Computer Science Canada

Space Invaders

Author:  Azzy [ Sat May 21, 2005 12:09 pm ]
Post subject:  Space Invaders

I'm trying to make a Space Invaders game but I got a problem. If I use a procedure for the gun, everytime you shoot your ship thing disappears and then reapears after the shot is gone. If I use a process, the ball goes flying up extremely fast and then begins to slow down. Can someone please help me solve this problem so I can continue on?

code:
var x := 320
var gunx : int
var guny := 30
var chars : array char of boolean

process gun
    loop
        Draw.FillOval (gunx, guny, 5, 5, black)
        delay (10)
        Draw.FillOval (gunx, guny, 5, 5, white)
        guny := guny + 1
        exit when guny = 480
    end loop
    guny := 30
end gun

loop
    Input.KeyDown (chars)
    Draw.FillOval (x, 30, 10, 10, red)
    delay (5)
    Draw.FillOval (x, 30, 10, 10, white)
    if chars (KEY_LEFT_ARROW) then
        x := x - 1
        if x <= 10 then
            x := x + 1
        end if
    elsif chars (KEY_RIGHT_ARROW) then
        x := x + 1
        if x >= 625 then
            x := x - 1
        end if
    elsif chars (KEY_CTRL) then
        gunx := x
        fork gun
    end if
end loop

Author:  MysticVegeta [ Sat May 21, 2005 12:21 pm ]
Post subject: 

There are around 50 topics regarding shooting. Also, use View.Update and dont use the processes, they screw your CPU up and have bugs.[/code]

Author:  Neo [ Sat May 21, 2005 1:43 pm ]
Post subject: 

Dont use processes. Make ur shoot procedure use the main loop and keep track of it with a counter.


: