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 / I can't get my sprite to walk up/right correctly

Author
Message
Ranietz
AGK Gold Backer
20
Years of Service
User Offline
Joined: 2nd Sep 2004
Location: Norway
Posted: 2nd Sep 2004 09:19 Edited at: 2nd Sep 2004 09:24
Hi, I'm new to this forum and new to programming in dark basic.

I'm making a 2D beat'em up game and I have some problems with my character's walking. I have atached parts of my code so you can take a look at it.
The "player walking" part is in the main loop, and the "sub programs" part is a sub program. Duh...
-"Player walking right" works ok. Both the x and y movement and the animation. The animation part is done in the sub program.
-"Player walking up/right" moves ok (x and y are working), but the image freezes at image 10 (the first image in the cycle). It wont animate.
I don't understand what's wrong since the animation for both cases is done by the same sub program.

Can anyone help me with this?
Let me know if there's som part you dont understand. English is not my native language...

edit: I'm using Dark Basic Classic and not Pro by the way...

-Ranietz-
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 2nd Sep 2004 11:12
That works here. Are you sure there is not another part of your program setting the variable image to 9 before going to the walking sub?

[addition] I just noticed the DBC part of that. I have DBP but the code you posted should work with either. If there are any other parts of your program that affect the variable image please post those parts as well.

Ranietz
AGK Gold Backer
20
Years of Service
User Offline
Joined: 2nd Sep 2004
Location: Norway
Posted: 2nd Sep 2004 11:51
Here is the whole code. The "player walking up/right" part was added for testing when I found out that the sprite wasn't animated when I walked up/right (or up/left, down/right or down/left). The animation for walking just left, right, up or down works fine.
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 2nd Sep 2004 12:12 Edited at: 2nd Sep 2004 12:16
Try changing this code

to this

or this

This was resetting the frame. I think using an if var=var=var=var is illegal. At least it acts wierd in DBP.

[edit] The second yet longer code will take less scan time because it will start at the top and if any are false it will not check the others. The first version seems to check all conditions even if some are false.

Ranietz
AGK Gold Backer
20
Years of Service
User Offline
Joined: 2nd Sep 2004
Location: Norway
Posted: 2nd Sep 2004 12:26
Thanks! It works now. I didn't know about the var=var=var thing. It's really hard find that kind of bugs. Thanks again!
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 2nd Sep 2004 12:32
I didn't know about that either until I ran your code as I had never tried it before. I played around with it when couldn't find anything else that would cause that problem. Glad I could help

Ranietz
AGK Gold Backer
20
Years of Service
User Offline
Joined: 2nd Sep 2004
Location: Norway
Posted: 2nd Sep 2004 12:44
I guess we both learned something today then.

Login to post a reply

Server time is: 2024-11-27 08:26:08
Your offset time is: 2024-11-27 08:26:08