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 / sprite not appearing on the correct coordinates

Author
Message
Zeus
18
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 3rd Apr 2007 20:05
I hate to ask so many questions in one day. I have spent nearly an hour to figure out where the sprite should be pasted after you have moved. Example,

When I press the down key it moves down slowly.
When I get to the bottom I press the up key.
Then the sprite appears WAY up to the top of the screen.
It was supposed to go up where ever the player moved it to (e.g the bottom of the screen).

Code:


Any help would be greatly appreciated.

zeddex2
17
Years of Service
User Offline
Joined: 4th Mar 2007
Location:
Posted: 3rd Apr 2007 20:25


basicaly, if downkey is press , sprite 2 go down
if upkey is press sprite 1 go up

so your not moving the same sprite !!!!

PS i just want to help but your code is like really hard to read. Can you anderstand it like he are now ??

If you can, I can!
Zeus
18
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 3rd Apr 2007 20:53
sorry, here it's easier now.



zeddex2
17
Years of Service
User Offline
Joined: 4th Mar 2007
Location:
Posted: 3rd Apr 2007 21:00
i read your code like this,

sprite 1 and 2 are at position 50, 50
you hide sprite 2

if upkey then dir = 1
if downkey dir = 3

if dir = 1 then move sprite 1 up
if dir = 3 move sprite 2 down

but basically sprite 2 is hide so you don't see anything and sprite. just try that with 1 sprite first



just tell me if the sprite move correctly

If you can, I can!
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 5th Apr 2007 20:14
Jordan:

Try indenting your code!

You'll find it much easier to read and more people will help if it doesn't look like a jumbled mess...



TDK_Man

indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 6th Apr 2007 02:58
here is a sprite example JSG

read each part for an idea how to set this up.
this example is using arrays to manage things.
you could use typed arrays as well for a more effecient way to manage multiple objects.



Login to post a reply

Server time is: 2024-11-25 20:34:42
Your offset time is: 2024-11-25 20:34:42