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 / my spritr wont move right.

Author
Message
Katz
18
Years of Service
User Offline
Joined: 26th Oct 2006
Location: Pensacola, FL
Posted: 28th Oct 2006 10:49
I am using DBP I need a little help in getting my sprite working right. I am trying to make a sprite animation of a guy running up, down, left, right when you hit the arow key. The animation faces the direction of the arrowkey and the sprit moves in that direction. I think the problem is a math one in my value of n but I can't figure out what I am doing wrong.


FNG
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 28th Oct 2006 14:54 Edited at: 28th Oct 2006 15:06
I cleaned it up a little for your to demonstrate clean code is easy code.

we can see now a few errors you made.
first one was the set display size was incorrect 786 / 768 no biggy.

the main game loop was not completed, perhaps a copy glitch

look at REM UPDATE SPRITE
and tell me what you can remove from the main loop and still make it work.

place what you think can be removed into the PRE MAIN area.




I also would explore scancodes.

if scancode(KEYNUM)= 1
perform action
endif

but it also allows for double key movements or 8 way direction.

if scancode(KEYNUM) & scancode(KEYNUM) = 1
perform action
endif

KEYNUM is the scancode number equivalent that matches each key to the keyboard.
put this line into your main just above the screen fps command
text 1,16,STR$(scancode())
when you press a key it will reveal the number in question.

also if you check for what keys are pressed and flag a variable on and off
then check for that variable it will handle a lot better.

think of 1 to 8 for rotation
1 - top
2 - top right
3 - right
4 - btm right
5 - btm
6 - btm left
7 - left
8 - top left
eg:

if scancode(topkeyscancodenumber)=1 then movedirection = 1
if scancode(topkeyscancodenumber) & scancode(rightkeyscancodenumber) then movedirection = 2

then perform the action based on this one variable
if movedirection = 1 then move sprite etc. etc..

I hope some of this make sense

Katz
18
Years of Service
User Offline
Joined: 26th Oct 2006
Location: Pensacola, FL
Posted: 29th Oct 2006 03:26
I am sorry I am a new to programing. Bellow is what I have updated but I am still haveing promlems.
-Problem 1: I can't get arno to face the direction that he is moveing.
-Problem 2: I cant get my spider to move a little distance automaticly.
-Problem 3: I cant get my sprite collision between arno and spider to work.

Thank you very much for being pateint with a rookie.



FNG

Login to post a reply

Server time is: 2024-11-26 07:47:28
Your offset time is: 2024-11-26 07:47:28