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 / Implementing boundary on player movement

Author
Message
Adam_db
17
Years of Service
User Offline
Joined: 28th Feb 2007
Location:
Posted: 28th Feb 2007 22:51
Hey hey, im making a 2d space shooter in dbpro, and need help implementing some boundaries on my player movement code. very simple stuff, but i cant seem to get this to work right.

it stays within the boundaries of the screen, but gets stuck on the axis. my ship sprite is 50x92 in dimensions also.

anyway, heres my code.




any help would be welcome
thanks,
Adam

----------------------------------------------------
Just because they are paranoid, doesnt mean they arent out to get you.
Adam_db
17
Years of Service
User Offline
Joined: 28th Feb 2007
Location:
Posted: 28th Feb 2007 23:36
***********************
FIXED
***********************

Nevermind, fixed it. silly really.

----------------------------------------------------
Just because they are paranoid, doesnt mean they arent out to get you.
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 28th Feb 2007 23:58 Edited at: 28th Feb 2007 23:59
Hello! I fixed it. This system is my favorite to use because no matter what you do the ship will never leave the screen (on the Y axis). Basically it just says that if the ship goes outside the screen, then just put it on the edge. See if you can figure out how to do the same for the X axis.

Anyway, here's your updated code:






If you couldn't get it to work for the X axis, here's the code for it:




Hope this helped

Adam_db
17
Years of Service
User Offline
Joined: 28th Feb 2007
Location:
Posted: 1st Mar 2007 14:24
Thanks very much for posting Sixty Squares, I managed it myself, i have only just registered on the forums, so they need to check my posts are okay before i can respond.

Its interesting that you found a solution completely different to the one i came up with, its funny that no-ones codes the same thing, the same way dontcha think?

incidentally this is how i solved the problem, in case anyone else out there found it tricky, and wants another solution, i changed the code to this:



also, i made my sprite change image as it moved left or right, a sort of tilting effect.



----------------------------------------------------
Just because they are paranoid, doesnt mean they arent out to get you.
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 1st Mar 2007 23:00
Oh! that's why your post wasn't there before!

Quote: "its funny that no-ones codes the same thing, the same way dontcha think?"


Everybody's different I guess

Anyway, good luck on your project

Login to post a reply

Server time is: 2024-11-25 22:42:12
Your offset time is: 2024-11-25 22:42:12