IGNORED

# Kid Grid play mechanics

## Recommended Posts

I am soo noob to this ... how do you confine the Player object to the grid?

##### Share on other sites

There are 2 steps...

1. start the player off on the grid

2. only allow joystick moves that keep him on the grid

How you tackle step 2 is a bit dependent on the game. In Salvo, I do step 2 something like this...

```    temp1=playerx&15
temp2=playery&31
if temp1 then goto skipvertical
if joy0down && playery<160 then playerdir=0:goto joydone
if joy0up && playery>32   then playerdir=1:goto joydone
skipvertical
if temp2 then goto skiphorizontal
if joy0left  && playerx>16 then playerdir=2:goto joydone
if joy0right && playerx<96 then playerdir=3:goto joydone
skiphorizontal
joydone
```

In your case the grid isn't always a grid, so this probably isn't enough on it's own. You also need to peek at the character underneath the player and make sure it's not a blank space character. There's an example of this in the "ramcharmap" sample - the character check there is done to make sure there's ground under the player's feet, but it's conceptually the same thing.

##### Share on other sites

There are 2 steps...

1. start the player off on the grid

2. only allow joystick moves that keep him on the grid

How you tackle step 2 is a bit dependent on the game. In Salvo, I do step 2 something like this...

```    temp1=playerx&15
temp2=playery&31
if temp1 then goto skipvertical
if joy0down && playery<160 then playerdir=0:goto joydone
if joy0up && playery>32   then playerdir=1:goto joydone
skipvertical
if temp2 then goto skiphorizontal
if joy0left  && playerx>16 then playerdir=2:goto joydone
if joy0right && playerx<96 then playerdir=3:goto joydone
skiphorizontal
joydone
```
In your case the grid isn't always a grid, so this probably isn't enough on it's own. You also need to peek at the character underneath the player and make sure it's not a blank space character. There's an example of this in the "ramcharmap" sample - the character check there is done to make sure there's ground under the player's feet, but it's conceptually the same thing.

Thank you .. this gives me some insight as to go about it.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.