WE have put movement into the game. We have the oval, that you control, entering a circle. WE want that to initiate a battle. how can we do that?
Program Below
Turing: |
%%%The Army Game%%%
%By: Mike Orr and Jake Klassen%
import GUI
var User_XP : real
var User_CurrentHealth : real
var User_Level : int := 1
var User_NextLevel : real
var WeaponDamage: int
var Weapon : string
var Name : string
var Gender : string
var Specialty : string
var Corps : string
var Regiment : string
GUI.SetBackgroundColour (green)
procedure Start
GUI.Quit
end Start
var b1 := GUI.CreateButton (120, 250, 10, "Start Game", Start )
loop
exit when GUI.ProcessEvent
end loop
cls
put "Its Time To Fight"
put skip
put "Enter your soldier's name. " ..
get Name : *
loop
put "Enter your Gender: " ..
get Gender
exit when Gender= "Male" or Gender = "Female"
end loop
loop
if Gender = "Male" then
put "Choose your specialty from the list below"
put "Engineer"
put "Infantry"
put "Communications"
put "Armoured"
put "Artillery"
put "Medic"
put "Military Police"
put "Airborne"
put "Ammunition Technician"
put "Scottish Infantry"
put " " ..
get Specialty
exit when Specialty= "Engineer" or Specialty = "Infantry" or Specialty = "Communications" or Specialty = "Armoured"
or Specialty = "Artillery" or Specialty = "Medic" or Specialty = "Military Police" or Specialty = "Airborne"
or Specialty = "Ammunition Technician" or Specialty = "Scottish Infantry"
end if
if Gender = "Female" then
put "Choose your specialty from the list below"
put "Communications"
put "Artillery"
put "Medic"
put " " ..
get Specialty
exit when Specialty= "Communications" or Specialty = "Artillery" or Specialty = "Medic"
end if
end loop
cls
loop
put "Choose your Corps. or Division"
put "Marine Corps."
put "Canadian Army"
put "Army Cadet"
put " " ..
get Corps : *
exit when Corps= "Marine Corps." or Corps = "Canadian Army" or Corps = "Army Cadet"
end loop
if Corps = "Canadian Army" then
put "Choose a regiment"
put "The Essex and Kent Scottish"
put "The Lake Superior Highlanders"
put "The Black Watch Royal Highland Regiment of Canada"
put "Princess Patricia's Canadian Light Infantry"
put "Royal Canadian Electrical and Mechanical Engineers"
put "Royal Canadian Field Ambulance"
put "Lord Strathcona's Horse"
put "Royal Canadian Horse Artillery"
put "Canadian Military Police"
put "Canadian Signal Corps."
put "Royal Canadian Regiment"
put " " ..
get Regiment
end if
if Corps = "Marine Corps." then
put "Choose a company."
put "Alpha"
put "Bravo"
put "Charlie"
put "Delta"
put "Echo"
put "Foxtrot"
put "Gulf"
put "Hotel"
put "India"
put "Juliette"
put "Kilo"
put " " ..
get Regiment
end if
if Corps = "Army Cadet" then
put "Choose your corps."
put "59 LHRC(ARMY)CC"
put "1084 Walkerville Legion"
put "CC 04 Blackwatch"
put "#44 Port Perry"
put " " ..
get Regiment
end if
put "Choose your weapon"
put "Colt Canada C7"
put "Colt Canada C6"
put "Colt Canada C8"
put "Colt Canada C9"
put "Armalite M-14"
put "Armalite M-15"
put "Armalite M-16"
put "M1 Carbine"
put "Remmington .22, semi auto"
put "Daisy 853C"
put "Lee Enfield No. 7 Bolt Action, Rim Fire, 22 calibre Rifle"
put " "
get Weapon
cls
if Specialty = "Engineer" then
User_CurrentHealth := 100
User_XP := 0
User_NextLevel := 200
end if
if Specialty = "Infantry" then
User_CurrentHealth := 100
User_XP := 0
User_NextLevel := 1000
end if
if Specialty = "Communications" then
User_CurrentHealth := 100
User_XP := 0
User_NextLevel := 100
end if
if Specialty = "Armoured" then
User_CurrentHealth := 100
User_XP := 0
User_NextLevel := 400
end if
if Specialty = "Artillery" then
User_CurrentHealth := 100
User_XP := 0
User_NextLevel := 500
end if
if Specialty = "Medic" then
User_CurrentHealth := 100
User_XP := 0
User_NextLevel := 700
end if
if Specialty = "Military Police" then
User_CurrentHealth := 100
User_XP := 0
User_NextLevel := 350
end if
if Specialty = "Airborne" then
User_CurrentHealth := 100
User_XP := 0
User_NextLevel := 950
end if
if Specialty = "Ammunition Technician" then
User_CurrentHealth := 100
User_XP := 0
User_NextLevel := 470
end if
if Specialty = "Scottish Infantry" then
User_CurrentHealth := 100
User_XP := 0
User_NextLevel := 1250
end if
put "Soldier's Name: ", Name
put "Gender: ", Gender
put "Regiment", Regiment
View.Set ("graphics:800,600,offscreenonly")
var x1,y1,x2,y2,a,b,xx1,yy1, yy2, xx2: int:= 0
var sd2,sd1,sdd1,sdd2 : int := 0 %shoe dircection
var c,csq: real:= 0
var key : array char of boolean
x1:= 300
y1:= 300
x2:= 150
y2:= 150
sd1 := 15
sd2 := 15 % shoe irection
sdd1 := 10
sdd2 := 10
loop
drawoval(x1,y1, 22, 22, 7)
drawoval(x2,y2, 50, 50, 1)
a:=x2-x1
b:=y2-y1
csq:=a*a+b*b
c:= sqrt(csq )
if 50+ 22>c then
put "collide"
end if
Input.KeyDown (key )
if key (KEY_UP_ARROW) and y1 < maxy then %makes sure the character won't go past the top of the screen
xx1 := x1 + 10
yy1 := y1 + 23
xx2 := x1 - 10
yy2 := y1 + 23
y1 += 1
sd1 := 10
sd2 := 10 % all sd's change direction of shoes
sdd1 := 15
sdd2 := 15
end if
if key (KEY_DOWN_ARROW) and y1 > 0 then
xx1 := x1 + 10
yy1 := y1 - 23
xx2 := x1 - 10
yy2 := y1 - 23
y1 -= 1
sd1 := 10
sd2 := 10 % all sd's change direction of shoes
sdd1 := 15
sdd2 := 15
end if
if key (KEY_LEFT_ARROW) and x1 > 0 then
xx1 := x1 - 22
yy1 := y1 - 8
xx2 := x1 - 22
yy2 := y1 + 12
x1 - = 1
sd1 := 15
sd2 := 15
sdd1 := 10 % sd's change direction of shoes
sdd2 := 10
end if
if key (KEY_RIGHT_ARROW) and x1 < maxx then
xx1 := x1 + 22
xx2: = x1 + 22 % SHOE POSITION IN RELATION TO CIRCLE POSITION
yy1: = y1 + 5
yy2 := y1 - 15
x1 += 1
sd1 := 15
sd2 := 15
sdd1 := 10 % sd's change direction of shoes
sdd2 := 10
end if
drawfilloval(x1,y1, 15, 12, 7) %body
delay (10)
View.Update
cls
end loop |
MOD EDIT: Remember your syntax tags! |