View.Set ("graphics:800,600")
colourback (black)
cls
%-----------------------------------------------------------------------------
%Variables--------------------------------------------------------------------
%-----------------------------------------------------------------------------
%These variables are used for holding the ship's images
var ship_image : int
var ship_image_rot : array 0 .. 180 of int
%These variables are used as the ship's coordinates
var ship_x : int := 700
var ship_y : int := 0
%These variables are used for moving the ship and drawing it on an angle
var ship_move, ship_angle : int := 0
%Holds the ship's health value
var ship_health : int := 100
%These variables are used for holding the 2nd ship's images
var ship2_image : int
var ship2_image_rot : array 0 .. 180 of int
%These variables are used as the ship's coordinates
var ship2_x : int := 0
var ship2_y : int := 0
%These variables are used for moving the ship and drawing it on an angle
var ship2_move, ship2_angle : int := 0
%Holds the 2nd ship's health value
var ship2_health : int := 100
%These variables are used to hold the bullet's images
var bullet_image : int
var bullet_image_rot : array 0 .. 180 of int
%These variables are used as the bullet's coordinates
var bullet_x, bullet_y : int := -1
var bullet_x_last, bullet_y_last, bullet_next_co : int := 1
var bullet_x_current, bullet_y_current : int := 0
%These variables are used as the bullet's angle
var bullet_angle : int := 1
%These variables are used to control the bullet's draw
var bullet_keydown, bullet_fly, bullet_true : int := 0
%These variables are used to hold the bullet's images
var bullet2_image : int
var bullet2_image_rot : array 0 .. 180 of int
%These variables are used as the bullet's coordinates
var bullet2_x, bullet2_y : int := -1
var bullet2_x_last, bullet2_y_last, bullet2_next_co : int := 1
var bullet2_x_current, bullet2_y_current : int := 0
%These variables are used as the bullet's angle
var bullet2_angle : int := 1
%These variables are used to control the bullet's draw
var bullet2_keydown, bullet2_fly, bullet2_true : int := 0
%Explosions
var explosion_image, explosion2_image, explosion3_image, explosion4_image, explosion5_image : int
var explosion_true : int := 0
var explosion2_true : int := 0
var explosion_x : int
var explosion_y : int
var explosion2_x : int
var explosion2_y : int
var explosion_count, explosion2_count : int := 0
%These variables are used for getting keyboard input
var key : array char of boolean
var key2 : array char of boolean
const UP_ARROW : char := chr (200)
const RIGHT_ARROW : char := chr (205)
const LEFT_ARROW : char := chr (203)
const SPACE : char := chr (32)
const W : char := "w"
const A : char := "a"
const D : char := "d"
const KEY_0 : char := "0"
%Used pre-load
var systype : int
var title_image : int
%-----------------------------------------------------------------------------
%Loading----------------------------------------------------------------------
%-----------------------------------------------------------------------------
%This procedure creates the images of the ship
procedure make_ship_images
ship_image := Pic.FileNew ("ship.bmp")
for counter : 0 .. 180
ship_image_rot (counter) := Pic.Rotate (ship_image, counter * 2, 49, 49)
end for
end make_ship_images
%This procedure creates the images of the 2nd ship
procedure make_ship2_images
ship2_image := Pic.FileNew ("ship2.bmp")
for counter : 0 .. 180
ship2_image_rot (counter) := Pic.Rotate (ship2_image, counter * 2, 49, 49)
end for
end make_ship2_images
%This procedure creates the images of the bullet
procedure make_bullet_images
bullet_image := Pic.FileNew ("bullet.bmp")
for counter : 0 .. 180
bullet_image_rot (counter) := Pic.Rotate (bullet_image, counter * 2, 32, 32)
end for
end make_bullet_images
procedure make_explosion
explosion_image := Pic.FileNew ("explosion.bmp")
explosion2_image := Pic.FileNew ("explosion2.bmp")
explosion3_image := Pic.FileNew ("explosion3.bmp")
explosion4_image := Pic.FileNew ("explosion4.bmp")
explosion5_image := Pic.FileNew ("explosion5.bmp")
end make_explosion
%-----------------------------------------------------------------------------
%Draw 1 Frame-----------------------------------------------------------------
%-----------------------------------------------------------------------------
procedure make_frame
Pic.Draw (ship_image_rot (ship_angle), ship_x, ship_y, picMerge)
Pic.Draw (ship2_image_rot (ship2_angle), ship2_x, ship2_y, picMerge)
if bullet_fly = 1 then
Pic.Draw (bullet_image_rot (bullet_angle), bullet_x, bullet_y, picMerge)
end if
if bullet2_fly = 1 then
Pic.Draw (bullet_image_rot (bullet2_angle), bullet2_x, bullet2_y, picMerge)
end if
if explosion_true = 1 then
Pic.Draw (explosion_image, explosion_x, explosion_y, picMerge)
explosion_true := 0
bullet_fly := 0
explosion_count := 5
bullet_x := -128
bullet_y := -128
elsif explosion_count >= 5 and explosion_count <= 5 then
Pic.Draw (explosion_image, explosion_x, explosion_y, picMerge)
explosion_count := explosion_count + 1
elsif explosion_count >= 5 and explosion_count <= 10 then
Pic.Draw (explosion2_image, explosion_x, explosion_y, picMerge)
explosion_count := explosion_count + 1
elsif explosion_count >= 10 and explosion_count <= 15 then
Pic.Draw (explosion3_image, explosion_x, explosion_y, picMerge)
explosion_count := explosion_count + 1
elsif explosion_count >= 15 and explosion_count <= 20 then
Pic.Draw (explosion4_image, explosion_x, explosion_y, picMerge)
explosion_count := explosion_count + 1
elsif explosion_count >= 20 and explosion_count <= 25 then
Pic.Draw (explosion5_image, explosion_x, explosion_y, picMerge)
explosion_count := explosion_count + 1
elsif explosion_count >= 25 then
explosion_count := 0
bullet_true := 0
end if
if explosion2_true = 1 then
Pic.Draw (explosion_image, explosion2_x, explosion2_y, picMerge)
explosion2_true := 0
explosion2_count := 5
bullet2_fly := 0
bullet2_x := -128
bullet2_y := -128
elsif explosion2_count >= 5 and explosion2_count <= 10 then
Pic.Draw (explosion2_image, explosion2_x, explosion2_y, picMerge)
explosion2_count := explosion2_count + 1
elsif explosion2_count >= 10 and explosion2_count <= 15 then
Pic.Draw (explosion3_image, explosion2_x, explosion2_y, picMerge)
explosion2_count := explosion2_count + 1
elsif explosion2_count >= 15 and explosion2_count <= 20 then
Pic.Draw (explosion4_image, explosion2_x, explosion2_y, picMerge)
explosion2_count := explosion2_count + 1
elsif explosion2_count >= 20 and explosion2_count <= 25 then
Pic.Draw (explosion5_image, explosion2_x, explosion2_y, picMerge)
explosion2_count := explosion2_count + 1
elsif explosion2_count >= 25 then
explosion2_count := 0
bullet2_true := 0
end if
put "Ship 1 health - %", ship_health, " " ..
put "Ship 2 health - %", ship2_health ..
bullet_keydown := 0
bullet2_keydown := 0
View.Update
delay (systype)
cls
end make_frame
%-----------------------------------------------------------------------------
%Collision Detection----------------------------------------------------------
%-----------------------------------------------------------------------------
procedure collision_detection
if bullet_x >= ship2_x and bullet_x <= ship2_x + 49 and bullet_y >= ship2_y and bullet_y <= ship2_y + 49 then
explosion_x := bullet_x
explosion_y := bullet_y
explosion_true := 1
ship2_health := ship2_health - 10
end if
if bullet2_x >= ship_x and bullet2_x <= ship_x + 49 and bullet2_y >= ship_y and bullet2_y <= ship_y + 49 then
explosion2_x := bullet2_x
explosion2_y := bullet2_y
explosion2_true := 1
ship_health := ship_health - 10
end if
make_frame
end collision_detection
%-----------------------------------------------------------------------------
%Calculate 2nd Bullets's next coordinates and rotation------------------------
%-----------------------------------------------------------------------------
procedure bullet2_next
if bullet2_fly = 1 then
bullet2_x := bullet2_x + (10 * cosd (bullet2_angle * 2 + 90) div 1)
bullet2_y := bullet2_y + (10 * sind (bullet2_angle * 2 + 90) div 1)
if bullet2_x < -64 or bullet2_x > 864 or bullet2_y < -64 or bullet2_y > 664 then
bullet2_x := -1
bullet2_y := -1
bullet2_fly := 0
bullet2_true := 0
end if
end if
if bullet2_keydown = 1 and bullet2_fly = 0 and bullet2_true = 0 then
bullet2_angle := ship2_angle
bullet2_x := ship2_x + 16
bullet2_y := ship2_y + 16
bullet2_fly := 1
bullet2_true := 1
end if
collision_detection
end bullet2_next
%-----------------------------------------------------------------------------
%Calculate Bullets's next coordinates and rotation----------------------------
%-----------------------------------------------------------------------------
procedure bullet_next
if bullet_fly = 1 then
bullet_x := bullet_x + (10 * cosd (bullet_angle * 2 + 90) div 1)
bullet_y := bullet_y + (10 * sind (bullet_angle * 2 + 90) div 1)
if bullet_x < -64 or bullet_x > 864 or bullet_y < -64 or bullet_y > 664 then
bullet_x := -1
bullet_y := -1
bullet_fly := 0
bullet_true := 0
end if
end if
if bullet_keydown = 1 and bullet_fly = 0 and bullet_true = 0 then
bullet_angle := ship_angle
bullet_x := ship_x + 16
bullet_y := ship_y + 16
bullet_fly := 1
bullet_true := 1
end if
bullet2_next
end bullet_next
%-----------------------------------------------------------------------------
%Calculate 2nd Ship's next coordinates and rotation-------------------------------
%-----------------------------------------------------------------------------
procedure ship2_next
if ship2_move = 1 then
ship2_x := ship2_x + (10 * cosd (ship2_angle * 2 + 90) div 2)
ship2_y := ship2_y + (10 * sind (ship2_angle * 2 + 90) div 2)
ship2_angle := ship2_angle - 1
if ship2_angle <= 0 then
ship2_angle := 180
end if
elsif ship2_move = 2 then
ship2_x := ship2_x + (10 * cosd (ship2_angle * 2 + 90) div 2)
ship2_y := ship2_y + (10 * sind (ship2_angle * 2 + 90) div 2)
ship2_angle := ship2_angle + 1
if ship2_angle = 180 then
ship2_angle := 0
end if
elsif ship2_move = 3 then
ship2_x := ship2_x + (10 * cosd (ship2_angle * 2 + 90) div 2)
ship2_y := ship2_y + (10 * sind (ship2_angle * 2 + 90) div 2)
elsif ship2_move = 4 then
ship2_angle := ship2_angle - 1
if ship2_angle <= 0 then
ship2_angle := 180
end if
elsif ship2_move = 5 then
ship2_angle := ship2_angle + 1
if ship2_angle = 180 then
ship2_angle := 0
end if
end if
if ship2_x > 800 then
ship2_x := -100
elsif ship2_x < -100 then
ship2_x := 800
end if
if ship2_y > 600 then
ship2_y := -100
elsif ship2_y < -100 then
ship2_y := 600
end if
ship2_move := 0
bullet_next
end ship2_next
%-----------------------------------------------------------------------------
%Calculate Ship's next coordinates and rotation-------------------------------
%-----------------------------------------------------------------------------
procedure ship_next
if ship_move = 1 then
ship_x := ship_x + (10 * cosd (ship_angle * 2 + 90) div 2)
ship_y := ship_y + (10 * sind (ship_angle * 2 + 90) div 2)
ship_angle := ship_angle - 1
if ship_angle <= 0 then
ship_angle := 180
end if
elsif ship_move = 2 then
ship_x := ship_x + (10 * cosd (ship_angle * 2 + 90) div 2)
ship_y := ship_y + (10 * sind (ship_angle * 2 + 90) div 2)
ship_angle := ship_angle + 1
if ship_angle = 180 then
ship_angle := 0
end if
elsif ship_move = 3 then
ship_x := ship_x + (10 * cosd (ship_angle * 2 + 90) div 2)
ship_y := ship_y + (10 * sind (ship_angle * 2 + 90) div 2)
elsif ship_move = 4 then
ship_angle := ship_angle - 1
if ship_angle <= 0 then
ship_angle := 180
end if
elsif ship_move = 5 then
ship_angle := ship_angle + 1
if ship_angle = 180 then
ship_angle := 0
end if
end if
if ship_x > 800 then
ship_x := -100
elsif ship_x < -100 then
ship_x := 800
end if
if ship_y > 600 then
ship_y := -100
elsif ship_y < -100 then
ship_y := 600
end if
ship_move := 0
ship2_next
end ship_next
%-----------------------------------------------------------------------------
%Get Keyboard Input ----------------------------------------------------------
%-----------------------------------------------------------------------------
procedure key_input
%Ship 1
loop
Input.KeyDown (key)
if key (UP_ARROW) and key (RIGHT_ARROW) then
ship_move := 1
elsif key (UP_ARROW) and key (LEFT_ARROW) then
ship_move := 2
elsif key (UP_ARROW) then
ship_move := 3
elsif key (RIGHT_ARROW) then
ship_move := 4
elsif key (LEFT_ARROW) then
ship_move := 5
end if
if key (KEY_0) and bullet_fly = 0 then
bullet_keydown := 1
end if
%Ship 2
Input.KeyDown (key2)
if key2 (W) and key2 (D) then
ship2_move := 1
elsif key2(W) and key2 (A) then
ship2_move := 2
elsif key2 (W) then
ship2_move := 3
elsif key2 (D) then
ship2_move := 4
elsif key2 (A) then
ship2_move := 5
end if
if key2 (SPACE) and bullet2_fly = 0 then
bullet2_keydown := 1
end if
ship_next
end loop
end key_input
%-----------------------------------------------------------------------------
%Pre - Load Stuff ----------------------------------------------------------
%-----------------------------------------------------------------------------
title_image := Pic.FileNew ("title.bmp")
loop
Pic.Draw (title_image, 0, 536, picMerge)
colour (white)
locate (6 ,1)
put "What class of system is this running on?"
put ""
put "1. Low - End"
put "2. Mid - Range"
put "3. High - End"
put skip
put ""..
get systype
cls
case systype of
label 1 :
systype := 1
cls
exit
label 2 :
systype := 10
cls
exit
label 3 :
systype := 16
cls
exit
label :
put "Invalid selection."
delay (1000)
cls
end case
end loop
put "Loading..."..
View.Set ("offscreenonly")
View.Update
make_ship_images
make_ship2_images
make_bullet_images
make_explosion
cls
key_input
|