Turing Space shooter game
Author |
Message |
Will910
|
Posted: Wed Jun 16, 2010 4:58 pm Post subject: Turing Space shooter game |
|
|
What is it you are trying to achieve?
What is the problem you are having?
Describe what you have tried to solve this problem
<Ive tried if statements including a boolean variable and nothing seems to work.>
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>
Turing: |
<var x, y, button, buttonupdown, font1, font2, font3, font4, WinID : int
var lives, points, xcan, num, yball, xball, lvl, xcyc, ycyc, dist : int := 0
var code : string
var key : string (1)
var fired : boolean := false
var xc1, xc2, xc3, xc4, xc5, xc6, xc7, xc8, xc9, xc10 : int
var yc1, yc2, yc3, yc4, yc5, yc6, yc7, yc8, yc9, yc10 : int
drawfill (1, 1, 255, 1)
font1 := Font.New ("chiller:32:underline,bold")
font2 := Font.New ("Arial black:24")
font3 := Font.New ("TremorITC TT:32:underline,bold")
font4 := Font.New ("BankGothic Lt BT:32:bold")
Font.Draw ("Beware of the Cyclops", 180, 200, font1, 12)
play ("<ADGEDGDEGDE1>A>")
cls
xcan := 260
xball := xcan
loop
%Title Screen
drawfill (1, 1, 255, 1)
color (14)
colorback (255)
drawbox (200, 370, 440, 320, 12) %start game button
Font.Draw ("Start", 270, 335, font2, 14)
drawbox (200, 230, 440, 180, 12) %Instructions button
Font.Draw ("Instructions", 215, 195, font2, 14)
drawbox (200, 100, 440, 50, 12) %Exit button
Font.Draw ("Exit", 275, 65, font2, 14)
%left cyclops on title screen
drawfilloval (100, 200, 25, 25, 4)
drawfilloval (100, 210, 7, 7, 1)
drawfillarc (100, 190, 15, 10, 180, 0, 0)
drawfillarc (100, 188, 12, 7, 180, 0, 255)
%right cyclops on title screen
drawfilloval (530, 200, 25, 25, 4)
drawfilloval (530, 210, 7, 7, 1)
drawfillarc (530, 190, 15, 10, 180, 0, 0)
drawfillarc (530, 188, 12, 7, 180, 0, 255)
View.Set ("offscreenonly")
buttonwait ("down", x, y, button, buttonupdown )
if x > 200 and x < 440 and y > 320 and y < 370 then
View.Update
cls
exit
end if
end loop
loop
randint (xc1, 10, 610)
randint (xc2, 10, 610)
randint (xc3, 10, 610)
randint (xc4, 10, 610)
randint (xc5, 10, 610)
randint (xc6, 10, 610)
randint (xc7, 10, 610)
randint (xc8, 10, 610)
randint (xc9, 10, 610)
randint (xc10, 10, 610)
yc1 := 450
yc2 := 450
yc3 := 450
yc4 := 450
yc5 := 450
yc6 := 450
yc7 := 450
yc8 := 450
yc9 := 450
yc10 := 450
drawfillbox (xcan, 1, xcan + 60, 30, 8)
drawfillbox (xcan + 30, 30, xcan + 50, 80, 8)
drawfillarc (xcan + 40, 80, 10, 5, 180, 0, 255)
drawfilloval (xc1, yc1, 10, 10, 12)
drawfilloval (xc1, yc1 + 2, 3, 3, 255)
drawarc (xc1, yc1 - 5, 4, 3, 180, 0, 14)
drawfilloval (xc2, yc2, 10, 10, 12)
drawfilloval (xc2, yc2 + 2, 3, 3, 255)
drawarc (xc2, yc2 - 5, 4, 3, 180, 0, 14)
drawfilloval (xc3, yc3, 10, 10, 12)
drawfilloval (xc3, yc3 + 2, 3, 3, 255)
drawarc (xc3, yc3 - 2, 4, 3, 180, 0, 14)
delay (100)
View.Update
drawfillbox (xcan, 1, xcan + 60, 30, 255)
drawfillbox (xcan + 30, 30, xcan + 50, 80, 255)
drawfillarc (xcan + 40, 80, 10, 5, 180, 0, 255)
drawfilloval (xc1, yc1, 10, 10, 255)
drawfilloval (xc1, yc1 + 2, 3, 3, 255)
drawarc (xc1, yc1 - 2, 4, 3, 180, 0, 255)
drawfilloval (xc2, yc2, 10, 10, 255)
drawfilloval (xc2, yc2 + 2, 3, 3, 255)
drawarc (xc2, yc2 - 2, 4, 3, 180, 0, 255)
drawfilloval (xc3, yc3, 10, 10, 255)
drawfilloval (xc3, yc3 + 2, 3, 3, 255)
drawarc (xc3, yc3 - 2, 4, 3, 180, 0, 255)
yc1 := yc1 - 10
yc2 := yc2 - 10
yc3 := yc3 - 10
yc4 := yc4 - 10
yc5 := yc5 - 10
yc6 := yc6 - 10
yc7 := yc7 - 10
yc8 := yc8 - 10
yc9 := yc9 - 10
yc10 := yc10 - 10
if yball >= 400 then
yball := 0
elsif num = 32 then
fired := true
yball := yball + 10
end if
if y > 400 and fired = true then
fired := false
yball := 0
xball := xcan
end if
if hasch then
getch (key ) %get key pressed
num := ord (key )
elsif num = 203 and xcan <= 5 then
xcan := xcan + 0
elsif num = 203 then %left arrow
xcan := xcan - 10
elsif num = 205 and xcan >= 560 then
xcan := xcan + 0
elsif num = 205 then %right arrow
xcan := xcan + 10
end if
if fired = false then
xball := xcan
yball := 0
end if
cls
if fired = true then
drawfilloval (xball + 40, yball + 80, 5, 5, 12)
end if
if fired = true then
drawfilloval (xball + 40, yball + 80, 5, 5, 255)
end if
end loop
if x > 200 and x < 440 and y < 180 and y > 230 then
cls
drawfill (1, 1, 255, 1)
drawbox (1, 399, 105, 350, 12)
locate (2, 2)
put "Back to menu" ..
Font.Draw ("Instructions", 180, 325, font4, 9)
locate (6, 1)
color (0)
put "Beware of the cyclops is played using the arrow keys, mouse and space bar. The"
put "arrow keys control the movement of your cannon," ..
put " and the spacebar is used to fire the cannon." ..
put " You collect power ups by shooting them out of the sky and killing bosses." ..
put " You also accumulate points for each enemy you shoot down, these " ..
put " points can be used to upgrade your cannon and to buy different projectiles." ..
put " After 3 levels of gameplay you will face a boss, which will be tougher than" ..
put "regular cyclops, but will give a higher point reward."
loop
buttonwait ("down", x, y, button, buttonupdown )
exit when x > 1 and x < 105 and y > 350 and y < 399
end loop
if x > 200 and x < 440 and y < 100 and y > 50 then
end if
end if
WinID := Window.GetActive
Window.Hide (WinID )>
|
Please specify what version of Turing you are using
<4.1> |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Cezna
|
Posted: Wed Jun 16, 2010 5:20 pm Post subject: RE:Turing Space shooter game |
|
|
You need to specify your problem or no one can help you |
|
|
|
|
|
Will910
|
Posted: Wed Jun 16, 2010 5:37 pm Post subject: RE:Turing Space shooter game |
|
|
oops didn't put brackets around it-----Alright so my problem is that every time I fire a projectile, it stops in the air if i move the cannon lateraly. Also falling enemies are not showing up. |
|
|
|
|
|
Will910
|
Posted: Wed Jun 16, 2010 5:59 pm Post subject: Re: Turing Space shooter game |
|
|
var x, y, button, buttonupdown, font1, font2, font3, font4, WinID : int
var lives, points, xcan, num, num1, yball, xball, lvl, xcyc, ycyc, dist : int := 0
var code : string
var key : string (1)
var fired : boolean := false
var xc1, xc2, xc3, xc4, xc5, xc6, xc7, xc8, xc9, xc10 : int
var yc1, yc2, yc3, yc4, yc5, yc6, yc7, yc8, yc9, yc10 : int
drawfill (1, 1, 255, 1)
font1 := Font.New ("chiller:32:underline,bold")
font2 := Font.New ("Arial black:24")
font3 := Font.New ("TremorITC TT:32:underline,bold")
font4 := Font.New ("BankGothic Lt BT:32:bold")
Font.Draw ("Beware of the Cyclops", 180, 200, font1, 12)
play ("<ADGEDGDEGDE1>A>")
cls
xcan := 260
xball := xcan
loop
%Title Screen
drawfill (1, 1, 255, 1)
color (14)
colorback (255)
drawbox (200, 370, 440, 320, 12) %start game button
Font.Draw ("Start", 270, 335, font2, 14)
drawbox (200, 230, 440, 180, 12) %Instructions button
Font.Draw ("Instructions", 215, 195, font2, 14)
drawbox (200, 100, 440, 50, 12) %Exit button
Font.Draw ("Exit", 275, 65, font2, 14)
%left cyclops on title screen
drawfilloval (100, 200, 25, 25, 4)
drawfilloval (100, 210, 7, 7, 1)
drawfillarc (100, 190, 15, 10, 180, 0, 0)
drawfillarc (100, 188, 12, 7, 180, 0, 255)
%right cyclops on title screen
drawfilloval (530, 200, 25, 25, 4)
drawfilloval (530, 210, 7, 7, 1)
drawfillarc (530, 190, 15, 10, 180, 0, 0)
drawfillarc (530, 188, 12, 7, 180, 0, 255)
View.Set ("offscreenonly")
buttonwait ("down", x, y, button, buttonupdown)
if x > 200 and x < 440 and y > 320 and y < 370 then
View.Update
cls
exit
end if
end loop
loop
if y > 400 and fired = true then
fired := false
yball := 0
xball:=xcan+40
end if
randint (xc1, 10, 610)
randint (xc2, 10, 610)
randint (xc3, 10, 610)
randint (xc4, 10, 610)
randint (xc5, 10, 610)
randint (xc6, 10, 610)
randint (xc7, 10, 610)
randint (xc8, 10, 610)
randint (xc9, 10, 610)
randint (xc10, 10, 610)
yc1 := 450
yc2 := 450
yc3 := 450
yc4 := 450
yc5 := 450
yc6 := 450
yc7 := 450
yc8 := 450
yc9 := 450
yc10 := 450
drawfilloval (xball + 40, yball + 80, 5, 5, 12)
drawfillbox (xcan, 1, xcan + 60, 30, 8)
drawfillbox (xcan + 30, 30, xcan + 50, 80, 8)
drawfillarc (xcan + 40, 80, 10, 5, 180, 0, 255)
drawfilloval (xc1, yc1, 10, 10, 12)
drawfilloval (xc1, yc1 + 2, 3, 3, 255)
drawarc (xc1, yc1 - 5, 4, 3, 180, 0, 14)
drawfilloval (xc2, yc2, 10, 10, 12)
drawfilloval (xc2, yc2 + 2, 3, 3, 255)
drawarc (xc2, yc2 - 5, 4, 3, 180, 0, 14)
drawfilloval (xc3, yc3, 10, 10, 12)
drawfilloval (xc3, yc3 + 2, 3, 3, 255)
drawarc (xc3, yc3 - 2, 4, 3, 180, 0, 14)
delay (50)
View.Update
drawfilloval (xball + 40, yball + 80, 5, 5, 255)
drawfillbox (xcan, 1, xcan + 60, 30, 255)
drawfillbox (xcan + 30, 30, xcan + 50, 80, 255)
drawfillarc (xcan + 40, 80, 10, 5, 180, 0, 255)
drawfilloval (xc1, yc1, 10, 10, 255)
drawfilloval (xc1, yc1 + 2, 3, 3, 255)
drawarc (xc1, yc1 - 2, 4, 3, 180, 0, 255)
drawfilloval (xc2, yc2, 10, 10, 255)
drawfilloval (xc2, yc2 + 2, 3, 3, 255)
drawarc (xc2, yc2 - 2, 4, 3, 180, 0, 255)
drawfilloval (xc3, yc3, 10, 10, 255)
drawfilloval (xc3, yc3 + 2, 3, 3, 255)
drawarc (xc3, yc3 - 2, 4, 3, 180, 0, 255)
yc1 := yc1 - 10
yc2 := yc2 - 10
yc3 := yc3 - 10
yc4 := yc4 - 10
yc5 := yc5 - 10
yc6 := yc6 - 10
yc7 := yc7 - 10
yc8 := yc8 - 10
yc9 := yc9 - 10
yc10 := yc10 - 10
if yball >= 400 then
yball := 0
xball:=xcan
end if
if hasch then
getch (key) %get key pressed
num := ord (key)
elsif num = 203 and xcan <= 5 then
xcan := xcan + 0
elsif num = 203 then %left arrow
xcan := xcan - 10
elsif num = 205 and xcan >= 560 then
xcan := xcan + 0
elsif num = 205 then %right arrow
xcan := xcan + 10
elsif num = 32 then
fired := true
yball := yball + 10
num1 := 32
end if
if fired = false then
xball := xcan
yball := 0
end if
if fired = true then
drawfilloval (xball + 40, yball + 80, 5, 5, 12)
end if
end loop
if x > 200 and x < 440 and y < 180 and y > 230 then
cls
drawfill (1, 1, 255, 1)
drawbox (1, 399, 105, 350, 12)
locate (2, 2)
put "Back to menu" ..
Font.Draw ("Instructions", 180, 325, font4, 9)
locate (6, 1)
color (0)
put "Beware of the cyclops is played using the arrow keys, mouse and space bar. The"
put "arrow keys control the movement of your cannon," ..
put " and the spacebar is used to fire the cannon." ..
put " You collect power ups by shooting them out of the sky and killing bosses." ..
put " You also accumulate points for each enemy you shoot down, these " ..
put " points can be used to upgrade your cannon and to buy different projectiles." ..
put " After 3 levels of gameplay you will face a boss, which will be tougher than" ..
put "regular cyclops, but will give a higher point reward."
loop
buttonwait ("down", x, y, button, buttonupdown)
exit when x > 1 and x < 105 and y > 350 and y < 399
end loop
if x > 200 and x < 440 and y < 100 and y > 50 then
end if
end if
WinID := Window.GetActive
Window.Hide (WinID)
______NEW CODE_____ |
|
|
|
|
|
Cezna
|
Posted: Wed Jun 16, 2010 6:17 pm Post subject: RE:Turing Space shooter game |
|
|
Put the same tags around that code as showed up in that first post, that will allow it to be read much more easily.
The tags are <code="Turing> before the code and </code> after the code, but with square brackets instead of triangle brackets.
example: (if you click "quote" at the top right of this post, you can see what all the stuff I typed looks like, and thus how to use it)
Turing: |
var the : string
the := the sky is orange
put the
|
|
|
|
|
|
|
Will910
|
Posted: Wed Jun 16, 2010 6:36 pm Post subject: Re: RE:Turing Space shooter game |
|
|
Turing: |
var x, y, button, buttonupdown, font1, font2, font3, font4, WinID : int
var lives, points, xcan, num, num1, yball, xball, lvl, xcyc, ycyc, dist : int := 0
var code : string
var key : string (1)
var fired : boolean := false
var xc1, xc2, xc3, xc4, xc5, xc6, xc7, xc8, xc9, xc10 : int
var yc1, yc2, yc3, yc4, yc5, yc6, yc7, yc8, yc9, yc10 : int
drawfill (1, 1, 255, 1)
font1 := Font.New ("chiller:32:underline,bold")
font2 := Font.New ("Arial black:24")
font3 := Font.New ("TremorITC TT:32:underline,bold")
font4 := Font.New ("BankGothic Lt BT:32:bold")
Font.Draw ("Beware of the Cyclops", 180, 200, font1, 12)
play ("<ADGEDGDEGDE1>A>")
cls
xcan := 260
xball := xcan
loop
%Title Screen
drawfill (1, 1, 255, 1)
color (14)
colorback (255)
drawbox (200, 370, 440, 320, 12) %start game button
Font.Draw ("Start", 270, 335, font2, 14)
drawbox (200, 230, 440, 180, 12) %Instructions button
Font.Draw ("Instructions", 215, 195, font2, 14)
drawbox (200, 100, 440, 50, 12) %Exit button
Font.Draw ("Exit", 275, 65, font2, 14)
%left cyclops on title screen
drawfilloval (100, 200, 25, 25, 4)
drawfilloval (100, 210, 7, 7, 1)
drawfillarc (100, 190, 15, 10, 180, 0, 0)
drawfillarc (100, 188, 12, 7, 180, 0, 255)
%right cyclops on title screen
drawfilloval (530, 200, 25, 25, 4)
drawfilloval (530, 210, 7, 7, 1)
drawfillarc (530, 190, 15, 10, 180, 0, 0)
drawfillarc (530, 188, 12, 7, 180, 0, 255)
View.Set ("offscreenonly")
buttonwait ("down", x, y, button, buttonupdown )
if x > 200 and x < 440 and y > 320 and y < 370 then
View.Update
cls
exit
end if
end loop
loop
if fired = true then
yball:=yball + 10
end if
if y > 400 and fired = true then
fired := false
yball := 0
xball := xcan + 40
end if
randint (xc1, 10, 610)
randint (xc2, 10, 610)
randint (xc3, 10, 610)
randint (xc4, 10, 610)
randint (xc5, 10, 610)
randint (xc6, 10, 610)
randint (xc7, 10, 610)
randint (xc8, 10, 610)
randint (xc9, 10, 610)
randint (xc10, 10, 610)
yc1 := 450
yc2 := 450
yc3 := 450
yc4 := 450
yc5 := 450
yc6 := 450
yc7 := 450
yc8 := 450
yc9 := 450
yc10 := 450
drawfilloval (xball + 40, yball + 80, 5, 5, 12)
drawfillbox (xcan, 1, xcan + 60, 30, 8)
drawfillbox (xcan + 30, 30, xcan + 50, 80, 8)
drawfillarc (xcan + 40, 80, 10, 5, 180, 0, 255)
drawfilloval (xc1, yc1, 10, 10, 12)
drawfilloval (xc1, yc1 + 2, 3, 3, 255)
drawarc (xc1, yc1 - 5, 4, 3, 180, 0, 14)
drawfilloval (xc2, yc2, 10, 10, 12)
drawfilloval (xc2, yc2 + 2, 3, 3, 255)
drawarc (xc2, yc2 - 5, 4, 3, 180, 0, 14)
drawfilloval (xc3, yc3, 10, 10, 12)
drawfilloval (xc3, yc3 + 2, 3, 3, 255)
drawarc (xc3, yc3 - 2, 4, 3, 180, 0, 14)
delay (100)
View.Update
drawfilloval (xball + 40, yball + 80, 5, 5, 255)
drawfillbox (xcan, 1, xcan + 60, 30, 255)
drawfillbox (xcan + 30, 30, xcan + 50, 80, 255)
drawfillarc (xcan + 40, 80, 10, 5, 180, 0, 255)
drawfilloval (xc1, yc1, 10, 10, 255)
drawfilloval (xc1, yc1 + 2, 3, 3, 255)
drawarc (xc1, yc1 - 2, 4, 3, 180, 0, 255)
drawfilloval (xc2, yc2, 10, 10, 255)
drawfilloval (xc2, yc2 + 2, 3, 3, 255)
drawarc (xc2, yc2 - 2, 4, 3, 180, 0, 255)
drawfilloval (xc3, yc3, 10, 10, 255)
drawfilloval (xc3, yc3 + 2, 3, 3, 255)
drawarc (xc3, yc3 - 2, 4, 3, 180, 0, 255)
yc1 := yc1 - 10
yc2 := yc2 - 10
yc3 := yc3 - 10
yc4 := yc4 - 10
yc5 := yc5 - 10
yc6 := yc6 - 10
yc7 := yc7 - 10
yc8 := yc8 - 10
yc9 := yc9 - 10
yc10 := yc10 - 10
if yball >= 400 then
yball := 0
xball := xcan
end if
if hasch then
getch (key ) %get key pressed
num := ord (key )
elsif num = 203 and xcan <= 5 then
xcan := xcan + 0
elsif num = 203 then %left arrow
xcan := xcan - 10
elsif num = 205 and xcan >= 560 then
xcan := xcan + 0
elsif num = 205 then %right arrow
xcan := xcan + 10
elsif num = 32 then
fired := true
yball := yball + 10
num1 := 32
end if
if fired = false then
xball := xcan
yball := 0
end if
if fired = true then
yball:=yball + 10
end if
end loop
if x > 200 and x < 440 and y < 180 and y > 230 then
cls
drawfill (1, 1, 255, 1)
drawbox (1, 399, 105, 350, 12)
locate (2, 2)
put "Back to menu" ..
Font.Draw ("Instructions", 180, 325, font4, 9)
locate (6, 1)
color (0)
put "Beware of the cyclops is played using the arrow keys, mouse and space bar. The"
put "arrow keys control the movement of your cannon," ..
put " and the spacebar is used to fire the cannon." ..
put " You collect power ups by shooting them out of the sky and killing bosses." ..
put " You also accumulate points for each enemy you shoot down, these " ..
put " points can be used to upgrade your cannon and to buy different projectiles." ..
put " After 3 levels of gameplay you will face a boss, which will be tougher than" ..
put "regular cyclops, but will give a higher point reward."
loop
buttonwait ("down", x, y, button, buttonupdown )
exit when x > 1 and x < 105 and y > 350 and y < 399
end loop
if x > 200 and x < 440 and y < 100 and y > 50 then
end if
end if
WinID := Window.GetActive
Window.Hide (WinID )
|
|
|
|
|
|
|
Cezna
|
Posted: Wed Jun 16, 2010 6:44 pm Post subject: RE:Turing Space shooter game |
|
|
Much betta'
Also, instead of pming me everything, just post it here so tha anyone who wants to help and see what you've fixed. |
|
|
|
|
|
Will910
|
Posted: Wed Jun 16, 2010 6:46 pm Post subject: Re: Turing Space shooter game |
|
|
Ok thanks for the info, much appreciated |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Cezna
|
Posted: Wed Jun 16, 2010 7:31 pm Post subject: RE:Turing Space shooter game |
|
|
Don't worry, I will look through your code too!
(You will have to repost what the problem is, as you pmed me with multiple problems, and then pmed saying some were solved, leaving me unsure of what the problems you are having are).
I just wanted to make sure you had it formatted right so that people who are much smarter than me would be able to help you too.
|
|
|
|
|
|
Will910
|
Posted: Wed Jun 16, 2010 8:23 pm Post subject: Re: Turing Space shooter game |
|
|
ok the problem is that once the cannon is fired, it continues to fire even when i don't press the key for it to fire(spacebar), i know this is because i needed a num:=0 to reset the keys entered, but when i tried it neither the cannon or the projectile would move when the correct keys were entered. |
|
|
|
|
|
TerranceN
|
Posted: Wed Jun 16, 2010 9:15 pm Post subject: RE:Turing Space shooter game |
|
|
First thing, look at your if statement to reset the ball:
Turing: | if y > 400 and fired = true then
fired := false
yball := 0
xball := xcan + 40
end if |
it uses y instead of yball, so change it to yball (also why is the + 40 there?). It still continuously shoots because num never gets reset when you hit space, so add (like you said) num := 0 in the if statement that checks if enter was hit (making sure it wont be next time it checks, but not voiding all other input). Now the ball will reset when it hits the top... sometimes. look at the other if statement you have in there to check if it has hit the top:
Turing: | if yball >= 400 then
yball := 0
xball := xcan
end if |
sometimes this is called instead of our first check for the ball hitting the top, and this does not set fired to false. Since we already have one check, we don't need another (so remove this one). Finally, you have two if statements that move the ball upward by 10, instead use 1 that moves it up by 2.
Hope that helps. |
|
|
|
|
|
Will910
|
Posted: Wed Jun 16, 2010 9:37 pm Post subject: RE:Turing Space shooter game |
|
|
THank you so much! |
|
|
|
|
|
Will910
|
Posted: Wed Jun 16, 2010 9:43 pm Post subject: RE:Turing Space shooter game |
|
|
The cannon seems to move really slowly, and it randomly stops moving occasionally after the projectile is fired, but at least it doesn't fire automatically....by the way, do you know why the other animations of the enemies are not showing up? |
|
|
|
|
|
|
|