i need help iwth my game
Author |
Message |
killjackin61
|
Posted: Tue Nov 24, 2009 11:06 am Post subject: i need help iwth my game |
|
|
What is it you are trying to achieve?
i made a game that you can shoot stuff
What is the problem you are having?
when shooting to the right of player, bullet goes backwards instead of forward
Describe what you have tried to solve this problem
<Answer Here>
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>
Turing: |
% This program will allow the player to shoot at the zombie
% Made by Tom Ai and Justin Jia
% Name: BEST GAME EVER !!!!!!
% The declartion of some of the varible
var guy, zombie, background : int
var jump_s : int := 10
var grav : int := 1
var key : array char of boolean
var px, py : int
var vel_y : real
var boom : boolean := false
var hit : boolean := false
var pictureguyf : int := Pic.FileNew ("foward.bmp")
var pictureguyb : int := Pic.FileNew ("back.bmp")
var picturezombie: int := Pic.FileNew ("zombie copy.bmp")
px := 200
py := 10
vel_y := 0
var zx := 9
var zy : int := 20
var x, y, oldx, oldy, b : int := - 1
var x1, y1 : int
x1 := px
y1 := py
var distantright : real
var health : int
var zombiehealth : int
var numzombie : int := 1
var count : int := 0
var name : string
var picturenum : int
% The background
picturenum := Pic.FileNew ("zombie background.JPG")
% Introduction to the game
locate (1, 30)
put "Kill Kill Kill!"
put skip
put " you are the only guy left that isn't a zombie"
put " defend youself from the countless amount of zombies coming at you"
put " Even worse, the zombie gets faster and faster every time you kill one"
put " luckly you have a gun"
put " but sadly not every bullet will hit!"
put " to move, use the arrow keys"
put " but watch out, you may not jump as high as you think"
put " you can aim by putting the crosshair on the zombie!"
put " you can shoot by click you mouse keys"
put " you must attempt to survive as long as you can. After surviving each"
put " wave, the next wave will be launched."
put "The health bar on the left top corner is your life, do not let it fall to 0"
put " The health bar on the right is the zombie's, kill it before it kills you!"
put ""
put " There is cheat modes"
put " but let's just say if you want to use it, do not enter chuck norris"
put ""
put " Good Luck! You'll need it."
put ""
put " Please enter your name: " ..
get name : *
put name, " press any key to enter HELL...."
Input.Pause
cls
process PlayBackgroundMusic (music : string)
loop
Music.PlayFile (music )
exit when health = 0 or zombiehealth = 0
end loop
end PlayBackgroundMusic
fork PlayBackgroundMusic ("music.mp3")
% cheat modes!!!
View.Set ("graphics,offscreenonly")
if name = "jesus" then
Font.Draw ("God Mode!!!", maxx div 2, maxy div 2 + 100, defFontID, red)
health := 1000
zombiehealth := 10
jump_s := 15
elsif name = "justin jia" or name = "tom ai" then
Font.Draw ("Creator mode!!!!", maxx div 2, maxy div 2 + 100, defFontID, red)
health := 10000000
zombiehealth := 10
jump_s := 20
elsif name = "chuck norris" then
Font.Draw ("Impossible mode!!!!", maxx div 2, maxy div 2 + 100, defFontID, red)
health := 1
zombiehealth := 10
jump_s := 0
elsif name = "ninja" then
Font.Draw ("super speed mode!!!!", maxx div 2, maxy div 2 + 100, defFontID, red)
health := 100
zombiehealth := 10
jump_s := 15
else
health := 100
zombiehealth := 10
jump_s := 15
end if
% Movement of zombie
process zombiemove
for i : 1 .. numzombie
% This loop will end when the life of the zombie is equal to zero
loop
Pic.Draw (picturezombie, zx, zy- 10, picCopy)
zx := zx + 1
if zx >= maxx then
zx := 10
end if
delay (25)
exit when health = 0 or zombiehealth = 0 and count = 30
end loop
end for
end zombiemove
%life of zombie and guy then display them
procedure life
if boom = true then
health := health - 1
end if
Font.Draw ("Health: ", 50, maxy - 15, defFontID, white)
locate (2, 9)
colorback (black)
color (white)
put health ..
if health >= 76 then
drawfillbox (0, maxy - 60, 150, maxy - 30, green)
elsif health >= 50 and health <= 75 then
drawfillbox (0, maxy - 60, 100, maxy - 30, yellow)
elsif health >= 25 and health < 50 then
drawfillbox (0, maxy - 60, 50, maxy - 30, 40)
elsif health >= 10 and health < 25 then
drawfillbox (0, maxy - 60, 25, maxy - 30, red)
elsif health < 10 then
drawfillbox (0, maxy - 60, 10, maxy - 30, black)
Font.Draw ("WARNING! you are about to die", 200, 200, defFontID, red)
end if
delay (25)
if hit = true then
zombiehealth := zombiehealth - 1
end if
Font.Draw ("Zombie Health: ", 530, maxy - 15, defFontID, white)
locate (2, 70)
put zombiehealth ..
if zombiehealth = 10 then
drawfillbox (550, maxy - 60, maxx, maxy - 40, green)
elsif zombiehealth >= 6 and zombiehealth <= 9 then
drawfillbox (550, maxy - 60, maxx - 20, maxy - 30, yellow)
elsif zombiehealth >= 4 and zombiehealth < 6 then
drawfillbox (550, maxy - 60, maxx - 40, maxy - 30, 40)
elsif zombiehealth >= 1 and zombiehealth < 4 then
drawfillbox (550, maxy - 60, maxx - 60, maxy - 30, red)
end if
if health = 0 then
cls
Font.Draw ("GAME OVER!", maxx div 2 - 30, maxy div 2, defFontID, white)
end if
if zombiehealth = 0 then
zombiehealth := 10
zx := 10
numzombie := numzombie + 10
count := count + 1
Font.Draw ("Next Wave!", maxx div 2 - 30, maxy div 2, defFontID, white)
delay (500)
cls
fork zombiemove
end if
locate (5, 30)
put name, " YOU SURVIVED, ", count, " ZOMBIES!!!" ..
end life
% check when zombie hit guy his life goes down, and when bullet hit zombie then zombie's life goes down.
procedure CheckForCollision
% distant between zombie and guy
var zombiedistant : int
distantright := (px - 20) - (zx + 10)
if distantright <= 0 and distantright >= - 100 and py = 10 then
boom := true
else
boom := false
end if
% Distant between bullet and zombie
zombiedistant := x1 - (zx + 10)
% Cheat mode on
if name = "jesus" or name = "justin jia" or name = "tom ai" then
if zombiedistant <= 0 and zombiedistant >= - 100 then
hit := true
else
hit := false
delay (25)
end if
else
% Cheat mode off
if zombiedistant <= 0 and zombiedistant >= - 100 and py = 10 then
hit := true
else
hit := false
delay (25)
end if
end if
life
end CheckForCollision
% The process for the where it should start and where it end.
process bullet
% This loop will end when the health of the guy is equal to zero
loop
% Get the current location of the mouse
mousewhere (x, y, b )
drawoval (x, y, 20, 20, green)
drawline (x - 45, y, x + 45, y, green)
drawline (x, y + 45, x, y - 45, green)
delay (10)
drawoval (x, y, 20, 20, white)
drawline (x - 45, y, x + 45, y, picCopy)
drawline (x, y + 45, x, y - 45, picCopy)
% If the mouse has moved and the button is pressed.
if (x not= oldx or y not= oldy ) and b = 1 then
% What happen if you click to the right of the guy
if x > px then
for a : 1 .. 80
drawfilloval (x1, y1, 5, 5, white)
drawfillbox (x1 + 12, y1 - 5, x1, y1 + 5, white)
delay (1)
drawfilloval (x1, y1, 5, 5, black)
drawfillbox (x1 + 12, y1 - 5, x1, y1 + 5, black)
x1 := x1 + 4
end for
x1 := px
y1 := py + 30
% What happen if you click to the left of the guy
elsif x < px then
for a : 1 .. 80
drawfilloval (x1 - 12, y1, 5, 5, white)
drawfillbox (x1 - 12, y1 - 5, x1, y1 + 5, white)
delay (10)
drawfilloval (x1 - 12, y1, 5, 5, black)
drawfillbox (x1 - 12, y1 - 5, x1, y1 + 5, black)
x1 := x1 - 4
end for
x1 := px - 5
y1 := py + 20
end if
end if
exit when health = 0and count = 30
end loop
end bullet
fork bullet
fork zombiemove
% Check for the boudery so that the guy cannot go out of the screen
procedure checkboundery
if px <= 30 then
px := 30
elsif px >= maxx - 30 then
px := maxx - 30
end if
end checkboundery
% This loop will display the guy as he keep moving.
% Also it loop will stop when the health of the guy is equal to zero
loop
Pic.Draw (picturenum, 0, 0, picCopy)
delay (10)
CheckForCollision
% with cheat on
if name = "justin jia" or name = "tom ai" or name = "ninja" then
Input.KeyDown (key )
% What happen if you press left arrow
if key (KEY_LEFT_ARROW) then
px - = 30
checkboundery
% What happen if you press right arrow
elsif key (KEY_RIGHT_ARROW) then
px + = 30
checkboundery
% What happen if you press up arrow
end if
if key (KEY_UP_ARROW) and py = 10 then
vel_y := jump_s
end if
vel_y - = grav
py + = round (vel_y )
if py < 10 then
py := 10
vel_y := 0
end if
% Draw the guy with the cheat mode on
if x <= px then
Pic.Draw (pictureguyf, px, py, picCopy)
else
Pic.Draw (pictureguyb, px, py, picCopy)
end if
delay (25)
else
% with cheat off
Input.KeyDown (key )
% What happen if you press the left arrow
if key (KEY_LEFT_ARROW) then
px - = 5
checkboundery
% What happen if you press the right arrow
elsif key (KEY_RIGHT_ARROW) then
px + = 5
checkboundery
% What happen if you press the up arrow
end if
if key (KEY_UP_ARROW) and py = 10 then
vel_y := jump_s
end if
vel_y - = grav
py + = round (vel_y )
if py < 10 then
py := 10
vel_y := 0
end if
% Draw the guy with cheat mode off
if x <= px then
Pic.Draw (pictureguyf, px, py, picCopy)
else
Pic.Draw (pictureguyb, px, py, picCopy)
end if
delay (25)
end if
View.Update
exit when health = 0 and count = 30
end loop
% Game end
if count = 30 then
cls
Font.Draw ("You have killed every single zombie on Earth, and you survived.", maxx div 2 - 150, maxy div 2 + 100, defFontID, red)
Font.Draw ("GAME OVER!", maxx div 2 - 30, maxy div 2, defFontID, red)
end if
|
Please specify what version of Turing you are using
<Answer Here> |
|
|
|
|
|
Sponsor Sponsor
|
|
|
apomb
|
Posted: Tue Nov 24, 2009 11:49 pm Post subject: RE:i need help iwth my game |
|
|
increment your variable instead of decrementing it. |
|
|
|
|
|
|
|