Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Player Position on Grid

Author
Message
Novan
16
Years of Service
User Offline
Joined: 21st Jul 2008
Location:
Posted: 25th Jul 2008 22:55
I am trying to make a turn based rpg. I have a plane and a cube. The cube represents the player. The plane is divied up into a 5x5 grid. How can i tell where the player is and when i add an enemy where the enemy is. I dont mean the xyz, but which space on the grid. I was thinking of useing a matrix, but im not sure how to approach that. Thanks in advance.

PS here is an image showing the grid and player.
Papa Stiffy
17
Years of Service
User Offline
Joined: 22nd Sep 2007
Location:
Posted: 27th Jul 2008 20:37
Well, say your moving the object by 5 pixels to the right which would put the cube in the second column, first row. Just have 0,5 = the applied grid space. You can simply test the cooridinates of the object and tell which piece of the grid he is on.

For example, lets say for the middle square on the grid, the x,y coordinate of the center is -10,-10. Well, in order to center you character(or enemy), it would need to be placed at the x,y of -10,-10. Meaning the only place he could be would be the center of the grid.

Got some time to kill...? http://www.TheFlashArena.com
Scorpyo
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 27th Jul 2008 22:11 Edited at: 27th Jul 2008 22:12
i did something similar some time ago
maybe it will help
Novan
16
Years of Service
User Offline
Joined: 21st Jul 2008
Location:
Posted: 28th Jul 2008 09:09
Thanks guys that helps alot.

Login to post a reply

Server time is: 2024-11-25 19:22:19
Your offset time is: 2024-11-25 19:22:19