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.

2D All the way! / How to make a sprite move left and right ?

Author
Message
Waltzer
19
Years of Service
User Offline
Joined: 8th Aug 2006
Location:
Posted: 22nd Sep 2006 21:59
Hello, I'm trying to make a 2D platform game (I just know the very basics of DBP).

And I was wondering, how can i make the sprite/character to move right when I press the right arrow, and how to make it move left when pressing the left key.
Scraggle
Moderator
22
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 23rd Sep 2006 18:38

That should do it


Zeus
20
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 23rd Sep 2006 19:03
Here:
x=250
y=250
sync on
do
x=x-5
x=x+5
sync
loop

Scraggle
Moderator
22
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 23rd Sep 2006 20:01
@JSG That code does absolutely nothing! It most certainly doesn't help answer the question. Having seen some of you other posts and considering you have just got back from a 2 week ban, I would suggest thinking long and hard before posting anything at all ... especially something as pointless as this!


Waltzer
19
Years of Service
User Offline
Joined: 8th Aug 2006
Location:
Posted: 23rd Sep 2006 22:09
Thank you Scraggle, it works (I'm so happy).
Waltzer
19
Years of Service
User Offline
Joined: 8th Aug 2006
Location:
Posted: 23rd Sep 2006 22:51
How do I make the sprite changing image while clicking leftkey and rightkey ?
sadsack
22
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 24th Sep 2006 04:39 Edited at: 24th Sep 2006 05:17
try this


Scraggle
Moderator
22
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 24th Sep 2006 15:42 Edited at: 24th Sep 2006 16:51
I don't think that is what he had in made.
I presume what you are asking for is to make the sprite animate while the keys are pressed.
This will do the job for you:


Change the variable AnimSpeed to adjust the rate of animation speed. It controls the speed in milliseconds, so a delay of 1000 will change the animation frame every second. A delay of zero will change the frame every loop.


Scraggle
Moderator
22
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 24th Sep 2006 16:50
...and here is some code to show an 8 frame sprite properly animated.
You will need to download the image I have used, so click the download button and save the image in the same folder as your project.

Here is the updated code:



Zeus
20
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 24th Sep 2006 19:04
@scraggle: Trying to blame for me for trying to help? I does if you have a sprite with it. I have tried thank you.

I am sorry for spamming and posting ridiculous posts, I will not do it again.
Gamedesign er20
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: The one place you would never look...
Posted: 24th Sep 2006 20:43
@Scraggle
does your code work with DBC?

Cocacola and Pepsi aren't that differnt. Deal with it.
Scraggle
Moderator
22
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 24th Sep 2006 21:13
@JSG You are not trying to help if your code is useless ... it confuses people becuase they think someone offering help must know what they are doing. Which you clearly don't!

Quote: "does your code work with DBC?"

I don't know, I don't have it. Try it and see but I am pretty sure you will have to delete the first line.


sadsack
22
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 24th Sep 2006 22:09 Edited at: 24th Sep 2006 22:18
I knew that is what he wanted the other sprited would be animate.
My way he would have to do a little thinking. He want to know how to put another sprit on screen when he press the move key. That is what the code he got.
renny

Edit: Your code is very nice.
edit2 I just seen your art work on the soldier. That is real nice,
I wish I could do that good.
Scraggle
Moderator
22
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 24th Sep 2006 23:03
So do I ... I got that from Reiners tilesets


sadsack
22
Years of Service
User Offline
Joined: 27th Nov 2003
Location: here
Posted: 25th Sep 2006 03:17
I will go there and see what they have,thanks Scraggle
renny
Sunflash
21
Years of Service
User Offline
Joined: 28th Jun 2005
Location: Seattle, Wa
Posted: 30th Sep 2006 02:51
Yeah, I'm making a platform game with graphics from www.reinerstileset.de too. It's going really well, the only place I'm stuck is at how to make the game run in a web browser, so I'm waiting for the DB Web Embedder thing that is being made... I plan to post the source code and media in the W.I.P. thread soon. But right now I'm just to lazy...

Your signature has been erased by a mod

Login to post a reply

Server time is: 2026-07-08 23:02:55
Your offset time is: 2026-07-08 23:02:55