health output wont want to work
Author |
Message |
UnTiteled
|
Posted: Fri Jan 15, 2010 5:25 pm Post subject: health output wont want to work |
|
|
What is it you are trying to achieve?
im trying to make my code output correctly because it doesnt want to subtract
What is the problem you are having?
my healt wont want to subtract because i think im outputting something out wrong
Describe what you have tried to solve this problem
tryed moving the code arround ...
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing: |
const GROUND_HEIGHT := 120
const RUN_SPEED := 10
const JUMP_SPEED := 30
const GRAVITY := 2
var manfig1 := Pic.FileNew ("stand.gif")
var manfig2 := Pic.FileNew ("face.gif")
var monsterfig2 := Pic.FileNew ("monster_face.gif")
var monster := Pic.FileNew ("monster.gif")
var ypos := 750
var xpos := 150
var chars : array char of boolean
var position := 1000
var posx, posy : int
var velx, vely : real
var hp2 := 100
posx := 20
velx := 0
posy := 400
vely := 0
setscreen ("graphics:max;max")
put ""
put ""
put ""
put ""
put ""
put ""
put ""
put ""
put ""
put "Loading Game..."
colourback (40)
put ""
locate (11, 79)
colourback (50)
put " "
delay (100)
locate (11, 78)
put " "
delay (100)
locate (11, 77)
put " "
delay (100)
locate (11, 76)
put " "
delay (100)
locate (11, 75)
put " "
delay (100)
locate (11, 74)
put " "
delay (100)
locate (11, 73)
put " "
delay (100)
locate (11, 73)
put " "
delay (100)
locate (11, 72)
put " "
delay (100)
locate (11, 71)
put " "
delay (100)
locate (11, 70)
put " "
delay (100)
locate (11, 69)
put " "
delay (100)
locate (11, 68)
put " "
delay (100)
locate (11, 67)
put " "
delay (100)
locate (11, 66)
put " "
delay (200)
locate (11, 65)
put " "
delay (100)
locate (11, 64)
put " "
delay (100)
locate (11, 63)
put " "
delay (100)
locate (11, 62)
put " "
delay (100)
locate (11, 61)
put " "
delay (100)
locate (11, 60)
put " "
delay (100)
locate (11, 59)
put " "
delay (500)
locate (11, 58)
put " "
delay (100)
locate (11, 57)
put " "
delay (100)
locate (11, 56)
put " "
delay (100)
locate (11, 55)
put " "
delay (100)
locate (11, 54)
put " "
delay (100)
locate (11, 53)
put " "
delay (100)
locate (11, 52)
put " "
delay (200)
locate (11, 51)
put " "
delay (100)
locate (11, 50)
put " "
delay (100)
locate (11, 49)
put " "
delay (100)
locate (11, 48)
put " "
delay (100)
locate (11, 47)
put " "
delay (100)
locate (11, 46)
put " "
delay (100)
locate (11, 45)
put " "
delay (100)
locate (11, 44)
put " "
delay (100)
locate (11, 43)
put " "
delay (300)
locate (11, 42)
put " "
delay (100)
locate (11, 41)
put " "
delay (100)
locate (11, 40)
put " "
delay (100)
locate (11, 39)
put " "
delay (100)
locate (11, 38)
put " "
delay (100)
locate (11, 37)
put " "
delay (100)
locate (11, 36)
put " "
delay (100)
locate (11, 35)
put " "
delay (100)
locate (11, 34)
put " "
delay (100)
locate (11, 33)
put " "
delay (100)
locate (11, 32)
put " "
delay (100)
locate (11, 31)
put " "
delay (100)
locate (11, 30)
put " "
delay (100)
locate (11, 29)
put " "
delay (100)
locate (11, 28)
put " "
delay (100)
locate (11, 27)
put " "
delay (100)
locate (11, 26)
put " "
delay (200)
locate (11, 25)
put " "
delay (100)
locate (11, 24)
put " "
delay (100)
locate (11, 23)
put " "
delay (100)
locate (11, 22)
put " "
delay (100)
locate (11, 21)
put " "
delay (100)
locate (11, 20)
put " "
delay (100)
locate (11, 19)
put " "
delay (500)
locate (11, 18)
put " "
delay (100)
locate (11, 17)
put " "
delay (100)
locate (11, 16)
put " "
delay (100)
locate (11, 15)
put " "
delay (100)
locate (11, 14)
put " "
delay (100)
locate (11, 13)
put " "
delay (100)
locate (11, 12)
put " "
delay (200)
locate (11, 11)
put " "
delay (100)
locate (11, 10)
put " "
delay (100)
locate (11, 9)
put " "
delay (100)
locate (11, 8)
put " "
delay (100)
locate (11, 7)
put " "
delay (100)
locate (11, 6)
put " "
delay (100)
locate (11, 5)
put " "
delay (100)
locate (11, 4)
put " "
delay (100)
locate (11, 3)
put " "
delay (300)
locate (11, 2)
put " "
delay (300)
locate (11, 1)
put " "
delay (100)
colourback (70)
cls
locate (15, 20)
put "___________.__"
locate (16, 20)
put "\\__ ___/| |__ ____ "
locate (17, 20)
put " | | | | \\_/ __ \\ "
locate (18, 20)
put " | | | Y \\ ___/ "
locate (19, 20)
put " |____| |___| /\\___ >"
locate (20, 20)
put " \\/ \\/ "
locate (21, 20)
put " _____ .__ .__ .__ __ "
locate (22, 20)
put " / _ \\ | | ____ | |__ ____ _____ |__| _______/ |_ "
locate (23, 20)
put " / /_\\ \\| | _/ ___\\| | \\_/ __ \\ / \\| |/ ___/\\ __\\"
locate (24, 20)
put "/ | \\ |_\\ \\___| Y \\ ___/| Y Y \\ |\\___ \\ | | "
locate (25, 20)
put "\\____|__ /____/\\___ >___| /\\___ >__|_| /__/____ > |__| "
locate (26, 20)
put " \\/ \\/ \\/ \\/ \\/ \\/ "
put "Instructions: Move with the 'up, down, left, and right buttons', shoot with the space bar"
put ""
put "On the first day, God created the Heavens and The earth..."
put "On the sixth day, God created the creatures of the earth, and with them"
put "came a soul devouring beast, once the humans were put on the earth, so"
put "did the demon start to hunt for souls"
put ""
put "your quest iss to defeat these demons and save the world from darkness"
put "hit any key to begin"
Input.Pause
colourback (white)
colour (white)
cls
locate (16, 20)
colour (black)
put " _______________"
locate (17, 20)
put "|prepare |"
locate (18, 20)
put "|to |"
locate (19, 20)
put "|be destroyed. |"
locate (20, 20)
put "| ______________|"
locate (21, 20)
put "|/"
Pic.Draw (manfig2, 120, 240, picMerge)
Pic.Draw (manfig1, 50, 50, picMerge)
drawline (0, GROUND_HEIGHT, maxx, GROUND_HEIGHT, blue)
locate (41, 10)
put "hit any key to continue"
Input.Pause
locate (16, 90)
put " _______________"
locate (17, 90)
put "| |"
locate (18, 90)
put "|GRAAAWWWWRRRRR |"
locate (19, 90)
put "|______________ |"
locate (20, 90)
put " |/"
Pic.Draw (monsterfig2, 790, 250, picMerge)
locate (41, 10)
Pic.Draw (monster, position, 60, picMerge)
View.Set ("offscreenonly")
loop
colour (black)
colourback (white)
cls
locate (16, 20)
put " _______________"
locate (17, 20)
put "|prepare |"
locate (18, 20)
put "|to |"
locate (19, 20)
put "|be destroyed. |"
locate (20, 20)
put "| ______________|"
locate (21, 20)
put "|/"
Pic.Draw (manfig2, 120, 240, picMerge)
Pic.Draw (manfig1, 50, 50, picMerge)
drawline (0, GROUND_HEIGHT, maxx, GROUND_HEIGHT, blue)
locate (41, 10)
locate (16, 90)
put " _______________"
locate (17, 90)
put "| |"
locate (18, 90)
put "|GRAAAWWWWRRRRR |"
locate (19, 90)
put "|______________ |"
locate (20, 90)
put " |/"
Pic.Draw (monsterfig2, 790, 250, picMerge)
locate (41, 10)
Pic.Draw (monster, position, 60, picMerge)
position := position - 1
delay (15)
View.Update
cls
exit when position = 750
end loop
locate (5, 50)
put "press s to start..."
Input.Pause
var pic2 := Pic.FileNew ("darkblast.gif")
var monster2 := Pic.FileNew ("monster.gif")
var pic := Pic.FileNew ("fireball2.gif")
View.Set ("offscreen")
loop
loop
var box1_x1, box1_y1, box1_x2, box1_y2 : int
var box2_x1, box2_y1, box2_x2, box2_y2 : int
var y := posx
var x := posy
box1_x1 := y
box1_y1 := x
box1_x2 := y + 60
box1_y2 := x + 60
box2_x1 := 780
box2_y1 := 40
box2_x2 := 840
box2_y2 := 225
put "enemy:health ",hp2, "/100"
drawbox (box1_x1, box1_y1, box1_x2, box1_y2, 9)
drawbox (box2_x1, box2_y1, box2_x2, box2_y2, 12)
box1_x1 + = 1
box1_x2 + = 1
if box1_x2 = box2_x1 and box1_y2 > box2_y1 then
hp2 := hp2 - 10
end if
Input.KeyDown (chars )
if chars ('q') then
exit
end if
if chars (KEY_LEFT_ARROW) then
velx := -RUN_SPEED
elsif chars (KEY_RIGHT_ARROW) then
velx := RUN_SPEED
else
velx := 0
end if
if chars (KEY_UP_ARROW) and posy = GROUND_HEIGHT then
vely := JUMP_SPEED
end if
Pic.Draw (monster2, 750, 60, picMerge)
Pic.Draw (pic2, ypos, xpos, picMerge)
ypos := ypos - 1
delay (3)
if ypos = - 80 then
ypos := 750
exit
end if
Input.KeyDown (chars )
if chars (' ') then
loop
put "enemy:health ",hp2, "/100"
box1_x1 := y
box1_y1 := x
box1_x2 := y + 60
box1_y2 := x + 60
box2_x1 := 780
box2_y1 := 40
box2_x2 := 840
box2_y2 := 225
drawbox (box1_x1, box1_y1, box1_x2, box1_y2, 9)
drawbox (box2_x1, box2_y1, box2_x2, box2_y2, 12)
box1_x1 + = 1
box1_x2 + = 1
if box1_x2 = box2_x1 and box1_y2 > box2_y1 then
hp2 := hp2 - 10
end if
Input.KeyDown (chars )
if chars ('q') then
exit
end if
if chars (KEY_LEFT_ARROW) then
velx := -RUN_SPEED
elsif chars (KEY_RIGHT_ARROW) then
velx := RUN_SPEED
else
velx := 0
end if
if chars (KEY_UP_ARROW) and posy = GROUND_HEIGHT then
vely := JUMP_SPEED
end if
Pic.Draw (manfig1, posx, posy, picMerge)
drawline (0, GROUND_HEIGHT, maxx, GROUND_HEIGHT, blue)
vely - = GRAVITY
posx + = round (velx )
posy + = round (vely )
if posy < GROUND_HEIGHT then
posy := GROUND_HEIGHT
vely := 0
end if
delay (35)
View.Update
cls
if posx < 0 then
posx := - 1
elsif posx > 600 then
posx := 600
end if
Pic.Draw (pic, y, x, picMerge)
y + = 5
if y > 760 then
y := - 10
exit
end if
Pic.Draw (monster2, 750, 60, picMerge)
Pic.Draw (pic2, ypos, xpos, picMerge)
ypos := ypos - 1
delay (3)
if ypos = - 80 then
ypos := 750
end if
end loop
end if
ypos := ypos - 1
delay (3)
if ypos = - 80 then
ypos := 750
end if
vely - = GRAVITY
posx + = round (velx )
posy + = round (vely )
if posy < GROUND_HEIGHT then
posy := GROUND_HEIGHT
vely := 0
end if
Pic.Draw (manfig1, posx, posy, picMerge)
drawline (0, GROUND_HEIGHT, maxx, GROUND_HEIGHT, blue)
delay (35)
if posx < 0 then
posx := - 1
elsif posx > 600 then
posx := 600
end if
View.Update
cls
end loop
ypos := ypos - 1
delay (3)
if ypos = - 80 then
ypos := 750
end if
end loop
|
Please specify what version of Turing you are using
4.1.1 |
|
|
|
|
|
Sponsor Sponsor
|
|
|
ProgrammingFun
|
Posted: Fri Jan 15, 2010 8:10 pm Post subject: RE:health output wont want to work |
|
|
Just so you know: you could try uploading a file with this program instead of posting this super-long code. |
|
|
|
|
|
Turing_Gamer
|
Posted: Sun Jan 17, 2010 3:49 pm Post subject: Re: health output wont want to work |
|
|
If you have a health bar and/or a health indicating number...
Turing: | var healthstatus := 100
loop
Draw.FillBox (1, 1, healthstatus, 10, brightred)
Draw.Box (1, 1, 100, 10, red)
Font.Draw ("Health: " + intstr (healthstatus ), 1, 11, font, black)
if hit := true then
healthstatus := healthstatus - 10
if healthstatus <= 0 then
put "You died"
end if
end if
end loop
|
|
|
|
|
|
|
|
|