%George Fehr
View.Set ("graphics:800;600,position:0;0,title:Space Invasion")
%***********
%*variables******************************************************************
%***********
%mouse variables
var mx : int := 0
var my : int := 0
var mb : int := 0
var exitFinal : boolean := false
%paddle variables
var x1 : int
var x2 : int
var y1 : int := 5
var y2 : int := 15
%starting position
x1 := 220
x2 := x1 + 100
%enemy
var ex : int := 400
var ey : int := 600
var eSpeed : int
var newEnemy : boolean := false
var hit1 : boolean := false
%bullet variables
var b1X : int
var b1Y : int
var endbullet : boolean := false
var b2X : int
var b2Y : int
var count1 : int
var count2 : int
%colour
var color1 : int := 0
var color2 : int := 1
var color3 : int
var bgcolor : int := 7
%score numbers
var score : int := 0
var hits : int := 0
var lives : int := 10
var ammo : int := 0
%score string values
var scoreS : string := ""
var hitsS : string := ""
var livesS : string := ""
var ammoS : string := ""
var playerName : string
%font variables
var font1 := Font.New ("arial:50")
var font2 := Font.New ("arial:30")
var font3 := Font.New ("arial:20")
%************
%*procedures*************************************************************
%************
procedure intro
Font.Draw ("By:", 300, 300, font1, 1)
Font.Draw ("George", 300, 250, font1, 1)
Font.Draw ("Space Invasion", 200, 400, font1, 1)
delay (500)
Font.Draw ("Get Ready", 200, 150, font1, 1)
delay (1000)
cls
end intro
procedure background
Draw.FillBox (0, 0, 200, 600, 1)
Draw.FillBox (195, 0, 200, 600, 0)
Font.Draw ("Restart", 20, 100, font3, 0)
Font.Draw ("Quit", 20, 60, font3, 0)
Font.Draw ("High Scores", 20, 20, font3, 0)
end background
procedure scoring
Font.Draw ("Score:", 10, 520, font3, 0)
Font.Draw ("Hits:", 10, 450, font3, 0)
Font.Draw ("Lives:", 10, 380, font3, 0)
Font.Draw ("Ammo:", 10, 310, font3, 0)
scoreS := intstr (score)
livesS := intstr (lives)
hitsS := intstr (hits)
ammoS := intstr (ammo)
Draw.FillBox (100, 520, 190, 560, 1)
Font.Draw (scoreS, 100, 520, font3, 0)
Draw.FillBox (75, 450, 190, 500, 1)
Font.Draw (hitsS, 75, 450, font3, 0)
Draw.FillBox (90, 380, 190, 430, 1)
Font.Draw (livesS, 90, 380, font3, 0)
Draw.FillBox (110, 310, 190, 360, 1)
Font.Draw (ammoS, 110, 310, font3, 0)
end scoring
procedure highScore
Font.Draw ("High Scores", 100, 520, font1, 0)
Font.Draw (playerName, 100, 420, font2, 0)
Font.Draw ("Score:", 10, 320, font2, 0)
Font.Draw ("Hits:", 10, 280, font2, 0)
Font.Draw ("Lives:", 10, 240, font2, 0)
Font.Draw ("Ammo:", 10, 200, font2, 0)
Font.Draw (scoreS, 125, 320, font2, 0)
Font.Draw (hitsS, 100, 280, font2, 0)
Font.Draw (livesS, 115, 240, font2, 0)
Font.Draw (ammoS, 140, 200, font2, 0)
end highScore
process fireBullet
endbullet := true
%bullet variables
b1X := x1 + 5
b1Y := 20
count1 := 1
%bullet variables
b2X := x2 - 5
b2Y := 20
count2 := 1
loop
b1Y := count1
b2Y := count2
count1 += 10
count2 += 10
Draw.FillBox (b1X, b1Y, b1X + 5, b1Y + 10, 0)
Draw.FillBox (b2X, b2Y, b2X + 5, b2Y + 10, 0)
delay (15)
Draw.FillBox (b1X, b1Y, b1X + 5, b1Y + 10, 7)
Draw.FillBox (b2X, b2Y, b2X + 5, b2Y + 10, 7)
if whatdotcolor (b1X + 2, b1Y + 11) = 1 or whatdotcolor (b2X + 2,
b2Y + 11) = 1 then
hit1 := true
exit
end if
exit when b2Y >= 580
end loop
if hit1 = true then
score += 100
hits += 1
newEnemy := true
hit1 := false
end if
ammo += 2
endbullet := false
end fireBullet
procedure levelUp
Font.Draw ("LEVEL UP", 400, 200, font1, 1)
delay (500)
Font.Draw ("LEVEL UP", 400, 200, font1, 7)
score += 200
eSpeed += 1
end levelUp
procedure MouseDown
fork fireBullet
end MouseDown
%******
%*main*******************************************************************
%******
put "Enter you name: " ..
get playerName : *
setscreen ("nocursor")
loop
%change background
colorback (bgcolor)
cls
score := 0
hits := 0
lives := 10
ammo := 0
eSpeed := 2
intro
%draw the background
background
delay (500)
%main loop
loop
Draw.FillBox (x1, y1, x2, y2 + 40, bgcolor)
Draw.FillBox (ex, ey, ex + 50, ey + 50, bgcolor) %enemy
Mouse.Where (mx, my, mb)
if mx > 20 and mx < 180 and my > 20 and my < 50 and mb = 1 then
cls
highScore
delay (10000)
exit
elsif mx > 20 and mx < 100 and my > 60 and my < 90 and mb = 1 then
cls
exitFinal := true
exit
elsif mx > 20 and mx < 160 and my > 100 and my < 130 and mb = 1 then
cls
delay (1000)
exit
end if
if mx > 250 then
x1 := mx - 50
x2 := mx + 50
end if
if mx > 250 and mx < 750 and mb = 1 and endbullet = false then
MouseDown
end if
if newEnemy = true then % enemy
ex := Rand.Int (200, 750)
ey := 600
newEnemy := false
end if
ey := ey - eSpeed %enmey
%paddle
Draw.FillBox (x1, y1, x2, y2, color1)
Draw.FillBox (x1 + 5, y1, x1 + 15, y1 + 40, color1)
Draw.FillBox (x2 - 5, y1, x2 - 15, y1 + 40, color1)
Draw.FillBox (ex, ey, ex + 50, ey + 50, 1) %enemy
if ey <= 50 then %enemy
lives -= 1
newEnemy := true
end if
scoring
if lives <= 0 then
cls
exitFinal := true
exit
end if
if score = 500 then
levelUp %4
elsif score = 1500 then
levelUp %6
elsif score = 3000 then
levelUp %8
elsif score = 5000 then
levelUp %10
elsif score = 7500 then
levelUp %12
elsif score = 10000 then
levelUp %14
elsif score = 12500 then
levelUp %16
elsif score = 15000 then
levelUp %18
end if
delay (20)
end loop
exit when exitFinal = true
end loop
highScore
|