%button/title/autor/insructions
Font.Draw ("Start", 290, 130,(Font.New ("arial:20:bold,")),white)
Font.Draw ("ASTEROID BLASTER", 125, 325,(Font.New ("arial:30:bold,")),white)
Font.Draw ("Instructions", 290, 75,(Font.New ("arial:10:bold,")),white)
Font.Draw ("Shoot the asteroids as they come down. Each time you shoot one, the next one comes faster.", 23, 55,(Font.New ("arial:10:bold,")),white)
Font.Draw ("If you let one go past you or if you get hit by one then you lose!", 125, 35,(Font.New ("arial:10:bold,")),white)
View.Update
% mouse button
loop % A
mousewhere (x,y,b)
if x>250 and x<400 and y>100 and y<175 and b=1 then % B
delay (5)
cls
View.Update
%background
drawfillbox (0,0,maxx,maxy,black)
for i : 0 .. 250 %stars in background
drawdot (Rand.Int (0, maxx), Rand.Int (0, maxy), 0)
end for
%set movement
loop % C
Input.KeyDown (chars) %set input key down for movement
locate (1, 1)
%up arrow/direction
if chars (KEY_UP_ARROW) then % D
if y2 < 380 then %stop from going off the screen
drawfillbox (x1, y1, x2, y2, 255) %to cover box
y1 += 5 %to move box
y2 += 5
drawfillbox (x1, y1, x2, y2, 0) %box
end if
%right arrow
elsif chars (KEY_RIGHT_ARROW) then
if x2 < maxx then %stop from going off the screen
drawfillbox (x1, y1, x2, y2, 255) %to cover box
x1 += 5 %to move box
x2 += 5
drawfillbox (x1, y1, x2, y2, 0) %box
end if
%left arrow
elsif chars (KEY_LEFT_ARROW) then
if x1 > 0 then %stop from going off the screen
drawfillbox (x1, y1, x2, y2, 255) %to cover box
x1 -= 5 %to move box
x2 -= 5
drawfillbox (x1, y1, x2, y2, 0) %box
end if
%down arrow
elsif chars (KEY_DOWN_ARROW) then
if y1 > 0 then %stop from going off the screen
drawfillbox (x1, y1, x2, y2, 255) %to cover box
y1 -= 5 %to move box
y2 -= 5
drawfillbox (x1, y1, x2, y2, 0) %box
end if
end if % D
%make shooting
if chars (KEY_ENTER) then
shoot:=1
end if
if shoot = 1 then
drawfillbox (sx1, sy1, sx2, sy2, 255) %to cover shot
sy1 += 10 %to move box
sy2 += 10
drawfillbox (sx1, sy1, sx2, sy2, 14) %shot
end if
if sy1> maxy then
shoot := 0
end if
if shoot = 0 then
sx1 := x1+5
sy1 := y1+12
sx2 := x2-5
sy2 := y2+12
end if
delay (25)
if a1 > 400 then
drawoval (b2 , maxy-a2, 20, 20, 0)
View.Update
delay (16)
drawoval (b2 , maxy-a2, 20, 20, 255)
a2:= a2+1
end if
if a2 > 400 then
drawoval (b3 , maxy-a3, 20, 20, 0)
View.Update
delay (14)
drawoval (b3 , maxy-a3, 20, 20, 255)
a3:= a3+1
end if
if a3 > 400 then
drawoval (b4 , maxy-a4, 20, 20, 0)
View.Update
delay (12)
drawoval (b4 , maxy-a4, 20, 20, 255)
a4:= a4+1
end if
if a4 > 400 then
drawoval (b5 , maxy-a5, 20, 20, 0)
View.Update
delay (10)
drawoval (b5 , maxy-a5, 20, 20, 255)
a5:= a5+1
end if
if a5 > 400 then
drawoval (b6 , maxy-a6, 20, 20, 0)
View.Update
delay (8)
drawoval (b6 , maxy-a6, 20, 20, 255)
a6:= a6+1
end if
if a6 > 400 then
drawoval (b7 , maxy-a7, 20, 20, 0)
View.Update
delay (6)
drawoval (b7 , maxy-a7, 20, 20, 255)
a7:= a7+1
end if
if a7 > 400 then
drawoval (b8 , maxy-a8, 20, 20, 0)
View.Update
delay (4)
drawoval (b8 , maxy-a8, 20, 20, 255)
a8:= a8+1
end if
if a8 > 400 then
drawoval (b9 , maxy-a9, 20, 20, 0)
View.Update
delay (2)
drawoval (b9 , maxy-a9, 20, 20, 255)
a9:= a9+1
end if
if a9 > 400 then
drawoval (b10 , maxy-a10, 20, 20, 0)
View.Update
delay (0)
drawoval (b10 , maxy-a10, 20, 20, 255)
a10:= a10+1
end if
end loop % C
end if % B
end loop % A
but when i try to do a collision thing, it never works
for example i tried somthing like this:
code:
if sx2 = b1 and sy2 = a1 then
cls
end if
and it didn't work.
Sponsor Sponsor
Martin
Posted: Sun Jan 15, 2006 10:50 pm Post subject: (No subject)
Trace through the program and see what happens. You are clearing the screen, but the variable still exists. So on one frame, it detects that the asteroid is hitting and then clears the screen. The next frame though it draws everything again.
Not pertaining to your actual problem, but learn how to use arrays!
Posted: Mon Jan 16, 2006 4:13 pm Post subject: (No subject)
What you'll want to do is use a boolean variable (in case you didn't know it's a variable that can contain either true or false) called let's say hasHit that is true if the asteroid has hit the player and false if it hasn't. When the player hits the asteroid you set hasHit to true. Then have it so the asteroid is only draw when hasHit is false. You'll need to do this for all of your asteroids, if you take martins advice and learn to use array you can have an array of boolean values and use a for statement instead of repeating your code 10 times.
codemage
Posted: Tue Jan 17, 2006 1:13 pm Post subject: (No subject)
ha**censored**?
Or... perhaps "has_hit"?
Or "ateroid_alive", for a better naming convention.
(O_o)
Posted: Tue Jan 17, 2006 5:29 pm Post subject: (No subject)
phew..
i got that working, thank you bored.
but once again...there is a problem
when ever the bullet hits the asteroid it doesn't disappear right away, and some times it does the opposite; it goes away before it touches it...
here's the code
%button/title/autor/insructions
Font.Draw ("Start", 290, 130,(Font.New ("arial:20:bold,")),white)
Font.Draw ("ASTEROID BLASTER", 125, 325,(Font.New ("arial:30:bold,")),white)
Font.Draw ("TEE- 20O", 5, 385,(Font.New ("arial:10:bold,")),white)
Font.Draw ("Mr.North", 583, 385,(Font.New ("arial:10:bold,")),white)
Font.Draw ("Instructions", 290, 75,(Font.New ("arial:10:bold,")),white)
Font.Draw ("Shoot the asteroids as they come down. Each time you shoot one, the next one comes faster.", 23, 55,(Font.New ("arial:10:bold,")),white)
Font.Draw ("If you let one go past you or if you get hit by one then you lose!", 125, 35,(Font.New ("arial:10:bold,")),white)
View.Update
% declare asteroids
proc asteroid1
if o1 = 0 then
drawoval (b1 , maxy-a(1), 20, 20, 0)
View.Update
drawoval (b1 , maxy-a(1), 20, 20, 255)
a(1):= a(1)+1
if a(1) > 400 then
quit
end if
end if
end asteroid1
proc asteroid2
if o2 = o1 then
drawoval (b2 , maxy-a(2), 20, 20, 0)
View.Update
drawoval (b2 , maxy-a(2), 20, 20, 255)
a(2):= a(2)+1
if a(2) > 400 then
quit
end if
end if
end asteroid2
proc asteroid3
if o3 = o2 then
drawoval (b3 , maxy-a(3), 20, 20, 0)
View.Update
drawoval (b3 , maxy-a(3), 20, 20, 255)
a(3):= a(3)+1
if a(3) > 400 then
quit
end if
end if
end asteroid3
proc asteroid4
if o4 = o3 then
drawoval (b4 , maxy-a(4), 20, 20, 0)
View.Update
drawoval (b4 , maxy-a(4), 20, 20, 255)
a(4):= a(4)+1
if a(4) > 400 then
quit
end if
end if
end asteroid4
proc asteroid5
if o5 = o4 then
drawoval (b5 , maxy-a(5), 20, 20, 0)
View.Update
drawoval (b5 , maxy-a(5), 20, 20, 255)
a(5):= a(5)+1
if a(5) > 400 then
quit
end if
end if
end asteroid5
proc asteroid6
if o6 = o5 then
drawoval (b6 , maxy-a(6), 20, 20, 0)
View.Update
drawoval (b6 , maxy-a(6), 20, 20, 255)
a(6):= a(6)+1
if a(6) > 400 then
quit
end if
end if
end asteroid6
proc asteroid7
if o7 = o6 then
drawoval (b7 , maxy-a(7), 20, 20, 0)
View.Update
drawoval (b7 , maxy-a(7), 20, 20, 255)
a(7):= a(7)+1
if a(7) > 400 then
quit
end if
end if
end asteroid7
proc asteroid8
if o8 = o7 then
drawoval (b8 , maxy-a(8), 20, 20, 0)
View.Update
drawoval (b8 , maxy-a(8), 20, 20, 255)
a(8):= a(8)+1
if a(8) > 400 then
quit
end if
end if
end asteroid8
proc asteroid9
if o9 = o8 then
drawoval (b9 , maxy-a(9), 20, 20, 0)
View.Update
drawoval (b9 , maxy-a(9), 20, 20, 255)
a(9):= a(9)+1
if a(9) > 400 then
quit
end if
end if
end asteroid9
proc asteroid10
if o10 = o9 then
drawoval (b10 , maxy-a(10), 20, 20, 0)
View.Update
drawoval (b10 , maxy-a(10), 20, 20, 255)
a(10):= a(10)+1
if a(10) > 400 then
quit
end if
end if
end asteroid10
%put all in
%declare movement *************************************MOVE***************************88
proc move
loop % C
Input.KeyDown (chars) %set input key down for movement
locate (1, 1)
if chars (KEY_UP_ARROW) then % D
if y2 < maxy then %stop from going off the screen
drawfillbox (x1, y1, x2, y2, 255) %to cover box
y1 += 5 %to move box
y2 += 5
drawfillbox (x1, y1, x2, y2, 0) %box
end if
%down arrow
elsif chars (KEY_DOWN_ARROW) then
if y1 > 0 then %stop from going off the screen
drawfillbox (x1, y1, x2, y2, 255) %to cover box
y1 -= 5 %to move box
y2 -= 5
drawfillbox (x1, y1, x2, y2, 0) %box
end if
%right arrow
elsif chars (KEY_RIGHT_ARROW) then
if x2 < maxx then %stop from going off the screen
drawfillbox (x1, y1, x2, y2, 255) %to cover box
x1 += 5 %to move box
x2 += 5
drawfillbox (x1, y1, x2, y2, 0) %box
end if
%left arrow
elsif chars (KEY_LEFT_ARROW) then
if x1 > 0 then %stop from going off the screen
drawfillbox (x1, y1, x2, y2, 255) %to cover box
x1 -= 5 %to move box
x2 -= 5
drawfillbox (x1, y1, x2, y2, 0) %box
end if
end if % D
%make shooting
if chars (KEY_ENTER) then
shoot:=1
end if
if shoot = 1 then
drawfillbox (sx1, sy1, sx2, sy2, 255) %to cover shot
sy1 += 10 %to move box
sy2 += 10
drawfillbox (sx1, sy1, sx2, sy2, 14) %shot
end if
if sy1> maxy then
shoot := 0
end if
if shoot = 0 then
sx1 := x1+5
sy1 := y1+12
sx2 := x2-5
sy2 := y2+12
end if
delay (25)
asteroid1
%***********************************COLLISIONS***************************************%
%first collision
if b1 > sx1 and b1 < sx2 and a(1) > sy1 and a(1) < sy2 then
o1 := 1
score := score + 1
end if
if o2 = o1 then
asteroid2
end if
%second collision
if b2 > sx1 and b2 < sx2 and a(2) > sy1 and a(2) < sy2 then
o2 := 2
score := score + 2
end if
if o3 = o2 then
asteroid3
end if
%third coll
if b3 > sx1 and b3 < sx2 and a(3) > sy1 and a(3) < sy2 then
o3 := 3
score := score + 3
end if
if o4 = o3 then
asteroid4
end if
%collision 4
if b4 > sx1 and b4 < sx2 and a(4) > sy1 and a(4) < sy2 then
o4 := 4
score := score + 4
end if
if o5 = o4 then
asteroid5
end if
%coll 5
if b5 > sx1 and b5 < sx2 and a(5) > sy1 and a(5) < sy2 then
o5 := 5
score := score + 5
end if
if o6 = o5 then
asteroid6
end if
%coll 6
if b6 > sx1 and b6 < sx2 and a(6) > sy1 and a(6) < sy2 then
o6 := 6
score := score + 6
end if
if o7 = o6 then
asteroid7
end if
%coll 7
if b7 > sx1 and b7 < sx2 and a(7) > sy1 and a(7) < sy2 then
o7 := 7
score := score + 7
end if
if o8 = o7 then
asteroid8
end if
%coll 8
if b8 > sx1 and b8 < sx2 and a(8) > sy1 and a(8) < sy2 then
o8 := 8
score := score + 8
end if
if o9 = o8 then
asteroid9
end if
%coll 9
if b9 > sx1 and b9 < sx2 and a(9) > sy1 and a(9) < sy2 then
o9 := 9
score := score + 9
end if
if o10 = o9 then
asteroid10
end if
%coll 10
if b10 > sx1 and b10 < sx2 and a(10) > sy1 and a(10) < sy2 then
o10 := 10
score := score + 10
end if
if o10 = 10 then
quit
end if
end loop % C
end move
%**************************START PROGRAM*******************
% mouse button
loop % A
mousewhere (x,y,b)
if x>250 and x<400 and y>100 and y<175 and b=1 then % B
delay (5)
cls
View.Update
%background
drawfillbox (0,0,maxx,maxy,black)
for i : 0 .. 250 %stars in background
drawdot (Rand.Int (0, maxx), Rand.Int (0, maxy), 0)
end for
%set declared movement/ loop movement and asteroids
move
end if % B
end loop % A
(O_o)
Posted: Tue Jan 17, 2006 5:30 pm Post subject: (No subject)
phew..
i got that working, thank you bored.
but once again...there is a problem
when ever the bullet hits the asteroid it doesn't disappear right away, and some times it does the opposite; it goes away before it touches it...
here's the code
%button/title/autor/insructions
Font.Draw ("Start", 290, 130,(Font.New ("arial:20:bold,")),white)
Font.Draw ("ASTEROID BLASTER", 125, 325,(Font.New ("arial:30:bold,")),white)
Font.Draw ("TEE- 20O", 5, 385,(Font.New ("arial:10:bold,")),white)
Font.Draw ("Mr.North", 583, 385,(Font.New ("arial:10:bold,")),white)
Font.Draw ("Instructions", 290, 75,(Font.New ("arial:10:bold,")),white)
Font.Draw ("Shoot the asteroids as they come down. Each time you shoot one, the next one comes faster.", 23, 55,(Font.New ("arial:10:bold,")),white)
Font.Draw ("If you let one go past you or if you get hit by one then you lose!", 125, 35,(Font.New ("arial:10:bold,")),white)
View.Update
% declare asteroids
proc asteroid1
if o1 = 0 then
drawoval (b1 , maxy-a(1), 20, 20, 0)
View.Update
drawoval (b1 , maxy-a(1), 20, 20, 255)
a(1):= a(1)+1
if a(1) > 400 then
quit
end if
end if
end asteroid1
proc asteroid2
if o2 = o1 then
drawoval (b2 , maxy-a(2), 20, 20, 0)
View.Update
drawoval (b2 , maxy-a(2), 20, 20, 255)
a(2):= a(2)+1
if a(2) > 400 then
quit
end if
end if
end asteroid2
proc asteroid3
if o3 = o2 then
drawoval (b3 , maxy-a(3), 20, 20, 0)
View.Update
drawoval (b3 , maxy-a(3), 20, 20, 255)
a(3):= a(3)+1
if a(3) > 400 then
quit
end if
end if
end asteroid3
proc asteroid4
if o4 = o3 then
drawoval (b4 , maxy-a(4), 20, 20, 0)
View.Update
drawoval (b4 , maxy-a(4), 20, 20, 255)
a(4):= a(4)+1
if a(4) > 400 then
quit
end if
end if
end asteroid4
proc asteroid5
if o5 = o4 then
drawoval (b5 , maxy-a(5), 20, 20, 0)
View.Update
drawoval (b5 , maxy-a(5), 20, 20, 255)
a(5):= a(5)+1
if a(5) > 400 then
quit
end if
end if
end asteroid5
proc asteroid6
if o6 = o5 then
drawoval (b6 , maxy-a(6), 20, 20, 0)
View.Update
drawoval (b6 , maxy-a(6), 20, 20, 255)
a(6):= a(6)+1
if a(6) > 400 then
quit
end if
end if
end asteroid6
proc asteroid7
if o7 = o6 then
drawoval (b7 , maxy-a(7), 20, 20, 0)
View.Update
drawoval (b7 , maxy-a(7), 20, 20, 255)
a(7):= a(7)+1
if a(7) > 400 then
quit
end if
end if
end asteroid7
proc asteroid8
if o8 = o7 then
drawoval (b8 , maxy-a(8), 20, 20, 0)
View.Update
drawoval (b8 , maxy-a(8), 20, 20, 255)
a(8):= a(8)+1
if a(8) > 400 then
quit
end if
end if
end asteroid8
proc asteroid9
if o9 = o8 then
drawoval (b9 , maxy-a(9), 20, 20, 0)
View.Update
drawoval (b9 , maxy-a(9), 20, 20, 255)
a(9):= a(9)+1
if a(9) > 400 then
quit
end if
end if
end asteroid9
proc asteroid10
if o10 = o9 then
drawoval (b10 , maxy-a(10), 20, 20, 0)
View.Update
drawoval (b10 , maxy-a(10), 20, 20, 255)
a(10):= a(10)+1
if a(10) > 400 then
quit
end if
end if
end asteroid10
%put all in
%declare movement *************************************MOVE***************************88
proc move
loop % C
Input.KeyDown (chars) %set input key down for movement
locate (1, 1)
if chars (KEY_UP_ARROW) then % D
if y2 < maxy then %stop from going off the screen
drawfillbox (x1, y1, x2, y2, 255) %to cover box
y1 += 5 %to move box
y2 += 5
drawfillbox (x1, y1, x2, y2, 0) %box
end if
%down arrow
elsif chars (KEY_DOWN_ARROW) then
if y1 > 0 then %stop from going off the screen
drawfillbox (x1, y1, x2, y2, 255) %to cover box
y1 -= 5 %to move box
y2 -= 5
drawfillbox (x1, y1, x2, y2, 0) %box
end if
%right arrow
elsif chars (KEY_RIGHT_ARROW) then
if x2 < maxx then %stop from going off the screen
drawfillbox (x1, y1, x2, y2, 255) %to cover box
x1 += 5 %to move box
x2 += 5
drawfillbox (x1, y1, x2, y2, 0) %box
end if
%left arrow
elsif chars (KEY_LEFT_ARROW) then
if x1 > 0 then %stop from going off the screen
drawfillbox (x1, y1, x2, y2, 255) %to cover box
x1 -= 5 %to move box
x2 -= 5
drawfillbox (x1, y1, x2, y2, 0) %box
end if
end if % D
%make shooting
if chars (KEY_ENTER) then
shoot:=1
end if
if shoot = 1 then
drawfillbox (sx1, sy1, sx2, sy2, 255) %to cover shot
sy1 += 10 %to move box
sy2 += 10
drawfillbox (sx1, sy1, sx2, sy2, 14) %shot
end if
if sy1> maxy then
shoot := 0
end if
if shoot = 0 then
sx1 := x1+5
sy1 := y1+12
sx2 := x2-5
sy2 := y2+12
end if
delay (25)
asteroid1
%***********************************COLLISIONS***************************************%
%first collision
if b1 > sx1 and b1 < sx2 and a(1) > sy1 and a(1) < sy2 then
o1 := 1
score := score + 1
end if
if o2 = o1 then
asteroid2
end if
%second collision
if b2 > sx1 and b2 < sx2 and a(2) > sy1 and a(2) < sy2 then
o2 := 2
score := score + 2
end if
if o3 = o2 then
asteroid3
end if
%third coll
if b3 > sx1 and b3 < sx2 and a(3) > sy1 and a(3) < sy2 then
o3 := 3
score := score + 3
end if
if o4 = o3 then
asteroid4
end if
%collision 4
if b4 > sx1 and b4 < sx2 and a(4) > sy1 and a(4) < sy2 then
o4 := 4
score := score + 4
end if
if o5 = o4 then
asteroid5
end if
%coll 5
if b5 > sx1 and b5 < sx2 and a(5) > sy1 and a(5) < sy2 then
o5 := 5
score := score + 5
end if
if o6 = o5 then
asteroid6
end if
%coll 6
if b6 > sx1 and b6 < sx2 and a(6) > sy1 and a(6) < sy2 then
o6 := 6
score := score + 6
end if
if o7 = o6 then
asteroid7
end if
%coll 7
if b7 > sx1 and b7 < sx2 and a(7) > sy1 and a(7) < sy2 then
o7 := 7
score := score + 7
end if
if o8 = o7 then
asteroid8
end if
%coll 8
if b8 > sx1 and b8 < sx2 and a(8) > sy1 and a(8) < sy2 then
o8 := 8
score := score + 8
end if
if o9 = o8 then
asteroid9
end if
%coll 9
if b9 > sx1 and b9 < sx2 and a(9) > sy1 and a(9) < sy2 then
o9 := 9
score := score + 9
end if
if o10 = o9 then
asteroid10
end if
%coll 10
if b10 > sx1 and b10 < sx2 and a(10) > sy1 and a(10) < sy2 then
o10 := 10
score := score + 10
end if
if o10 = 10 then
quit
end if
end loop % C
end move
%**************************START PROGRAM*******************
% mouse button
loop % A
mousewhere (x,y,b)
if x>250 and x<400 and y>100 and y<175 and b=1 then % B
delay (5)
cls
View.Update
%background
drawfillbox (0,0,maxx,maxy,black)
for i : 0 .. 250 %stars in background
drawdot (Rand.Int (0, maxx), Rand.Int (0, maxy), 0)
end for
%set declared movement/ loop movement and asteroids
move
end if % B
end loop % A
(O_o)
Posted: Tue Jan 17, 2006 5:31 pm Post subject: (No subject)
phew..
i got that working, thank you bored.
but once again...there is a problem
when ever the bullet hits the asteroid it doesn't disappear right away, and some times it does the opposite; it goes away before it touches it...
here's the code
%button/title/autor/insructions
Font.Draw ("Start", 290, 130,(Font.New ("arial:20:bold,")),white)
Font.Draw ("ASTEROID BLASTER", 125, 325,(Font.New ("arial:30:bold,")),white)
Font.Draw ("TEE- 20O", 5, 385,(Font.New ("arial:10:bold,")),white)
Font.Draw ("Mr.North", 583, 385,(Font.New ("arial:10:bold,")),white)
Font.Draw ("Instructions", 290, 75,(Font.New ("arial:10:bold,")),white)
Font.Draw ("Shoot the asteroids as they come down. Each time you shoot one, the next one comes faster.", 23, 55,(Font.New ("arial:10:bold,")),white)
Font.Draw ("If you let one go past you or if you get hit by one then you lose!", 125, 35,(Font.New ("arial:10:bold,")),white)
View.Update
% declare asteroids
proc asteroid1
if o1 = 0 then
drawoval (b1 , maxy-a(1), 20, 20, 0)
View.Update
drawoval (b1 , maxy-a(1), 20, 20, 255)
a(1):= a(1)+1
if a(1) > 400 then
quit
end if
end if
end asteroid1
proc asteroid2
if o2 = o1 then
drawoval (b2 , maxy-a(2), 20, 20, 0)
View.Update
drawoval (b2 , maxy-a(2), 20, 20, 255)
a(2):= a(2)+1
if a(2) > 400 then
quit
end if
end if
end asteroid2
proc asteroid3
if o3 = o2 then
drawoval (b3 , maxy-a(3), 20, 20, 0)
View.Update
drawoval (b3 , maxy-a(3), 20, 20, 255)
a(3):= a(3)+1
if a(3) > 400 then
quit
end if
end if
end asteroid3
proc asteroid4
if o4 = o3 then
drawoval (b4 , maxy-a(4), 20, 20, 0)
View.Update
drawoval (b4 , maxy-a(4), 20, 20, 255)
a(4):= a(4)+1
if a(4) > 400 then
quit
end if
end if
end asteroid4
proc asteroid5
if o5 = o4 then
drawoval (b5 , maxy-a(5), 20, 20, 0)
View.Update
drawoval (b5 , maxy-a(5), 20, 20, 255)
a(5):= a(5)+1
if a(5) > 400 then
quit
end if
end if
end asteroid5
proc asteroid6
if o6 = o5 then
drawoval (b6 , maxy-a(6), 20, 20, 0)
View.Update
drawoval (b6 , maxy-a(6), 20, 20, 255)
a(6):= a(6)+1
if a(6) > 400 then
quit
end if
end if
end asteroid6
proc asteroid7
if o7 = o6 then
drawoval (b7 , maxy-a(7), 20, 20, 0)
View.Update
drawoval (b7 , maxy-a(7), 20, 20, 255)
a(7):= a(7)+1
if a(7) > 400 then
quit
end if
end if
end asteroid7
proc asteroid8
if o8 = o7 then
drawoval (b8 , maxy-a(8), 20, 20, 0)
View.Update
drawoval (b8 , maxy-a(8), 20, 20, 255)
a(8):= a(8)+1
if a(8) > 400 then
quit
end if
end if
end asteroid8
proc asteroid9
if o9 = o8 then
drawoval (b9 , maxy-a(9), 20, 20, 0)
View.Update
drawoval (b9 , maxy-a(9), 20, 20, 255)
a(9):= a(9)+1
if a(9) > 400 then
quit
end if
end if
end asteroid9
proc asteroid10
if o10 = o9 then
drawoval (b10 , maxy-a(10), 20, 20, 0)
View.Update
drawoval (b10 , maxy-a(10), 20, 20, 255)
a(10):= a(10)+1
if a(10) > 400 then
quit
end if
end if
end asteroid10
%put all in
%declare movement *************************************MOVE***************************88
proc move
loop % C
Input.KeyDown (chars) %set input key down for movement
locate (1, 1)
if chars (KEY_UP_ARROW) then % D
if y2 < maxy then %stop from going off the screen
drawfillbox (x1, y1, x2, y2, 255) %to cover box
y1 += 5 %to move box
y2 += 5
drawfillbox (x1, y1, x2, y2, 0) %box
end if
%down arrow
elsif chars (KEY_DOWN_ARROW) then
if y1 > 0 then %stop from going off the screen
drawfillbox (x1, y1, x2, y2, 255) %to cover box
y1 -= 5 %to move box
y2 -= 5
drawfillbox (x1, y1, x2, y2, 0) %box
end if
%right arrow
elsif chars (KEY_RIGHT_ARROW) then
if x2 < maxx then %stop from going off the screen
drawfillbox (x1, y1, x2, y2, 255) %to cover box
x1 += 5 %to move box
x2 += 5
drawfillbox (x1, y1, x2, y2, 0) %box
end if
%left arrow
elsif chars (KEY_LEFT_ARROW) then
if x1 > 0 then %stop from going off the screen
drawfillbox (x1, y1, x2, y2, 255) %to cover box
x1 -= 5 %to move box
x2 -= 5
drawfillbox (x1, y1, x2, y2, 0) %box
end if
end if % D
%make shooting
if chars (KEY_ENTER) then
shoot:=1
end if
if shoot = 1 then
drawfillbox (sx1, sy1, sx2, sy2, 255) %to cover shot
sy1 += 10 %to move box
sy2 += 10
drawfillbox (sx1, sy1, sx2, sy2, 14) %shot
end if
if sy1> maxy then
shoot := 0
end if
if shoot = 0 then
sx1 := x1+5
sy1 := y1+12
sx2 := x2-5
sy2 := y2+12
end if
delay (25)
asteroid1
%***********************************COLLISIONS***************************************%
%first collision
if b1 > sx1 and b1 < sx2 and a(1) > sy1 and a(1) < sy2 then
o1 := 1
score := score + 1
end if
if o2 = o1 then
asteroid2
end if
%second collision
if b2 > sx1 and b2 < sx2 and a(2) > sy1 and a(2) < sy2 then
o2 := 2
score := score + 2
end if
if o3 = o2 then
asteroid3
end if
%third coll
if b3 > sx1 and b3 < sx2 and a(3) > sy1 and a(3) < sy2 then
o3 := 3
score := score + 3
end if
if o4 = o3 then
asteroid4
end if
%collision 4
if b4 > sx1 and b4 < sx2 and a(4) > sy1 and a(4) < sy2 then
o4 := 4
score := score + 4
end if
if o5 = o4 then
asteroid5
end if
%coll 5
if b5 > sx1 and b5 < sx2 and a(5) > sy1 and a(5) < sy2 then
o5 := 5
score := score + 5
end if
if o6 = o5 then
asteroid6
end if
%coll 6
if b6 > sx1 and b6 < sx2 and a(6) > sy1 and a(6) < sy2 then
o6 := 6
score := score + 6
end if
if o7 = o6 then
asteroid7
end if
%coll 7
if b7 > sx1 and b7 < sx2 and a(7) > sy1 and a(7) < sy2 then
o7 := 7
score := score + 7
end if
if o8 = o7 then
asteroid8
end if
%coll 8
if b8 > sx1 and b8 < sx2 and a(8) > sy1 and a(8) < sy2 then
o8 := 8
score := score + 8
end if
if o9 = o8 then
asteroid9
end if
%coll 9
if b9 > sx1 and b9 < sx2 and a(9) > sy1 and a(9) < sy2 then
o9 := 9
score := score + 9
end if
if o10 = o9 then
asteroid10
end if
%coll 10
if b10 > sx1 and b10 < sx2 and a(10) > sy1 and a(10) < sy2 then
o10 := 10
score := score + 10
end if
if o10 = 10 then
quit
end if
end loop % C
end move
%**************************START PROGRAM*******************
% mouse button
loop % A
mousewhere (x,y,b)
if x>250 and x<400 and y>100 and y<175 and b=1 then % B
delay (5)
cls
View.Update
%background
drawfillbox (0,0,maxx,maxy,black)
for i : 0 .. 250 %stars in background
drawdot (Rand.Int (0, maxx), Rand.Int (0, maxy), 0)
end for
%set declared movement/ loop movement and asteroids
move
end if % B
end loop % A
(O_o)
Posted: Tue Jan 17, 2006 5:32 pm Post subject: (No subject)
phew..
i got that working, thank you bored.
but once again...there is a problem
when ever the bullet hits the asteroid it doesn't disappear right away, and some times it does the opposite; it goes away before it touches it...
here's the code
%button/title/autor/insructions
Font.Draw ("Start", 290, 130,(Font.New ("arial:20:bold,")),white)
Font.Draw ("ASTEROID BLASTER", 125, 325,(Font.New ("arial:30:bold,")),white)
Font.Draw ("TEE- 20O", 5, 385,(Font.New ("arial:10:bold,")),white)
Font.Draw ("Mr.North", 583, 385,(Font.New ("arial:10:bold,")),white)
Font.Draw ("Instructions", 290, 75,(Font.New ("arial:10:bold,")),white)
Font.Draw ("Shoot the asteroids as they come down. Each time you shoot one, the next one comes faster.", 23, 55,(Font.New ("arial:10:bold,")),white)
Font.Draw ("If you let one go past you or if you get hit by one then you lose!", 125, 35,(Font.New ("arial:10:bold,")),white)
View.Update
% declare asteroids
proc asteroid1
if o1 = 0 then
drawoval (b1 , maxy-a(1), 20, 20, 0)
View.Update
drawoval (b1 , maxy-a(1), 20, 20, 255)
a(1):= a(1)+1
if a(1) > 400 then
quit
end if
end if
end asteroid1
proc asteroid2
if o2 = o1 then
drawoval (b2 , maxy-a(2), 20, 20, 0)
View.Update
drawoval (b2 , maxy-a(2), 20, 20, 255)
a(2):= a(2)+1
if a(2) > 400 then
quit
end if
end if
end asteroid2
proc asteroid3
if o3 = o2 then
drawoval (b3 , maxy-a(3), 20, 20, 0)
View.Update
drawoval (b3 , maxy-a(3), 20, 20, 255)
a(3):= a(3)+1
if a(3) > 400 then
quit
end if
end if
end asteroid3
proc asteroid4
if o4 = o3 then
drawoval (b4 , maxy-a(4), 20, 20, 0)
View.Update
drawoval (b4 , maxy-a(4), 20, 20, 255)
a(4):= a(4)+1
if a(4) > 400 then
quit
end if
end if
end asteroid4
proc asteroid5
if o5 = o4 then
drawoval (b5 , maxy-a(5), 20, 20, 0)
View.Update
drawoval (b5 , maxy-a(5), 20, 20, 255)
a(5):= a(5)+1
if a(5) > 400 then
quit
end if
end if
end asteroid5
proc asteroid6
if o6 = o5 then
drawoval (b6 , maxy-a(6), 20, 20, 0)
View.Update
drawoval (b6 , maxy-a(6), 20, 20, 255)
a(6):= a(6)+1
if a(6) > 400 then
quit
end if
end if
end asteroid6
proc asteroid7
if o7 = o6 then
drawoval (b7 , maxy-a(7), 20, 20, 0)
View.Update
drawoval (b7 , maxy-a(7), 20, 20, 255)
a(7):= a(7)+1
if a(7) > 400 then
quit
end if
end if
end asteroid7
proc asteroid8
if o8 = o7 then
drawoval (b8 , maxy-a(8), 20, 20, 0)
View.Update
drawoval (b8 , maxy-a(8), 20, 20, 255)
a(8):= a(8)+1
if a(8) > 400 then
quit
end if
end if
end asteroid8
proc asteroid9
if o9 = o8 then
drawoval (b9 , maxy-a(9), 20, 20, 0)
View.Update
drawoval (b9 , maxy-a(9), 20, 20, 255)
a(9):= a(9)+1
if a(9) > 400 then
quit
end if
end if
end asteroid9
proc asteroid10
if o10 = o9 then
drawoval (b10 , maxy-a(10), 20, 20, 0)
View.Update
drawoval (b10 , maxy-a(10), 20, 20, 255)
a(10):= a(10)+1
if a(10) > 400 then
quit
end if
end if
end asteroid10
%put all in
%declare movement *************************************MOVE***************************88
proc move
loop % C
Input.KeyDown (chars) %set input key down for movement
locate (1, 1)
if chars (KEY_UP_ARROW) then % D
if y2 < maxy then %stop from going off the screen
drawfillbox (x1, y1, x2, y2, 255) %to cover box
y1 += 5 %to move box
y2 += 5
drawfillbox (x1, y1, x2, y2, 0) %box
end if
%down arrow
elsif chars (KEY_DOWN_ARROW) then
if y1 > 0 then %stop from going off the screen
drawfillbox (x1, y1, x2, y2, 255) %to cover box
y1 -= 5 %to move box
y2 -= 5
drawfillbox (x1, y1, x2, y2, 0) %box
end if
%right arrow
elsif chars (KEY_RIGHT_ARROW) then
if x2 < maxx then %stop from going off the screen
drawfillbox (x1, y1, x2, y2, 255) %to cover box
x1 += 5 %to move box
x2 += 5
drawfillbox (x1, y1, x2, y2, 0) %box
end if
%left arrow
elsif chars (KEY_LEFT_ARROW) then
if x1 > 0 then %stop from going off the screen
drawfillbox (x1, y1, x2, y2, 255) %to cover box
x1 -= 5 %to move box
x2 -= 5
drawfillbox (x1, y1, x2, y2, 0) %box
end if
end if % D
%make shooting
if chars (KEY_ENTER) then
shoot:=1
end if
if shoot = 1 then
drawfillbox (sx1, sy1, sx2, sy2, 255) %to cover shot
sy1 += 10 %to move box
sy2 += 10
drawfillbox (sx1, sy1, sx2, sy2, 14) %shot
end if
if sy1> maxy then
shoot := 0
end if
if shoot = 0 then
sx1 := x1+5
sy1 := y1+12
sx2 := x2-5
sy2 := y2+12
end if
delay (25)
asteroid1
%***********************************COLLISIONS***************************************%
%first collision
if b1 > sx1 and b1 < sx2 and a(1) > sy1 and a(1) < sy2 then
o1 := 1
score := score + 1
end if
if o2 = o1 then
asteroid2
end if
%second collision
if b2 > sx1 and b2 < sx2 and a(2) > sy1 and a(2) < sy2 then
o2 := 2
score := score + 2
end if
if o3 = o2 then
asteroid3
end if
%third coll
if b3 > sx1 and b3 < sx2 and a(3) > sy1 and a(3) < sy2 then
o3 := 3
score := score + 3
end if
if o4 = o3 then
asteroid4
end if
%collision 4
if b4 > sx1 and b4 < sx2 and a(4) > sy1 and a(4) < sy2 then
o4 := 4
score := score + 4
end if
if o5 = o4 then
asteroid5
end if
%coll 5
if b5 > sx1 and b5 < sx2 and a(5) > sy1 and a(5) < sy2 then
o5 := 5
score := score + 5
end if
if o6 = o5 then
asteroid6
end if
%coll 6
if b6 > sx1 and b6 < sx2 and a(6) > sy1 and a(6) < sy2 then
o6 := 6
score := score + 6
end if
if o7 = o6 then
asteroid7
end if
%coll 7
if b7 > sx1 and b7 < sx2 and a(7) > sy1 and a(7) < sy2 then
o7 := 7
score := score + 7
end if
if o8 = o7 then
asteroid8
end if
%coll 8
if b8 > sx1 and b8 < sx2 and a(8) > sy1 and a(8) < sy2 then
o8 := 8
score := score + 8
end if
if o9 = o8 then
asteroid9
end if
%coll 9
if b9 > sx1 and b9 < sx2 and a(9) > sy1 and a(9) < sy2 then
o9 := 9
score := score + 9
end if
if o10 = o9 then
asteroid10
end if
%coll 10
if b10 > sx1 and b10 < sx2 and a(10) > sy1 and a(10) < sy2 then
o10 := 10
score := score + 10
end if
if o10 = 10 then
quit
end if
end loop % C
end move
%**************************START PROGRAM*******************
% mouse button
loop % A
mousewhere (x,y,b)
if x>250 and x<400 and y>100 and y<175 and b=1 then % B
delay (5)
cls
View.Update
%background
drawfillbox (0,0,maxx,maxy,black)
for i : 0 .. 250 %stars in background
drawdot (Rand.Int (0, maxx), Rand.Int (0, maxy), 0)
end for
%set declared movement/ loop movement and asteroids
move
end if % B
end loop % A
Sponsor Sponsor
(O_o)
Posted: Tue Jan 17, 2006 5:35 pm Post subject: (No subject)
OPPS
how did that happen
i'm really sorry about that
you can delete the extras if you want
Clayton
Posted: Tue Jan 17, 2006 11:33 pm Post subject: (No subject)
when i tried this program i had a few problems,
1) your collision detection for bullet to asteroid didnt seem to be working at all
2) your collision detection for ship to asteroid didnt seem to be working
3) your Instructions button didnt work, i couldnt figure out how to work it for a while
looks good though a little bit more work and im sure itll look good
um to tidy up the code a bit, put your asteroid variables(the random ones) into an array, just makes it look better(the code) good job so far
(O_o)
Posted: Wed Jan 18, 2006 4:22 pm Post subject: (No subject)
1) the detection worked for me but as i said before when ever the bullet hits the asteroid it doesn't disappear right away, and some times it does the opposite; it goes away before it touches it...
2)i haven't made one yet
3)i plan to tidy when i finish it. and i tried to make it in an array but then they would all be the same random digit.