Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Can we get some help with starting a battle
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
MikeJake




PostPosted: Mon Feb 09, 2009 11:24 am   Post subject: Can we get some help with starting a battle

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!
Sponsor
Sponsor
Sponsor
sponsor
SNIPERDUDE




PostPosted: Mon Feb 09, 2009 3:23 pm   Post subject: Re: Can we get some help with starting a battle

code tags please.

[syntax="turing"] code here [/syntax]
DemonWasp




PostPosted: Mon Feb 09, 2009 3:35 pm   Post subject: RE:Can we get some help with starting a battle

What do you mean by "initiate a battle"? If you mean like "we wander around, if we touch an enemy we go to a fight-screen", then you need to have enemy locations (and possibly movement) defined. If you mean "enemies exist in the area and will attack if you come close", that may be more difficult, and requires some form of detection-rules and an attack script (meaning something to tell the enemy what to do when they get close).
MikeJake




PostPosted: Tue Feb 10, 2009 11:08 am   Post subject: Re: Can we get some help with starting a battle

WE mean like, if you come up to an enemy, you have the choice to engage that target, and it can engage you. Con you help with that?
DemonWasp




PostPosted: Tue Feb 10, 2009 11:27 am   Post subject: RE:Can we get some help with starting a battle

I can guide you through the process.

First, you need to determine how you're storing the enemies - their location, type, stats, and so on. You need to think about what stats they will need to partake in combat (attack percentage, attack damage, hp, whatever). You can either store these in associated arrays:

code:
var x : array 1..ENEMIES of int
var y : array 1..ENEMIES of int
var hp : array 1..ENEMIES of int


or you could use the preferred method, which would be records:

code:
type Enemy
  record
    x, y, hp : int
  end record

var enemies : array 1..ENEMIES of Enemy


Once you decide how to store your enemies, we can discuss how to decide whether you encounter them or not.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: