forums

TNT Basic Forums > Programming Q&A
help with asteroid game
< Last Thread     Next Thread >
Author
Thread        Post A Reply

05-15-2008 23:03

Posted by:
shepherd150

Click Here to Email shepherd150   Find more posts by shepherd150

hello i am a grade ten student. I have to create a game for my computers class and I have chosen to make an asteroids clone. I have already made the ship and and the bullets but I am stuck trying to make the asteroids.
I can make a single asteroid work but i cant figure out how to increase the number of asteroids for each level. I know i could design each level but is there any way of makeing the asteroids appear automatically?
does anyone have any suggestions?

05-16-2008 14:55

Posted by:
Jacob

Location:
San Francisco, CA

Click Here to Email Jacob   Find more posts by Jacob

Use arrays.

Like this
global float astroidX[999], astroidY[999], astroidXV[999], astroidYV[999]

while inGame
int i=0, numAstroids=10
for i=0 to numAstroids
'draw astroids at astroidX and astroidY
next
wend

05-16-2008 18:52

Posted by:
shepherd150

Click Here to Email shepherd150   Find more posts by shepherd150

thanks

that helps a lot but now i dont know how to make the asteroid move


here is my game so far:


global float width=600, height=600
global float yposship= height/2,xposship=width/2
global float shipspeed
global float shippic=0, rotationship
global float rotateship=0
global float shipxdirect, shipydirect, shipspeed=3
global float bulletx, bullety
global float bullspeed=6
global float bullrange=300
global int bullmove

window mode hardware width, height
load images 128
load sounds 128
playgame ()
procedure playgame ()
while not mouse button
sprite 1, xposship, yposship, shippic

if left
rotateship= rotateship-2
set sprite rotation 1,rotateship

else if right
rotateship= rotateship+2
set sprite rotation 1,rotateship

end if

rotationship= sprite rotation (1)
shipxdirect= Cos(rotationship)
shipydirect= sin(rotationship)


if up

yposship= yposship-(shipydirect*-shipspeed)
xposship= xposship+(shipxdirect*shipspeed)

end if

if xposship<0
xposship= width
else if xposship>width
xposship=0
end if

if yposship<0
yposship= height
else if yposship>height
yposship= 0
end if

if space
play sound 0
bulletx=xposship
bullety=yposship
sprite 2, bulletx ,bullety , 1
move sprite 2, (shipxdirect*bullrange), (shipydirect*bullrange), bullspeed
end if

bullmove= sprite moving (2)

if bullmove=0
sprite off 2
end if






draw frame

wend

end proc ()

05-16-2008 23:26

Posted by:
appleide

Click Here to Email appleide   Find more posts by appleide

You might want to look at for ... next loops . I think they're what you're looking for.

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.