PDA

View Full Version : 2 games


The Scarlet Twizby
06-09-2008, 11:51 PM
I am currently working on two games, one similar to the Super Smash Bros series made by Nintendo and the other similar to the Pokemon series from the same company. When I have problems with one I work on the other until I figure out how to fix them usually, but now I have problems in both. I am, admittedly, as far as I know, a complete novice as programing goes, though I can improvise in a pinch, and have absolutely no idea of what I am doing most of the time. In any case, the problems I am currently having are:

In the SSB game, I am using a mask to determine whether or not the player's attack hits the opponent, and I only want it to hit over a certain range. This makes it incredibly difficult to use ground-based attacks, as hittests only work if the mask is touching the center of the opponent movie clip. The relevent code is below.
onClipEvent (enterFrame) {
if (_root.player.direct == true) {
direct = 1;//right
} else {
direct = -1;//left
}
if (_root.player.action != 2 && _root.player.action != 6 && _root.player.action != 7) {//the player is not attacking (there are three ways to attack, and thus three actions corresponding to attack. normal, special, and powerful)
_y = _root.player._y;
_root.player.hit = false;//the 'hit' variable determines whether or not the player has actually hit with the attack, or is just running through the animation for the attack.
_x = _root.player._x;
} else if (_root.player.action == 2) {
_y = _root.player._y+_root.player.atkrangey[_root.player.attack - 1];//the range arrays are composed as follows:[center point of where the mask should be for attack 1, for attack 2, 3, 4, range of attack 1 / 2, of attack 2 / 2, 3/2, 4/2]. this means that if the range of attack 1 = 20 and the starting point is 20, the mask would start at 20 pixels below the character and spread out 20 up and down. the same goes for all the other ranges.
_x = _root.player._x+_root.player.atkrangex[_root.player.attack - 1]*direct - 10;
_height = _root.player.atkrangey[_root.player.attack+3]*2;
_width = _root.player.atkrangex[_root.player.attack+3]*2;
} else if (_root.player.action == 6) {
_y = _root.player._y+_root.player.specrangey[_root.player.attack - 1];
_x = _root.player._x+_root.player.specrangex[_root.player.attack - 1]*direct - 20;
_height = _root.player.specrangey[_root.player.attack+3]*2;
_width = _root.player.specrangex[_root.player.attack+3]*2;
} else if (_root.player.action == 7) {
_y = _root.player._y+_root.player.prangey[_root.player.attack - 1];
_x = _root.player._x+_root.player.prangex[_root.player.attack - 1];
_height = _root.player.prangey[_root.player.attack+3]*2;
_width = _root.player.prangex[_root.player.attack+3]*2;
}
}

For the pokemon-esque one,
After creating a new character, the screen is supposed to change to the walkaround map. the only problem is that the movie won't play once it changes. relevent code is below.

on(release){ //attatched to the 'new character' button.
_root.char = new Character (player_txt.text, password_txt.text, gender)
_root.gotoAndPlay("walkaround map");
}

_root.onEnterFrame = function(){ //frame 'walkaround map'
trace(k) // k is undefined. when I play this movie, k is not traced.
player._x = _root.char._xcoord * 16
player._y = _root.char._ycoord * 16
}

NickZA
06-11-2008, 11:49 AM
Twizby,

I suggest you edit your original post and add [.AS][/AS.] (without the dots) aroudn your code so it looks like this:

this is my code.

Then people will read it, and they might respond.

The Scarlet Twizby
06-11-2008, 08:19 PM
Thank you.

The Scarlet Twizby
06-13-2008, 04:30 PM
I fixed the problem with the walkaround map, somehow, but I have another one. I am sure there is a more efficient way to map out a grid than what I am using- which is a class with the following code.

class FloorMap {
var _name:String;
var _xdim:Number;
var _ydim:Number;
var _scale:Number;
var _floor:Array;
function FloorMap (n: String, x:Number, y:Number,a:Number, b:String){
this._name = n;
this._xdim = x;
this._ydim = y;
this._scale = a;
this._floor = new Array(x*y);
//array = [(1,1), (1,2)... (1, ydim), (2, 1)... (2, ydim)... (xdim, ydim)]
}
}

the array is filled with a set of numbers which correspond to types of floor tiles.
If anyone knows an easier way to do this, could you please tell me?

The Scarlet Twizby
08-02-2008, 06:55 PM
I managed to get around the problem with coding the map, but now a have another problem (surprise, surprise) which has to do with buildings. When the character moves around, instead of the charactere itself moving, I have the background move. I see that there are two different ways to change backgrounds, say, between that inside a building or cave and the outside, which is to either make several different maps, one for the outside and one for each building/cave/place. the problem with this is that it means a whole lot of maps. an alternative is to have just two maps, one for outside buildings and one for inside them. the problem with this is that it means all buildings etc have to be the exact same size on the inside and outside. does anyone who has had experience with similar problems have any advice?

also, after adding the script to create a map to my .fla, when I try to run the .swf a message pops up saying that unless I abort the script my computer may stop running. Is this a problem with the code, such as an infinite loop, or is it just the fact that the code I used for the map is extremely long, or is it a bug in the viewing program? Or is it just giving a warning that the flash file is extremely large and may take a while to start running?

The Scarlet Twizby
08-25-2008, 09:49 PM
I fixed all the map problems now. As part of the game, there are several times when there is a menu consisting of numerous identical buttons. When one option is pressed, I want to have the buttons change their labels to say other things (for example, they start out "option 1", "option 2", and when option 1 is pressed, the labels on the two buttons change to "option 3" and "option 4"). I have tried to do this by putting a dynamic text box inside the movie clip which is acting as a button, with the button's instance name being "opt1" and the text box's "opt_txt", and refering to it in the main time line and on the movie clip as "opt1.opt_txt" and also by calling a function inside opt 1 with the following code

//inside movieclip
function changeText(x:String):Void{
opt_txt.text = x
}

//on main timeline
opt1.changeText("sbhdisdb")

when I do any of those things, nothing happens. Can anyone say what is going wrong?
Also, is there some sort of hittest-like function which will return true whenever any pixel in a particular movie clip hits one in another?