View.Set ("graphics: 500, 600, offscreenonly")
colorback (black)
cls
%Draws the spaceship
Draw.Line (1, 1, 26, 52, white)
Draw.Line (52, 1, 26, 52, white)
Draw.Line (1, 1, 52, 1, white)
Draw.Fill (26, 2, white, white)
var spaceship : int := Pic.New (0, 0, 52, 52)
Pic.SetTransparentColor (spaceship, black)
cls
var shot : int := 0
const SHIP_SPEED := 2
const BULLET_SPEED := 3
%Spaceship
var x : int := 330
var y : int := 0
var chars : array char of boolean
%Laser
var bullet_x : int
var bullet_y : int
var bullet_y2 : int
var chars2 : array char of boolean
forward procedure movement
procedure shoot
loop
shot := 1
bullet_y += BULLET_SPEED
bullet_y2 += BULLET_SPEED
exit when bullet_y > 700
movement
end loop
shot := 0
end shoot
body procedure movement
Input.KeyDown (chars)
Input.KeyDown (chars2)
%Spaceship Movement
if chars (KEY_RIGHT_ARROW) and x <= 445 then
x += SHIP_SPEED
end if
if chars (KEY_LEFT_ARROW) and x >= 1 then
x -= SHIP_SPEED
end if
if chars (KEY_UP_ARROW) and y <= 545 then
y += SHIP_SPEED
end if
if chars (KEY_DOWN_ARROW) and y >= 1 then
y -= SHIP_SPEED
end if
if chars2 (' ') and shot = 0 then
bullet_x := x
bullet_y := y
bullet_y2 := y + 20
shoot
end if
if shot = 1 then
Draw.ThickLine (bullet_x + 26, bullet_y + 55, bullet_x + 26, bullet_y2 + 55, 5, brightred)
end if
Pic.Draw (spaceship, x, y, picMerge)
View.Update
delay (1)
cls
end movement
loop
movement
end loop
|