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.

Author
Message
JSN
22
Years of Service
User Offline
Joined: 8th Nov 2003
Location: 127.0.0.1
Posted: 29th Nov 2003 20:19
I've managed to get my sprites to wake me up on a morning, make my breakfast, do my work, run my bath and even get my slippers and pipe...

BUT...

I can't get just one little sprite to do a circular path on my screen...!

Does anyone have a quick bit of code I can learn from on how to simply move a sprite around a circle. Must be something to do with sin/cos/tan/etc (it's all greek to me!!)

TIA

~ J ~
BHoltzman
23
Years of Service
User Offline
Joined: 29th Aug 2002
Location:
Posted: 29th Nov 2003 21:07
Sure, I'll show you in psuedo code since I don't have dbpro in front of me right now.

for index = 1 to upperbound
spritemove sprite, CircleXSize * cos(index) + XOffset, CircleYSize * Sin(index) + YOffset
next index

Hopefully you get the idea.
Ravey
Retired TGC Developer
23
Years of Service
User Offline
Joined: 2nd Nov 2002
Location: Southern TGC Nerve Centre
Posted: 29th Nov 2003 21:15 Edited at: 29th Nov 2003 21:17
Just remember cos affects the x, sin for the y

sync rate 60 : sync on

radius=100
xoffset=screen width()/2
yoffset=screen height()/2

do
x=cos(wrapvalue(num))*radius
y=sin(wrapvalue(num))*radius
inc num,1
cls
circle x+xoffset,y+yoffset,8
sync
loop

Regards,
Dave Milton
Check out my games: Diode, Root, Binman & Skateboard Crazy
JSN
22
Years of Service
User Offline
Joined: 8th Nov 2003
Location: 127.0.0.1
Posted: 29th Nov 2003 21:16
Thanks both of you, the "cos affect x, sin affects Y" is a HUGE help.

Wish me luck...

~ J ~
Ravey
Retired TGC Developer
23
Years of Service
User Offline
Joined: 2nd Nov 2002
Location: Southern TGC Nerve Centre
Posted: 29th Nov 2003 21:17
Good luck

Regards,
Dave Milton
Check out my games: Diode, Root, Binman & Skateboard Crazy
JSN
22
Years of Service
User Offline
Joined: 8th Nov 2003
Location: 127.0.0.1
Posted: 30th Nov 2003 02:17
BHoltzman & Ravey...

Just a quick "Thanks" for giving me some excellent, straight to the point, and easy to follow code.

Got the routine working a dream (now doing "S" shapes and allsorts!!)

Again, my thanks...

-----

~ J ~
BHoltzman
23
Years of Service
User Offline
Joined: 29th Aug 2002
Location:
Posted: 30th Nov 2003 04:29
No problem. Have fun with your project.
Ravey
Retired TGC Developer
23
Years of Service
User Offline
Joined: 2nd Nov 2002
Location: Southern TGC Nerve Centre
Posted: 30th Nov 2003 12:52
Wohoo - good man, glad you are enjoying it

Regards,
Dave Milton
Check out my games: Diode, Root, Binman & Skateboard Crazy

Login to post a reply

Server time is: 2026-07-27 01:32:53
Your offset time is: 2026-07-27 01:32:53