Computer Science Canada

more than one movement at the same time

Author:  (O_o) [ Fri Jan 13, 2006 5:31 pm ]
Post subject:  more than one movement at the same time

hi
i'm trying to make a game where i have a box and i can move it with the arrow keys, and also want to move circles across the screen at the same time. when ever i try to do it, only the circles move. I was wonder if someone could explain to me how to do both at the same time.

Author:  (O_o) [ Fri Jan 13, 2006 5:42 pm ]
Post subject: 

sorry for the double post but if you don't want to download the program here it is

code:

%declare variables and screen
setscreen("graphics : 400;400")


%set variables for moving and ship
    var chars : array char of boolean
    var x1, y1, x2, y2 : int

%ship variables
    x1 := 308
    y1 := 195
    x2 := 349
    y2 := 206

%set vars for shooting
    var sx1, sy1, sx2, sy2, shoot : int

    shoot:= 0
    sx1 := x1+5
    sy1 := y1+12
    sx2 := x2-5
    sy2 := y2+12
   
%set variables for asteroids
var a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 :int := 0

var b1, b2, b3, b4, b5, b6, b7, b8, b9, b10 :int
b1:= Rand.Int(0,maxx)
b2:= Rand.Int(0,maxx)
b3:= Rand.Int(0,maxx)
b4:= Rand.Int(0,maxx)
b5:= Rand.Int(0,maxx)
b6:= Rand.Int(0,maxx)
b7:= Rand.Int(0,maxx)
b8:= Rand.Int(0,maxx)
b9:= Rand.Int(0,maxx)
b10:= Rand.Int(0,maxx)
   
%var for intro button   
    var x,y,b : int

%background, for intro
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

%draw button
drawbox (250, 100, 400, 175, 0)

%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)

% 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

%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
 
%draw ship   
    drawfillbox (x1, y1, x2, y2, 0)

%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
            delay (0)
        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
            delay (0)
        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
            delay (0)
        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
            delay (0)
        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 (50) 

    loop
        drawoval (b1 , maxy-a1, 20, 20, 0)
        delay (18)
        drawoval (b1 , maxy-a1, 20, 20, 255)
        a1:= a1+1
    exit when a1 = 400
    end loop

    delay (1000)   
       
    loop
        if a1 > 200 then
        drawoval (b2 , maxy-a2, 20, 20, 0)
        delay (16)
        drawoval (b2 , maxy-a2, 20, 20, 255)
        a2:= a2+1
        end if
    exit when a2 = 400
    end loop

    delay (1000)
   
    loop
        if a2 > 200 then
        drawoval (b3 , maxy-a3, 20, 20, 0)
        delay (14)
        drawoval (b3 , maxy-a3, 20, 20, 255)
        a3:= a3+1
        exit when a3 = 400
        end if
    end loop

    delay (1000)   
       
    loop
        if a3 > 200 then
        drawoval (b4 , maxy-a4, 20, 20, 0)
        delay (12)
        drawoval (b4 , maxy-a4, 20, 20, 255)
        a4:= a4+1
        end if
    exit when a4 = 400
    end loop
   
    delay (1000)   
       
    loop
        if a4 > 200 then
        drawoval (b5 , maxy-a5, 20, 20, 0)
        delay (10)
        drawoval (b5 , maxy-a5, 20, 20, 255)
        a5:= a5+1
        end if
    exit when a5 = 400
    end loop
   
    delay (1000)

    loop
        if a5 > 200 then
        drawoval (b6 , maxy-a6, 20, 20, 0)
        delay (8)
        drawoval (b6 , maxy-a6, 20, 20, 255)
        a6:= a6+1
    exit when a6 = 400
    end if
    end loop

    delay (1000)   
       
    loop
        if a6 > 200 then
        drawoval (b7 , maxy-a7, 20, 20, 0)
        delay (6)
        drawoval (b7 , maxy-a7, 20, 20, 255)
        a7:= a7+1
        end if
    exit when a7 = 400
    end loop

    delay (1000)
   
    loop
        if a7 > 200 then
        drawoval (b8 , maxy-a8, 20, 20, 0)
        delay (4)
        drawoval (b8 , maxy-a8, 20, 20, 255)
        a8:= a8+1
        exit when a8 = 400
        end if
    end loop

    delay (1000)   
       
    loop
        if a8 > 200 then
        drawoval (b9 , maxy-a9, 20, 20, 0)
        delay (2)
        drawoval (b9 , maxy-a9, 20, 20, 255)
        a9:= a9+1
        end if
    exit when a9 = 400
    end loop
   
    delay (1000)   
       
    loop
        if a9 > 200 then
        drawoval (b10 , maxy-a10, 20, 20, 0)
        delay (0)
        drawoval (b10 , maxy-a10, 20, 20, 255)
        a10:= a10+1
        end if
    exit when a10 = 400
    end loop

end loop                                                % C

end if                                                  % B

end loop                                                % A

Author:  iker [ Fri Jan 13, 2006 5:58 pm ]
Post subject: 

instead of having all of the directions in one if statement..
code:

if key (KEY_LEFT_ARROW) then
left
elsif key (KEY_RIGHT_ARROW) then
right
elsif key (KEY_UP_ARROW) then
up
elsif key (KEY_DOWN_ARROW) then
down
end if

try puting them in separate if statements, opposite directions such as up and down can be in the same one..
code:

if key (KEY_UP_ARROW) then
up
elsif key (KEY_DOWN_ARROW) then
down
end if

if key (KEY_LEFT_ARROW) then
left
elsif key (KEY_RIGHT_ARROW) then
right
end if

hope that helps

Author:  (O_o) [ Fri Jan 13, 2006 6:26 pm ]
Post subject: 

thanks for the tip
i treid it but it didn't work
i can move the ship until add the asteroids, then it i cant move it anymore.

so if i take out this part:
code:

loop
        drawoval (b1 , maxy-a1, 20, 20, 0)
        delay (18)
        drawoval (b1 , maxy-a1, 20, 20, 255)
        a1:= a1+1
    exit when a1 = 400
    end loop

    delay (1000)   
       
    loop
        if a1 > 200 then
        drawoval (b2 , maxy-a2, 20, 20, 0)
        delay (16)
        drawoval (b2 , maxy-a2, 20, 20, 255)
        a2:= a2+1
        end if
    exit when a2 = 400
    end loop

    delay (1000)
   
    loop
        if a2 > 200 then
        drawoval (b3 , maxy-a3, 20, 20, 0)
        delay (14)
        drawoval (b3 , maxy-a3, 20, 20, 255)
        a3:= a3+1
        exit when a3 = 400
        end if
    end loop

    delay (1000)   
       
    loop
        if a3 > 200 then
        drawoval (b4 , maxy-a4, 20, 20, 0)
        delay (12)
        drawoval (b4 , maxy-a4, 20, 20, 255)
        a4:= a4+1
        end if
    exit when a4 = 400
    end loop
   
    delay (1000)   
       
    loop
        if a4 > 200 then
        drawoval (b5 , maxy-a5, 20, 20, 0)
        delay (10)
        drawoval (b5 , maxy-a5, 20, 20, 255)
        a5:= a5+1
        end if
    exit when a5 = 400
    end loop
   
    delay (1000)

    loop
        if a5 > 200 then
        drawoval (b6 , maxy-a6, 20, 20, 0)
        delay (8)
        drawoval (b6 , maxy-a6, 20, 20, 255)
        a6:= a6+1
    exit when a6 = 400
    end if
    end loop

    delay (1000)   
       
    loop
        if a6 > 200 then
        drawoval (b7 , maxy-a7, 20, 20, 0)
        delay (6)
        drawoval (b7 , maxy-a7, 20, 20, 255)
        a7:= a7+1
        end if
    exit when a7 = 400
    end loop

    delay (1000)
   
    loop
        if a7 > 200 then
        drawoval (b8 , maxy-a8, 20, 20, 0)
        delay (4)
        drawoval (b8 , maxy-a8, 20, 20, 255)
        a8:= a8+1
        exit when a8 = 400
        end if
    end loop

    delay (1000)   
       
    loop
        if a8 > 200 then
        drawoval (b9 , maxy-a9, 20, 20, 0)
        delay (2)
        drawoval (b9 , maxy-a9, 20, 20, 255)
        a9:= a9+1
        end if
    exit when a9 = 400
    end loop
   
    delay (1000)   
       
    loop
        if a9 > 200 then
        drawoval (b10 , maxy-a10, 20, 20, 0)
        delay (0)
        drawoval (b10 , maxy-a10, 20, 20, 255)
        a10:= a10+1
        end if
    exit when a10 = 400
    end loop


and try to move it works
so i only can't move when this part comes in

Author:  Tony [ Fri Jan 13, 2006 7:08 pm ]
Post subject: 

that is because you have a bunch of loops with delays in them. It takes quite a while for those loops to finish, and you're not checking for any input while inside the loops.

no input -- no movement

Author:  (O_o) [ Fri Jan 13, 2006 7:44 pm ]
Post subject: 

oooo
i get what you mean
so you're saying that i need to get the program to check for inputs while the asteroids fall.
hmmm
how would i do that though?

Author:  Tony [ Fri Jan 13, 2006 8:31 pm ]
Post subject: 

step procedures

code:

loop
   check input
   you move 1 step
   asteroid moves 1 step
end loop


currently you have your loops set up so that an asteroid would move from beginning to end before letting go of the controls. Try to figure out how to let the asteroid move just 1 step, let go of the controls, and resume from where it left of next time Wink

Author:  (O_o) [ Fri Jan 13, 2006 8:46 pm ]
Post subject: 

i'm not sure of what you saying....
what do you mean by letting go of the controls?
do you mean that i should get the program to check for inputs constantly before each move of the asteroid?

Author:  Tony [ Fri Jan 13, 2006 9:14 pm ]
Post subject: 

(O_o) wrote:
do you mean that i should get the program to check for inputs constantly before each move of the asteroid?

not only check, but also process and move the user accordingly

Author:  (O_o) [ Fri Jan 13, 2006 9:30 pm ]
Post subject: 

so do you mean somthing like this?
code:

    loop
   
    if chars (KEY_UP_ARROW) then               
        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

        drawoval (b1 , maxy-a1, 20, 20, 0)
        delay (18)
        drawoval (b1 , maxy-a1, 20, 20, 255)
        a1:= a1+1
    exit when a1 = 400
    end loop

Author:  Tony [ Fri Jan 13, 2006 9:50 pm ]
Post subject: 

not quite

your asteroid will not move unless UP_ARROW is pressed Razz

try to separate everything into procedures

Author:  (O_o) [ Sat Jan 14, 2006 12:03 pm ]
Post subject: 

example?

Author:  iker [ Sat Jan 14, 2006 3:12 pm ]
Post subject: 

heres an example
code:

proc asteroidmove
    asteroidy -= asteroid speed
end asteroidmove

proc detectcollision
    if asteroidy = paddley and asteroidx = paddlex then
        %boom
    end if
end detectcollision

proc paddlemove
    if key (KEY_UP_ARROW) then
        up
    elsif key (KEY_DOWN_ARROW) then
        down
    end if

    if key (KEY_LEFT_ARROW) then
        left
    elsif key (KEY_RIGHT_ARROW) then
        right
    end if
end paddlemove

loop
    paddlemove
    asteroidmove
    detectcollison
end loop

Author:  (O_o) [ Sun Jan 15, 2006 11:41 am ]
Post subject: 

wow..
it worked!
thanks alot!
but, there were two problems.....

one being that as the asteroids come down they flash...but i'm not sure if that's fixable...

two that the collision wouldn't work. the bulletjust goes through the asteriod...

Author:  Cervantes [ Sun Jan 15, 2006 11:56 am ]
Post subject: 

Use View.Update.
http://www.compsci.ca/v2/viewtopic.php?t=3077
http://www.compsci.ca/v2/viewtopic.php?t=193

Author:  (O_o) [ Sun Jan 15, 2006 10:33 pm ]
Post subject: 

wow, thanks Cervantes
but i still can't get the asteroid to disappear after it gets shot.

so far i have this thanks to you guys
code:

%declare variables and screen
View.Set ("offscreenonly")


%set variables for moving and ship
    var chars : array char of boolean
    var x1, y1, x2, y2 : int

%ship variables
    x1 := 308
    y1 := 195
    x2 := 349
    y2 := 206

%set vars for shooting
    var sx1, sy1, sx2, sy2, shoot : int

    shoot:= 0
    sx1 := x1+5
    sy1 := y1+12
    sx2 := x2-5
    sy2 := y2+12
   
%set variables for asteroids
var a1, a2, a3, a4, a5, a6, a7, a8, a9, a10 :int := 0


var b1, b2, b3, b4, b5, b6, b7, b8, b9, b10 :int
b1:= Rand.Int(0,maxx)
b2:= Rand.Int(0,maxx)
b3:= Rand.Int(0,maxx)
b4:= Rand.Int(0,maxx)
b5:= Rand.Int(0,maxx)
b6:= Rand.Int(0,maxx)
b7:= Rand.Int(0,maxx)
b8:= Rand.Int(0,maxx)
b9:= Rand.Int(0,maxx)
b10:= Rand.Int(0,maxx)
   
%var for intro button   
    var x,y,b : int
View.Update

%background, for intro
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
View.Update

%draw button
drawbox (250, 100, 400, 175, 0)
View.Update

%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
 
%draw ship   
    drawfillbox (x1, y1, x2, y2, 0)
View.Update

%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)

%asteroids
        drawoval (b1 , maxy-a1, 20, 20, 0)       
        View.Update
        delay (18)
        drawoval (b1 , maxy-a1, 20, 20, 255)
        a1:= a1+1

        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.

Author:  Martin [ Sun Jan 15, 2006 10:50 pm ]
Post 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!

http://www.compsci.ca/v2/viewtopic.php?t=1117
http://www.compsci.ca/v2/viewtopic.php?t=366

Author:  Bored [ Mon Jan 16, 2006 4:13 pm ]
Post 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.

Author:  codemage [ Tue Jan 17, 2006 1:13 pm ]
Post subject: 

ha**censored**? Wink
Or... perhaps "has_hit"?
Or "ateroid_alive", for a better naming convention. Smile

Author:  (O_o) [ Tue Jan 17, 2006 5:29 pm ]
Post 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

code:

%**************************DECLARATIONS**************
%declare screen
View.Set ("offscreenonly")

%set variables for moving and ship
var chars : array char of boolean    %parallel get

const nothing:= 120
const up:=56
const down:=88
const right:=248
const left:=104
const button:=112

%variables for ship
var x1, y1, x2, y2 : int %position for ship

    x1 := 330
    y1 := 195
    x2 := 371
    y2 := 206

%set vars for shooting
var sx1, sy1, sx2, sy2, shoot : int

    shoot:= 0
    sx1 := x1+5
    sy1 := y1+12
    sx2 := x2-5
    sy2 := y2+12
   
%set variables for asteroids
var a : array 1..10 of int  %y of asteroids

for i : 1..10
    a (i) := 0
end for

var o1, o2, o3, o4, o5, o6, o7, o8, o9, o10 :int    %number asteroid
    o1 := 0
    o2 := 1
    o3 := 2
    o4 := 3
    o5 := 4
    o6 := 5
    o7 := 6
    o8 := 7
    o9 := 8
    o10 := 9

var b1, b2, b3, b4, b5, b6, b7, b8, b9, b10 :int    %x of asteroid
    b1:= Rand.Int(0,maxx)
    b2:= Rand.Int(0,maxx)
    b3:= Rand.Int(0,maxx)
    b4:= Rand.Int(0,maxx)
    b5:= Rand.Int(0,maxx)
    b6:= Rand.Int(0,maxx)
    b7:= Rand.Int(0,maxx)
    b8:= Rand.Int(0,maxx)
    b9:= Rand.Int(0,maxx)
    b10:= Rand.Int(0,maxx)
   
%var for intro button   
var x,y,b : int
 
%var for score and c for credits
var score :int := 0
var c:int := 0
%background, for intro
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
View.Update

%draw button
drawbox (250, 100, 400, 175, 0)
View.Update

%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
 
%draw ship   
        drawfillbox (x1, y1, x2, y2, 0)
        View.Update

%set declared movement/ loop movement and asteroids
        move
    end if                                                  % B
end loop                                                    % A

Author:  (O_o) [ Tue Jan 17, 2006 5:30 pm ]
Post 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

code:

%**************************DECLARATIONS**************
%declare screen
View.Set ("offscreenonly")

%set variables for moving and ship
var chars : array char of boolean    %parallel get

const nothing:= 120
const up:=56
const down:=88
const right:=248
const left:=104
const button:=112

%variables for ship
var x1, y1, x2, y2 : int %position for ship

    x1 := 330
    y1 := 195
    x2 := 371
    y2 := 206

%set vars for shooting
var sx1, sy1, sx2, sy2, shoot : int

    shoot:= 0
    sx1 := x1+5
    sy1 := y1+12
    sx2 := x2-5
    sy2 := y2+12
   
%set variables for asteroids
var a : array 1..10 of int  %y of asteroids

for i : 1..10
    a (i) := 0
end for

var o1, o2, o3, o4, o5, o6, o7, o8, o9, o10 :int    %number asteroid
    o1 := 0
    o2 := 1
    o3 := 2
    o4 := 3
    o5 := 4
    o6 := 5
    o7 := 6
    o8 := 7
    o9 := 8
    o10 := 9

var b1, b2, b3, b4, b5, b6, b7, b8, b9, b10 :int    %x of asteroid
    b1:= Rand.Int(0,maxx)
    b2:= Rand.Int(0,maxx)
    b3:= Rand.Int(0,maxx)
    b4:= Rand.Int(0,maxx)
    b5:= Rand.Int(0,maxx)
    b6:= Rand.Int(0,maxx)
    b7:= Rand.Int(0,maxx)
    b8:= Rand.Int(0,maxx)
    b9:= Rand.Int(0,maxx)
    b10:= Rand.Int(0,maxx)
   
%var for intro button   
var x,y,b : int
 
%var for score and c for credits
var score :int := 0
var c:int := 0
%background, for intro
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
View.Update

%draw button
drawbox (250, 100, 400, 175, 0)
View.Update

%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
 
%draw ship   
        drawfillbox (x1, y1, x2, y2, 0)
        View.Update

%set declared movement/ loop movement and asteroids
        move
    end if                                                  % B
end loop                                                    % A

Author:  (O_o) [ Tue Jan 17, 2006 5:31 pm ]
Post 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

code:

%**************************DECLARATIONS**************
%declare screen
View.Set ("offscreenonly")

%set variables for moving and ship
var chars : array char of boolean   

const nothing:= 120
const up:=56
const down:=88
const right:=248
const left:=104
const button:=112

%variables for ship
var x1, y1, x2, y2 : int %position for ship

    x1 := 330
    y1 := 195
    x2 := 371
    y2 := 206

%set vars for shooting
var sx1, sy1, sx2, sy2, shoot : int

    shoot:= 0
    sx1 := x1+5
    sy1 := y1+12
    sx2 := x2-5
    sy2 := y2+12
   
%set variables for asteroids
var a : array 1..10 of int  %y of asteroids

for i : 1..10
    a (i) := 0
end for

var o1, o2, o3, o4, o5, o6, o7, o8, o9, o10 :int    %number asteroid
    o1 := 0
    o2 := 1
    o3 := 2
    o4 := 3
    o5 := 4
    o6 := 5
    o7 := 6
    o8 := 7
    o9 := 8
    o10 := 9

var b1, b2, b3, b4, b5, b6, b7, b8, b9, b10 :int    %x of asteroid
    b1:= Rand.Int(0,maxx)
    b2:= Rand.Int(0,maxx)
    b3:= Rand.Int(0,maxx)
    b4:= Rand.Int(0,maxx)
    b5:= Rand.Int(0,maxx)
    b6:= Rand.Int(0,maxx)
    b7:= Rand.Int(0,maxx)
    b8:= Rand.Int(0,maxx)
    b9:= Rand.Int(0,maxx)
    b10:= Rand.Int(0,maxx)
   
%var for intro button   
var x,y,b : int
 
%var for score and c for credits
var score :int := 0
var c:int := 0
%background, for intro
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
View.Update

%draw button
drawbox (250, 100, 400, 175, 0)
View.Update

%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
 
%draw ship   
        drawfillbox (x1, y1, x2, y2, 0)
        View.Update

%set declared movement/ loop movement and asteroids
        move
    end if                                                  % B
end loop                                                    % A

Author:  (O_o) [ Tue Jan 17, 2006 5:32 pm ]
Post 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

code:

%**************************DECLARATIONS**************
%declare screen
View.Set ("offscreenonly")

%set variables for moving and ship
var chars : array char of boolean    %parallel get

const nothing:= 120
const up:=56
const down:=88
const right:=248
const left:=104
const button:=112

%variables for ship
var x1, y1, x2, y2 : int %position for ship

    x1 := 330
    y1 := 195
    x2 := 371
    y2 := 206

%set vars for shooting
var sx1, sy1, sx2, sy2, shoot : int

    shoot:= 0
    sx1 := x1+5
    sy1 := y1+12
    sx2 := x2-5
    sy2 := y2+12
   
%set variables for asteroids
var a : array 1..10 of int  %y of asteroids

for i : 1..10
    a (i) := 0
end for

var o1, o2, o3, o4, o5, o6, o7, o8, o9, o10 :int    %number asteroid
    o1 := 0
    o2 := 1
    o3 := 2
    o4 := 3
    o5 := 4
    o6 := 5
    o7 := 6
    o8 := 7
    o9 := 8
    o10 := 9

var b1, b2, b3, b4, b5, b6, b7, b8, b9, b10 :int    %x of asteroid
    b1:= Rand.Int(0,maxx)
    b2:= Rand.Int(0,maxx)
    b3:= Rand.Int(0,maxx)
    b4:= Rand.Int(0,maxx)
    b5:= Rand.Int(0,maxx)
    b6:= Rand.Int(0,maxx)
    b7:= Rand.Int(0,maxx)
    b8:= Rand.Int(0,maxx)
    b9:= Rand.Int(0,maxx)
    b10:= Rand.Int(0,maxx)
   
%var for intro button   
var x,y,b : int
 
%var for score and c for credits
var score :int := 0
var c:int := 0
%background, for intro
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
View.Update

%draw button
drawbox (250, 100, 400, 175, 0)
View.Update

%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
 
%draw ship   
        drawfillbox (x1, y1, x2, y2, 0)
        View.Update

%set declared movement/ loop movement and asteroids
        move
    end if                                                  % B
end loop                                                    % A

Author:  (O_o) [ Tue Jan 17, 2006 5:35 pm ]
Post subject: 

OPPS
how did that happen
i'm really sorry about that
you can delete the extras if you want

Author:  Clayton [ Tue Jan 17, 2006 11:33 pm ]
Post 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

Author:  (O_o) [ Wed Jan 18, 2006 4:22 pm ]
Post 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.

thanks for the comments


: