00:00
00:00
Newgrounds Background Image Theme

xrusteater0 just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

[HELP] Movement In Squares?

408 Views | 4 Replies
New Topic Respond to this Topic

[HELP] Movement In Squares? 2017-01-11 22:07:29


Hey, to some form of making a move similar to the bomberman?

Example: suppose I act a checkerboard background on a map, each square that has 25x25 cm.

Instead of the Player Add the x/y to get to this point, he jumps directly to the square.

Any idea?

Response to [HELP] Movement In Squares? 2017-01-12 05:22:17


You could use a two-dimensional array and store a current player position. In the game update loop you could render it at the current position based on the array. Like so:

var currX:int, currY:int;
var arr:Array = new Array(GRID_SIZE)
for(var i:uint = 0; i < arr.length; ++i) {
    arr[i] = new Array(GRID_SIZE);
    for(var j:uint = 0; j < arr[i].length; ++j) {
        arr[i][j] = new Tile();
    }
}
///move character
if key up -> currY -= step
if key left -> currX -= step
if key right -> currX += step
if key down -> currY += step
//render
player.x = arr[currX][currY].x
player.y = arr[currX][currY].y

Slint approves of me! | "This is Newgrounds.com, not Disney.com" - WadeFulp

"Sit look rub panda" - Alan Davies

BBS Signature

Response to [HELP] Movement In Squares? 2017-01-12 08:51:19


Well, I tried to make some changes because as2 doesn't support init, then changed to number, but nothing happened. Any idea?

Response to [HELP] Movement In Squares? 2017-01-15 05:15:27


At 1/12/17 08:51 AM, CrazY770 wrote: Well, I tried to make some changes because as2 doesn't support init, then changed to number, but nothing happened. Any idea?

What code are you using? Each section should be in a different clipEvent (render in enterFrame, moving in keyDown, etc...)


Slint approves of me! | "This is Newgrounds.com, not Disney.com" - WadeFulp

"Sit look rub panda" - Alan Davies

BBS Signature

Response to [HELP] Movement In Squares? 2017-01-20 10:55:28


player_mc.onEnterFrame = function(). I use this.