Soccer Game Shot out help
Author |
Message |
yumrum
|
Posted: Sun Dec 20, 2009 8:00 pm Post subject: Soccer Game Shot out help |
|
|
What is it you are trying to achieve?
I'm trying to fix in shootout mode so that when it first starts ur controling the people on the left not the right
to get to shootout mode at start up type 5 (enter) 5 (enter) 1(enter) 5(enter)
only the third number is important the other 3 can be anynumber
What is the problem you are having?
the ball is on the one side and the people that are controlable at the time are on the other
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing: |
% Soccer time
% Made By Yumyum
% lots of help from Diablo and Tony
%Variables
var timer, timer1 : int := 0 % timer
var move1 : int := 5 % Speed of player 1- can be used as a handicap
var move2 : int := 5 % Speed of player 2- can be used as a handicap
var chars : array char of boolean % Movement
var ChangeofPlayer1 : int := 1 % changing player
var ChangeofPlayer2 : int := 5 % changing player
var radius : int := 10 % Collision stuff
var collision : array 1 .. 9 of boolean % Collision stuff
var method : string
var x : array 1 .. 9 of int % For all player's and Ball
var y : array 1 .. 9 of int % For all Player's and Ball
var score1, score2 : int := 0 % scores
var countergo : int := 0 % counter for goal
var stickyoff : int := 0 % solves run threw problem
var passp1 : int := 0
var passp2 : int := 0
var p1colour : int := 12
var p2colour : int := 9
var ifshootout : int := 3
var whichside : int := 1
%FONTS
var font1, font2, font3, font4 : int
font1 := Font.New ("sans serif:18:bold")
font2 := Font.New ("sans serif:36:bold")
font3 := Font.New ("mono:12")
font4 := Font.New ("Palatino:40:Bold,Italic")
% ANY PROCEDURES
procedure Resetposition
% player starting positions
x (1) := 560
y (1) := 300
x (2) := 20
y (2) := 300
x (3) := 200
y (3) := 200
x (4) := 450
y (4) := 450
x (5) := 640
y (5) := 300
x (6) := 750
y (6) := 450
x (7) := 1000
y (7) := 200
x (8) := 1180
y (8) := 300
x (9) := 600
y (9) := 300
end Resetposition
Resetposition
procedure Playermove
Input.KeyDown (chars )
% Who player1 controling
if chars ('0') then
ChangeofPlayer1 := 2
elsif chars ('7') then
ChangeofPlayer1 := 1
elsif chars ('8') then
ChangeofPlayer1 := 3
elsif chars ('9') then
ChangeofPlayer1 := 4
end if
%Moving all the characters
Input.KeyDown (chars ) % Value for key
if chars (KEY_UP_ARROW) then
y (ChangeofPlayer1 ) := y (ChangeofPlayer1 ) + move1
end if
if chars (KEY_RIGHT_ARROW) then
x (ChangeofPlayer1 ) := x (ChangeofPlayer1 ) + move1
end if
if chars (KEY_LEFT_ARROW) then
x (ChangeofPlayer1 ) := x (ChangeofPlayer1 ) - move1
end if
if chars (KEY_DOWN_ARROW) then
y (ChangeofPlayer1 ) := y (ChangeofPlayer1 ) - move1
end if
% Who PLayer2 Controling
if chars ('1') then
ChangeofPlayer2 := 5
elsif chars ('3') then
ChangeofPlayer2 := 7
elsif chars ('4') then
ChangeofPlayer2 := 8
elsif chars ('2') then
ChangeofPlayer2 := 6
end if
% Player 2 movement
if chars ('w') then
y (ChangeofPlayer2 ) := y (ChangeofPlayer2 ) + move2
end if
if chars ('d') then
x (ChangeofPlayer2 ) := x (ChangeofPlayer2 ) + move2
end if
if chars ('a') then
x (ChangeofPlayer2 ) := x (ChangeofPlayer2 ) - move2
end if
if chars ('s') then
y (ChangeofPlayer2 ) := y (ChangeofPlayer2 ) - move2
end if
end Playermove
procedure background
% feild and line wall
Draw.FillBox (1200, 680, 0, 0, green)
Draw.FillBox (1190, 590, 10, 10, white)
Draw.FillBox (1187, 587, 13, 13, green)
% circle & middle line
Draw.FillOval (600, 300, 100, 100, white)
Draw.FillOval (600, 300, 97, 97, green)
Draw.FillBox (599, 10, 601, 590, white)
% Goals
Draw.FillBox (0, 240, 13, 360, black)
Draw.FillBox (1187, 240, 1200, 360, black)
% outside box
Draw.FillBox (10, 450, 200, 453, white)
Draw.FillBox (10, 150, 200, 147, white)
Draw.FillBox (1190, 150, 1000, 147, white)
Draw.FillBox (1190, 450, 1000, 453, white)
Draw.FillBox (197, 150, 200, 450, white)
Draw.FillBox (1000, 150, 1003, 450, white)
%inner box
Draw.FillBox (10, 190, 70, 193, white)
Draw.FillBox (10, 410, 70, 413, white)
Draw.FillBox (67, 193, 70, 410, white)
Draw.FillBox (1190, 190, 1120, 193, white)
Draw.FillBox (1190, 410, 1120, 413, white)
Draw.FillBox (1120, 193, 1123, 410, white)
end background
function Collided1 () : boolean
if Math.Distance (x (ChangeofPlayer1 ), y (ChangeofPlayer1 ), x (9), y (9)) < radius * 1. 5 then
result true
else
result false
end if
end Collided1
function Collided2 () : boolean
if Math.Distance (x (ChangeofPlayer2 ), y (ChangeofPlayer2 ), x (9), y (9)) < radius * 1. 5 then
result true
else
result false
end if
end Collided2
procedure sides
for t : 1 .. 8
if x (t ) > 1200 then
x (t ) := 1195
end if
if x (t ) < 0 then
x (t ) := 5
end if
if y (t ) > 600 then
y (t ) := 595
end if
if y (t ) < 0 then
y (t ) := 5
end if
end for
end sides
procedure goaliebounderys
% so goalie's can''t leave box
if x (2) > 200 then
x (2) := 197
end if
if x (2) < 0 then
x (2) := 5
end if
if y (2) > 453 then
y (2) := 450
end if
if y (2) < 150 then
y (2) := 151
end if
% so goalie 2 can't leave box
if x (8) < 1003 then
x (8) := 1000
end if
if x (8) > 1200 then
x (8) := 1195
end if
if y (8) > 453 then
y (8) := 450
end if
if y (8) < 150 then
y (8) := 151
end if
end goaliebounderys
procedure drawpeople
% 7 striker
Draw.FillOval (x (1), y (1), 10, 10, p1colour )
Draw.Text ("7", x (1) - 4, y (1) - 4, font3, black)
% Goalie
Draw.FillOval (x (2), y (2), 10, 10, yellow)
Draw.Text ("0", x (2) - 4, y (2) - 4, font3, black)
% 8 Sweeper
Draw.FillOval (x (3), y (3), 10, 10, p1colour )
Draw.Text ("8", x (3) - 4, y (3) - 4, font3, black)
% 9 Stopper
Draw.FillOval (x (4), y (4), 10, 10, p1colour )
Draw.Text ("9", x (4) - 4, y (4) - 4, font3, black)
% 1 striker
Draw.FillOval (x (5), y (5), 10, 10, p2colour )
Draw.Text ("1", x (5) - 4, y (5) - 4, font3, black)
% 4 Goalie
Draw.FillOval (x (8), y (8), 10, 10, 13)
Draw.Text ("4", x (8) - 4, y (8) - 4, font3, black)
% 2 Sweeper
Draw.FillOval (x (6), y (6), 10, 10, p2colour )
Draw.Text ("2", x (6) - 4, y (6) - 4, font3, black)
% 3 Stopper
Draw.FillOval (x (7), y (7), 10, 10, p2colour )
Draw.Text ("3", x (7) - 4, y (7) - 4, font3, black)
%Soccerball
Draw.FillOval (x (9), y (9), 7, 7, black)
Draw.FillOval (x (9), y (9), 3, 3, white)
end drawpeople
procedure keepscore
Draw.Text (intstr (score1 ), 50, 600, font4, black)
Draw.Text (intstr (score2 ), 1120, 600, font4, black)
end keepscore
procedure countdownrefresh
View.Update
delay (1000)
cls
end countdownrefresh
procedure countdown
%Counting down
Draw.Text ("Ready", 240, 200, font4, black)
countdownrefresh
for z : 1 .. 3
Draw.Text (intstr (z ), 240, 200, font4, black)
countdownrefresh
end for
% Setting Screen size
setscreen ("graphics:1200;680,offscreenonly")
background
Resetposition
drawpeople
Draw.Text ("GO", 590, 330, font4, black)
View.Update
delay (500)
countergo := 0
end countdown
procedure Goal
% Goal against team two
if x (9) > 1190 and y (9) < 360 and y (9) > 240 then
cls
% Setting Screen size
setscreen ("graphics:500;400,offscreenonly")
put " PLAYER ONE GOAL GOAL GOAL"
score1 := score1 + 1
countergo := 1
elsif x (9) < 10 and y (9) < 360 and y (9) > 240 then
cls
% Setting Screen size
setscreen ("graphics:500;400,offscreenonly")
put " PLAYER TWO GOAL GOAL GOAL"
score2 := score2 + 1
countergo := 1
end if
if countergo = 1 then
countdown
end if
end Goal
procedure Ballbounderys
% Ball against side
if x (9) > 1200 then
x (9) := 1195
end if
if x (9) < 0 then
x (9) := 5
end if
if y (9) > 600 then
y (9) := 595
end if
if y (9) < 0 then
y (9) := 5
end if
end Ballbounderys
proc Sticky2 ()
if chars ('s') then
y (9) - = 5
elsif chars ('w') then
y (9) + = 5
elsif chars ('a') then
x (9) - = 5
elsif chars ('d') then
x (9) + = 5
end if
end Sticky2
proc Sticky ()
if chars (KEY_DOWN_ARROW) then
y (9) - = 5
elsif chars (KEY_UP_ARROW) then
y (9) + = 5
elsif chars (KEY_LEFT_ARROW) then
x (9) - = 5
elsif chars (KEY_RIGHT_ARROW) then
x (9) + = 5
end if
end Sticky
proc passkick
if Math.Distance (x (ChangeofPlayer1 ), y (ChangeofPlayer1 ), x (9), y (9)) < radius * 1. 5 + 5 then
if chars (',') then
y (9) + = 150
elsif chars ('.') then
y (9) - = 150
elsif chars ('/') then
x (9) + = 160
end if
end if
if Math.Distance (x (ChangeofPlayer2 ), y (ChangeofPlayer2 ), x (9), y (9)) < radius * 1. 5 + 5 then
if chars ('q') then
y (9) + = 150
elsif chars ('e') then
y (9) - = 150
elsif chars ('r') then
x (9) - = 160
end if
end if
end passkick
proc collisions ()
for i : 5 .. 8
for m : 5 .. 8
if x (9) <= x (m ) + 50 and x (9) >= x (m ) - 50 and y (9) <= y (m ) + 50 and y (9) >= y (m ) - 50 then
else
collision (i ) := Collided1 ()
if collision (i ) = true then
Sticky
end if
end if
end for
end for
for i : 1 .. 4
for m : 1 .. 4
if x (9) <= x (m ) + 50 and x (9) >= x (m ) - 50 and y (9) <= y (m ) + 50 and y (9) >= y (m ) - 50 then
else
collision (i ) := Collided2 ()
if collision (i ) = true then
Sticky2
end if
end if
end for
end for
end collisions
proc background2
setscreen ("graphics:800;600,offscreenonly")
Draw.FillBox (801, 601, 0, 0, black)
Draw.Text ("Super", 350, 550, font4, yellow)
Draw.Text ("Soccer", 338, 500, font4, yellow)
end background2
proc startup
background2
Draw.Text ("Enter Player 1 Movement (norm 5)", 20, 400, font3, yellow)
View.Update
get move1
cls
background2
Draw.Text ("Enter Player 2 Movement (norm 5)", 20, 350, font3, yellow)
View.Update
get move2
cls
background2
Draw.Text ("Just shootout mode? (1 yes 0 no)", 20, 300, font3, yellow)
View.Update
get ifshootout
cls
background2
Draw.Text ("Enter Time Limit (mins)", 20, 250, font3, yellow)
View.Update
get timer
timer := timer * 100000
% Setting Screen size
setscreen ("graphics:1200;680,offscreenonly")
countdown
end startup
proc drawpeopleshootout
% 7 striker
Draw.FillOval (x (1), y (1), 10, 10, p1colour )
Draw.Text ("7", x (1) - 4, y (1) - 4, font3, black)
% Goalie
Draw.FillOval (x (2), y (2), 10, 10, yellow)
Draw.Text ("0", x (2) - 4, y (2) - 4, font3, black)
% 1 striker
Draw.FillOval (x (5), y (5), 10, 10, p2colour )
Draw.Text ("1", x (5) - 4, y (5) - 4, font3, black)
% 4 Goalie
Draw.FillOval (x (8), y (8), 10, 10, 13)
Draw.Text ("4", x (8) - 4, y (8) - 4, font3, black)
%Soccerball
Draw.FillOval (x (9), y (9), 7, 7, black)
Draw.FillOval (x (9), y (9), 3, 3, white)
end drawpeopleshootout
proc Playermoveshootout1
ChangeofPlayer1 := 2
ChangeofPlayer2 := 5
%Moving all the characters
Input.KeyDown (chars ) % Value for key
if chars (KEY_UP_ARROW) then
y (ChangeofPlayer1 ) := y (ChangeofPlayer1 ) + move1
end if
if chars (KEY_RIGHT_ARROW) then
x (ChangeofPlayer1 ) := x (ChangeofPlayer1 ) + move1
end if
if chars (KEY_LEFT_ARROW) then
x (ChangeofPlayer1 ) := x (ChangeofPlayer1 ) - move1
end if
if chars (KEY_DOWN_ARROW) then
y (ChangeofPlayer1 ) := y (ChangeofPlayer1 ) - move1
end if
% Player 2 movement
if chars ('w') then
y (ChangeofPlayer2 ) := y (ChangeofPlayer2 ) + move2
end if
if chars ('d') then
x (ChangeofPlayer2 ) := x (ChangeofPlayer2 ) + move2
end if
if chars ('a') then
x (ChangeofPlayer2 ) := x (ChangeofPlayer2 ) - move2
end if
if chars ('s') then
y (ChangeofPlayer2 ) := y (ChangeofPlayer2 ) - move2
end if
end Playermoveshootout1
proc reset
x (2) := 15
y (2) := 300
x (5) := 195
y (5) := 300
x (1) := 1005
y (1) := 300
x (8) := 1950
y (8) := 300
end reset
proc Goalshootout
% Goal against team two
if x (9) > 1190 and y (9) < 360 and y (9) > 240 then
cls
score1 := score1 + 1
whichside := 1
reset
x (9) := 180
y (9) := 300
elsif x (9) < 10 and y (9) < 360 and y (9) > 240 then
cls
score2 := score2 + 1
whichside := 2
reset
x (9) := 1025
y (9) := 300
end if
end Goalshootout
proc Playermoveshootout2
ChangeofPlayer1 := 1
ChangeofPlayer2 := 8
%Moving all the characters
Input.KeyDown (chars ) % Value for key
if chars (KEY_UP_ARROW) then
y (ChangeofPlayer1 ) := y (ChangeofPlayer1 ) + move1
end if
if chars (KEY_RIGHT_ARROW) then
x (ChangeofPlayer1 ) := x (ChangeofPlayer1 ) + move1
end if
if chars (KEY_LEFT_ARROW) then
x (ChangeofPlayer1 ) := x (ChangeofPlayer1 ) - move1
end if
if chars (KEY_DOWN_ARROW) then
y (ChangeofPlayer1 ) := y (ChangeofPlayer1 ) - move1
end if
% Player 2 movement
if chars ('w') then
y (ChangeofPlayer2 ) := y (ChangeofPlayer2 ) + move2
end if
if chars ('d') then
x (ChangeofPlayer2 ) := x (ChangeofPlayer2 ) + move2
end if
if chars ('a') then
x (ChangeofPlayer2 ) := x (ChangeofPlayer2 ) - move2
end if
if chars ('s') then
y (ChangeofPlayer2 ) := y (ChangeofPlayer2 ) - move2
end if
end Playermoveshootout2
proc sidesshootout
%leftside
if x (2) > 200 then
x (2) := 195
end if
if x (2) < 10 then
x (2) := 15
end if
if y (2) > 450 then
y (2) := 445
end if
if y (2) < 150 then
y (2) := 155
end if
if x (5) > 200 then
x (5) := 195
end if
if x (5) < 10 then
x (5) := 15
end if
if y (5) > 450 then
y (5) := 445
end if
if y (5) < 150 then
y (5) := 155
end if
%right side
if x (1) > 1200 then
x (1) := 1195
end if
if x (1) < 1000 then
x (1) := 1005
end if
if y (1) > 450 then
y (1) := 445
end if
if y (1) < 150 then
y (1) := 155
end if
if x (8) > 1200 then
x (8) := 1195
end if
if x (8) < 1000 then
x (8) := 1005
end if
if y (8) > 450 then
y (8) := 445
end if
if y (8) < 150 then
y (8) := 155
end if
end sidesshootout
proc goaliewins1
if x (9) < 1002 or y (9) > 452 or y (9) < 152 then
whichside := 2
end if
end goaliewins1
proc goaliewins2
if x (9) > 202 or y (9) > 452 or y (9) < 152 then
whichside := 1
end if
end goaliewins2
proc shootout
score1 := 0
score2 := 0
x (9) := 180
y (9) := 300
loop
if whichside = 1 then
cls
background
Playermoveshootout1
sidesshootout
collisions
goaliebounderys
Ballbounderys
drawpeopleshootout
Goalshootout
keepscore
goaliewins1
View.Update
delay (20)
elsif whichside = 2 then
cls
background
Playermoveshootout2
sidesshootout
collisions
goaliebounderys
Ballbounderys
drawpeopleshootout
Goalshootout
keepscore
goaliewins2
if score1 = score2 + 1 then
cls
put "TEAM 1 WINS"
delay (1000)
exit
end if
if score2 = score1 + 1 then
cls
put "TEAM 2 WINS"
delay (1000)
exit
end if
View.Update
delay (20)
end if
end loop
end shootout
% My Game Starts
loop
startup
loop
loop
if ifshootout = 1 then
exit
end if
cls
background
Playermove
sides
collisions
passkick
goaliebounderys
Ballbounderys
drawpeople
keepscore
Goal
timer1 := Time.Elapsed
if timer <= timer1 then
exit
end if
View.Update
delay (20)
end loop
shootout
exit
end loop
end loop
|
Please specify what version of Turing you are using
<Answer Here> |
|
|
|
|
|
Sponsor Sponsor
|
|
|
yumrum
|
Posted: Sun Dec 20, 2009 8:22 pm Post subject: RE:Soccer Game Shot out help |
|
|
Sorry forgot to Mention all the Code for Shootout starts from the bottom up (all the top is for the actual game) |
|
|
|
|
|
yumrum
|
Posted: Sun Dec 20, 2009 8:54 pm Post subject: RE:Soccer Game Shot out help |
|
|
Never Mind i got it fixed |
|
|
|
|
|
|
|