NIKON Posted February 2, 2015 Share Posted February 2, 2015 I am soo noob to this ... how do you confine the Player object to the grid? Quote Link to comment Share on other sites More sharing options...
RevEng Posted February 4, 2015 Share Posted February 4, 2015 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. Quote Link to comment Share on other sites More sharing options...
NIKON Posted February 4, 2015 Author Share Posted February 4, 2015 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.