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! / 2D Race Game - Help looping / moving sprites

Author
Message
Newbie5UK
21
Years of Service
User Offline
Joined: 13th Nov 2004
Location:
Posted: 22nd Nov 2004 20:47
Hi,

I have DARKBASIC Enhanced... (Not prof)

I would liek to write code for a 2D car game where you watch from the pit wall as cars go by right to left..

What command should i use to move the sprite (car).
Should I use a loop for each car ?(20 cars)

The cars will go from one side of the screen to other then complete rest of lap before coming back across finnish line...

I am new so need helps as to best commands and priciples for such a game.

thx
Torq
22
Years of Service
User Offline
Joined: 18th Jan 2004
Location:
Posted: 23rd Nov 2004 10:58
Well you could try something like this

load sprite "car.jpg",1
sync on
sync rate 60

do
gosub movecars
sync
loop

movecars:
for carmove = 1 to 20
move sprite carmove,5
next carmove
return

Now this dosent create the sprites or place them you will have to do that but its a general Idea of how to use a sub to move 20 cars. Hope this helps.

http://badtempergames.tripod.com

Torq
22
Years of Service
User Offline
Joined: 18th Jan 2004
Location:
Posted: 23rd Nov 2004 11:05
oops you have enhanced not pro well heres what he sub would look like.

load sprite "car.jpg",1
sync on
sync rate 60
x=0

do
gosub movecars
sync
loop



movecars:
inc x
for carmove= 1 to 20
sprite carmove,x,200,1
next carmove
if x >=640 then x=0
return

This lets you just change the x pos of each sprite. Should work for enhanced.


return

http://badtempergames.tripod.com

13e
21
Years of Service
User Offline
Joined: 20th Oct 2004
Location: Here
Posted: 23rd Nov 2004 23:19 Edited at: 23rd Nov 2004 23:20
You could have the track as a single scrolling image in the background with the car sprite pasted on top of it. This'd give the illusion of the car moving.

You could have a short series of sprites to animate the wheels or whatever to make the car look like it's going too.

Then if you want it to make the race stop when the car reaches the finish line, you can either make the track into one long image and make DB end the race when the image reaches a certain position or you could have DB increment a variable at every sync and when it reaches a certain integer, it ends the race.

Did that make sense to anyone else?

I could write you a small snippet if you'd like?

Login to post a reply

Server time is: 2026-06-11 13:13:56
Your offset time is: 2026-06-11 13:13:56