Welcome! Log In Create A New Profile

Advanced

8 Way Movement in flash

Posted by pinball Wizard 
8 Way Movement in flash
January 13, 2009 01:58AM
I have gotten down a flash engine for side-scrollers like Super Mario Bros. and Mega-Man and it senses walls and can jump and move left and right. Now I need to get the sprite to move in a upward-rightward method using only the arrow keys. I can post some code if you need it to help me. I am working on a full fledged 16-bit dedication game with some type of engine like the listed games.
Re: 8 Way Movement in flash
January 13, 2009 08:48AM
Sorry, not quite sure what you're asking for. Are you asking how to read the input to accomplish this, or how to make a character jump?
Re: 8 Way Movement in flash
January 13, 2009 09:05PM
I have (at the moment Megaman sprites) a character with jump capabilities in a gravity world. I want to be able to jump upward but at the same time move right. At the moment It will either more right OR jump up. I want to get the the 45 degree angle part of the action.
Re: 8 Way Movement in flash
January 13, 2009 09:12PM
Assign a jump variable and a jump direction variable to your sprite's class (assuming your sprite is based off a class). Increment jump once every loop once the character is jumping. Then use a large number of if statments to change the x and y values of your sprite accordingly to each position and direction for each stage in the jump sequence. Also include if statements that could end the jump sequence (like if"megaman lands on a platform" stop the jump sequence).

Hope that helps.
Re: 8 Way Movement in flash
January 20, 2009 01:50AM
This is my code for the sprite. This includes gravity and jumping around.
onClipEvent (Load) {
	movespeed=5;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
play();
_x+=movespeed
gravity=2
}
else if (Key.isDown(Key.LEFT)) {
play();
_x-=movespeed
gravity=2
}
else if (Key.isDown(Key.DOWN)) {
_y+=movespeed
gravity=2
}
else if (Key.isDown(Key.UP)) {
_y-=movespeed+5
gravity=2
}
}
onClipEvent (enterFrame) { 
 radius=15.8
 while (_root.wall.hitTest(_x, _y+radius+5, true)) {
        _y--;
		speedy=0
		gravity=0
    }
    while (_root.wall.hitTest(_x, _y-radius-6, true)) {
        _y++;
    }
    while (_root.wall.hitTest(_x-radius-13, _y, true)) {
        _x++;
    }
    while (_root.wall.hitTest(_x+radius-5, _y, true)) {
        _x--;
	}
}
	onClipEvent (load) {
	gravity = 2;
	speedx = 0 ;
	speedy = 0 ;
}

onClipEvent (enterFrame) {

	speedy = speedy + gravity ;
	this._x += speedx/5 ;
	this._y += speedy/5 ;
}

If you can help me out in a more easy way to implement on the code already written.
Re: 8 Way Movement in flash
January 27, 2009 07:38AM
else if (Key.isDown(Key.DOWN)
Remove the "else".
Sorry, only registered users may post in this forum.

Click here to login