Soccer Suggestions
Author |
Message |
yumrum
|
Posted: Thu Jun 04, 2009 6:14 pm Post subject: Soccer Suggestions |
|
|
What is it you are trying to achieve?
Just want suggestions. and how to do aiming with kick when i add the ball
Turing: |
% Soccer time
%Variables
var x, y, x1, y1, x2, y2, x3, y3, x4, x5, x6, x7, y4, y5, y6, y7 : int
var chars : array char of boolean % Movement
var playerwho, playerwho1 : int := 1
% player starting positions
x := 590
y := 300
x1 := 20
y1 := 300
x2 := 200
y2 := 200
x3 := 450
y3 := 450
x4 := 610
y4 := 300
x5 := 750
y5 := 450
x6 := 1000
y6 := 200
x7 := 1180
y7 := 300
%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 Player1move
Input.KeyDown (chars )
% what player controling
if chars ('2') then
playerwho := 2
elsif chars ('1') then
playerwho := 1
elsif chars ('3') then
playerwho := 3
elsif chars ('4') then
playerwho := 4
end if
% Striker
if playerwho = 1 then
Input.KeyDown (chars ) % Value for key
if chars (KEY_UP_ARROW) then
y := y + 5
end if
if chars (KEY_RIGHT_ARROW) then
x := x + 5
end if
if chars (KEY_LEFT_ARROW) then
x := x - 5
end if
if chars (KEY_DOWN_ARROW) then
y := y - 5
end if
% Goalie
elsif playerwho = 2 then
if chars (KEY_UP_ARROW) then
y1 := y1 + 5
end if
if chars (KEY_RIGHT_ARROW) then
x1 := x1 + 5
end if
if chars (KEY_LEFT_ARROW) then
x1 := x1 - 5
end if
if chars (KEY_DOWN_ARROW) then
y1 := y1 - 5
end if
% Sweeper
elsif playerwho = 3 then
if chars (KEY_UP_ARROW) then
y2 := y2 + 5
end if
if chars (KEY_RIGHT_ARROW) then
x2 := x2 + 5
end if
if chars (KEY_LEFT_ARROW) then
x2 := x2 - 5
end if
if chars (KEY_DOWN_ARROW) then
y2 := y2 - 5
end if
% Stopper
elsif playerwho = 4 then
if chars (KEY_UP_ARROW) then
y3 := y3 + 5
end if
if chars (KEY_RIGHT_ARROW) then
x3 := x3 + 5
end if
if chars (KEY_LEFT_ARROW) then
x3 := x3 - 5
end if
if chars (KEY_DOWN_ARROW) then
y3 := y3 - 5
end if
end if
end Player1move
procedure Player2move
Input.KeyDown (chars )
% what player controling
if chars ('7') then
playerwho1 := 1
elsif chars ('8') then
playerwho1 := 2
elsif chars ('9') then
playerwho1 := 3
elsif chars ('0') then
playerwho1 := 4
end if
% Striker
if playerwho1 = 1 then
Input.KeyDown (chars ) % Value for key
if chars ('w') then
y4 := y4 + 5
end if
if chars ('d') then
x4 := x4 + 5
end if
if chars ('a') then
x4 := x4 - 5
end if
if chars ('s') then
y4 := y4 - 5
end if
% Goalie
elsif playerwho1 = 4 then
if chars ('w') then
y7 := y7 + 5
end if
if chars ('d') then
x7 := x7 + 5
end if
if chars ('a') then
x7 := x7 - 5
end if
if chars ('s') then
y7 := y7 - 5
end if
% Sweeper
elsif playerwho1 = 2 then
if chars ('w') then
y5 := y5 + 5
end if
if chars ('d') then
x5 := x5 + 5
end if
if chars ('a') then
x5 := x5 - 5
end if
if chars ('s') then
y5 := y5 - 5
end if
% Stopper
elsif playerwho1 = 3 then
if chars ('w') then
y6 := y6 + 5
end if
if chars ('d') then
x6 := x6 + 5
end if
if chars ('a') then
x6 := x6 - 5
end if
if chars ('s') then
y6 := y6 - 5
end if
end if
end Player2move
% Background
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)
% Boxs
% 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
procedure sides
%Striker 1
if x > 1200 then
x := 1195
end if
if x < 0 then
x := 5
end if
if y > 600 then
y := 595
end if
if y < 0 then
y := 5
end if
% Sweeper 3
if x2 > 1200 then
x2 := 1195
end if
if x2 < 0 then
x2 := 5
end if
if y2 > 600 then
y2 := 595
end if
if y2 < 0 then
y2 := 5
end if
% Stopper 4
if x3 > 1200 then
x3 := 1195
end if
if x3 < 0 then
x3 := 5
end if
if y3 > 600 then
y3 := 595
end if
if y3 < 0 then
y3 := 5
end if
% Second team
%Striker 2
if x4 > 1200 then
x4 := 1195
end if
if x4 < 0 then
x4 := 5
end if
if y4 > 600 then
y4 := 595
end if
if y4 < 0 then
y4 := 5
end if
% Sweeper 3
if x5 > 1200 then
x5 := 1195
end if
if x5 < 0 then
x5 := 5
end if
if y5 > 600 then
y5 := 595
end if
if y5 < 0 then
y5 := 5
end if
% Stopper 4
if x6 > 1200 then
x6 := 1195
end if
if x6 < 0 then
x6 := 5
end if
if y6 > 600 then
y6 := 595
end if
if y6 < 0 then
y6 := 5
end if
end sides
procedure goaliebounderys
% so goalie's can''t leave box
if x1 > 200 then
x1 := 197
end if
if x1 < 0 then
x1 := 5
end if
if y1 > 453 then
y1 := 450
end if
if y1 < 150 then
y1 := 151
end if
% so goalie 2 can't leave box
if x7 < 1003 then
x7 := 1000
end if
if x7 > 1200 then
x7 := 1195
end if
if y7 > 453 then
y7 := 450
end if
if y7 < 150 then
y7 := 151
end if
end goaliebounderys
procedure drawpeople
% 1 striker
Draw.FillOval (x, y, 10, 10, brightred)
Draw.Text ("1", x - 4, y - 4, font3, black)
% Goalie
Draw.FillOval (x1, y1, 10, 10, yellow)
Draw.Text ("2", x1 - 4, y1 - 4, font3, black)
% 3 Sweeper
Draw.FillOval (x2, y2, 10, 10, brightred)
Draw.Text ("3", x2 - 4, y2 - 4, font3, black)
% 4 Stopper
Draw.FillOval (x3, y3, 10, 10, brightred)
Draw.Text ("4", x3 - 4, y3 - 4, font3, black)
% 7 striker
Draw.FillOval (x4, y4, 10, 10, brightblue)
Draw.Text ("7", x4 - 4, y4 - 4, font3, black)
% 0 Goalie
Draw.FillOval (x7, y7, 10, 10, 13)
Draw.Text ("0", x7 - 4, y7 - 4, font3, black)
% 8 Sweeper
Draw.FillOval (x5, y5, 10, 10, brightblue)
Draw.Text ("8", x5 - 4, y5 - 4, font3, black)
% 9 Stopper
Draw.FillOval (x6, y6, 10, 10, brightblue)
Draw.Text ("9", x6 - 4, y6 - 4, font3, black)
end drawpeople
% My Game Starts
% Setting Screen size
setscreen ("graphics:1200;680,offscreenonly")
loop
cls
background
Player1move
Player2move
sides
goaliebounderys
drawpeople
View.Update
delay (15)
end loop
|
Please specify what version of Turing you are using
4.1 |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
yumrum
|
Posted: Thu Jun 04, 2009 7:14 pm Post subject: Re: Soccer Suggestions |
|
|
Alright so now i really need help.
run the program and watch what happends to the soccer ball if u try to move it in all dircetions i don't know how to fix it tried a bunch
Turing: |
% Soccer time
%Variables
var x, y, x1, y1, x2, y2, x3, y3, x4, x5, x6, x7, y4, y5, y6, y7, x8, y8 : int
var chars : array char of boolean % Movement
var playerwho, playerwho1 : int := 1
% player starting positions
x := 560
y := 300
x1 := 20
y1 := 300
x2 := 200
y2 := 200
x3 := 450
y3 := 450
x4 := 640
y4 := 300
x5 := 750
y5 := 450
x6 := 1000
y6 := 200
x7 := 1180
y7 := 300
x8 := 600
y8 := 300
%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 Player1move
Input.KeyDown (chars )
% what player controling
if chars ('2') then
playerwho := 2
elsif chars ('1') then
playerwho := 1
elsif chars ('3') then
playerwho := 3
elsif chars ('4') then
playerwho := 4
end if
% Striker
if playerwho = 1 then
Input.KeyDown (chars ) % Value for key
if chars (KEY_UP_ARROW) then
y := y + 5
end if
if chars (KEY_RIGHT_ARROW) then
x := x + 5
end if
if chars (KEY_LEFT_ARROW) then
x := x - 5
end if
if chars (KEY_DOWN_ARROW) then
y := y - 5
end if
% Goalie
elsif playerwho = 2 then
if chars (KEY_UP_ARROW) then
y1 := y1 + 5
end if
if chars (KEY_RIGHT_ARROW) then
x1 := x1 + 5
end if
if chars (KEY_LEFT_ARROW) then
x1 := x1 - 5
end if
if chars (KEY_DOWN_ARROW) then
y1 := y1 - 5
end if
% Sweeper
elsif playerwho = 3 then
if chars (KEY_UP_ARROW) then
y2 := y2 + 5
end if
if chars (KEY_RIGHT_ARROW) then
x2 := x2 + 5
end if
if chars (KEY_LEFT_ARROW) then
x2 := x2 - 5
end if
if chars (KEY_DOWN_ARROW) then
y2 := y2 - 5
end if
% Stopper
elsif playerwho = 4 then
if chars (KEY_UP_ARROW) then
y3 := y3 + 5
end if
if chars (KEY_RIGHT_ARROW) then
x3 := x3 + 5
end if
if chars (KEY_LEFT_ARROW) then
x3 := x3 - 5
end if
if chars (KEY_DOWN_ARROW) then
y3 := y3 - 5
end if
end if
end Player1move
procedure Player2move
Input.KeyDown (chars )
% what player controling
if chars ('7') then
playerwho1 := 1
elsif chars ('8') then
playerwho1 := 2
elsif chars ('9') then
playerwho1 := 3
elsif chars ('0') then
playerwho1 := 4
end if
% Striker
if playerwho1 = 1 then
Input.KeyDown (chars ) % Value for key
if chars ('w') then
y4 := y4 + 5
end if
if chars ('d') then
x4 := x4 + 5
end if
if chars ('a') then
x4 := x4 - 5
end if
if chars ('s') then
y4 := y4 - 5
end if
% Goalie
elsif playerwho1 = 4 then
if chars ('w') then
y7 := y7 + 5
end if
if chars ('d') then
x7 := x7 + 5
end if
if chars ('a') then
x7 := x7 - 5
end if
if chars ('s') then
y7 := y7 - 5
end if
% Sweeper
elsif playerwho1 = 2 then
if chars ('w') then
y5 := y5 + 5
end if
if chars ('d') then
x5 := x5 + 5
end if
if chars ('a') then
x5 := x5 - 5
end if
if chars ('s') then
y5 := y5 - 5
end if
% Stopper
elsif playerwho1 = 3 then
if chars ('w') then
y6 := y6 + 5
end if
if chars ('d') then
x6 := x6 + 5
end if
if chars ('a') then
x6 := x6 - 5
end if
if chars ('s') then
y6 := y6 - 5
end if
end if
end Player2move
% Background
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)
% Boxs
% 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
procedure sides
%Striker 1
if x > 1200 then
x := 1195
end if
if x < 0 then
x := 5
end if
if y > 600 then
y := 595
end if
if y < 0 then
y := 5
end if
% Sweeper 3
if x2 > 1200 then
x2 := 1195
end if
if x2 < 0 then
x2 := 5
end if
if y2 > 600 then
y2 := 595
end if
if y2 < 0 then
y2 := 5
end if
% Stopper 4
if x3 > 1200 then
x3 := 1195
end if
if x3 < 0 then
x3 := 5
end if
if y3 > 600 then
y3 := 595
end if
if y3 < 0 then
y3 := 5
end if
% Second team
%Striker 2
if x4 > 1200 then
x4 := 1195
end if
if x4 < 0 then
x4 := 5
end if
if y4 > 600 then
y4 := 595
end if
if y4 < 0 then
y4 := 5
end if
% Sweeper 3
if x5 > 1200 then
x5 := 1195
end if
if x5 < 0 then
x5 := 5
end if
if y5 > 600 then
y5 := 595
end if
if y5 < 0 then
y5 := 5
end if
% Stopper 4
if x6 > 1200 then
x6 := 1195
end if
if x6 < 0 then
x6 := 5
end if
if y6 > 600 then
y6 := 595
end if
if y6 < 0 then
y6 := 5
end if
end sides
procedure goaliebounderys
% so goalie's can''t leave box
if x1 > 200 then
x1 := 197
end if
if x1 < 0 then
x1 := 5
end if
if y1 > 453 then
y1 := 450
end if
if y1 < 150 then
y1 := 151
end if
% so goalie 2 can't leave box
if x7 < 1003 then
x7 := 1000
end if
if x7 > 1200 then
x7 := 1195
end if
if y7 > 453 then
y7 := 450
end if
if y7 < 150 then
y7 := 151
end if
end goaliebounderys
procedure drawpeople
% 1 striker
Draw.FillOval (x, y, 10, 10, brightred)
Draw.Text ("1", x - 4, y - 4, font3, black)
% Goalie
Draw.FillOval (x1, y1, 10, 10, yellow)
Draw.Text ("2", x1 - 4, y1 - 4, font3, black)
% 3 Sweeper
Draw.FillOval (x2, y2, 10, 10, brightred)
Draw.Text ("3", x2 - 4, y2 - 4, font3, black)
% 4 Stopper
Draw.FillOval (x3, y3, 10, 10, brightred)
Draw.Text ("4", x3 - 4, y3 - 4, font3, black)
% 7 striker
Draw.FillOval (x4, y4, 10, 10, brightblue)
Draw.Text ("7", x4 - 4, y4 - 4, font3, black)
% 0 Goalie
Draw.FillOval (x7, y7, 10, 10, 13)
Draw.Text ("0", x7 - 4, y7 - 4, font3, black)
% 8 Sweeper
Draw.FillOval (x5, y5, 10, 10, brightblue)
Draw.Text ("8", x5 - 4, y5 - 4, font3, black)
% 9 Stopper
Draw.FillOval (x6, y6, 10, 10, brightblue)
Draw.Text ("9", x6 - 4, y6 - 4, font3, black)
%Soccerball
Draw.FillOval (x8, y8, 7, 7, black)
Draw.FillOval (x8, y8, 3, 3, white)
end drawpeople
procedure ballcollision
%collision with the ball
% left and right
if x < x8 + 20 and x > x8 + 14 then
x8 := x8 - 5
elsif x < x8 - 14 and x > x8 - 20 then
x8 := x8 + 5
end if
% up and down
if y < y8 + 20 and y > y8 + 14 then
y8 := y8 - 5
elsif y4 < y8 - 14 and y > y8 - 20 then
y8 := y8 + 5
end if
% left and right
if x4 < x8 + 20 and x4 > x8 + 14 then
x8 := x8 - 5
elsif x4 < x8 - 14 and x4 > x8 - 20 then
x8 := x8 + 5
end if
% up and down
if y4 < y8 + 20 and y4 > y8 + 14 then
y8 := y8 - 5
elsif y4 < y8 - 14 and y4 > y8 - 20 then
y8 := y8 + 5
end if
end ballcollision
% My Game Starts
% Setting Screen size
setscreen ("graphics:1200;680,offscreenonly")
loop
cls
background
Player1move
Player2move
sides
ballcollision
goaliebounderys
drawpeople
View.Update
delay (15)
end loop
|
|
|
|
|
|
![](images/spacer.gif) |
yumrum
|
Posted: Thu Jun 04, 2009 8:42 pm Post subject: RE:Soccer Suggestions |
|
|
Anyone Know what's screwed up with the ball would be most appreiciated |
|
|
|
|
![](images/spacer.gif) |
Nai
![](http://compsci.ca/v3/uploads/user_avatars/20439034944c71c3e5cfe26.gif)
|
Posted: Tue Jun 16, 2009 5:34 pm Post subject: Re: Soccer Suggestions |
|
|
First, you really should use some better variable names for your x and y's. It is very hard to figure out what each means. Second, it looks like you aren't really checking if the ball collides with the player, but rather if the player's x coordinate is above or below the x coordinate of the ball (same with the y's). You need to make sure that the player is actually hitting the ball (by checking if the both x and y coordinates at the same time). Try to think of there being a box around the ball, and if the player's x AND y coordinates are inside the box, then move it. |
|
|
|
|
![](images/spacer.gif) |
|
|