Help making keys do actions
Author |
Message |
Octobers
|
Posted: Sat Jun 13, 2009 4:37 pm Post subject: Help making keys do actions |
|
|
Just fixed it lol. The end if and end loop for a keyboard input have to be at the end of the code for the computer to keep checking. Im such an idiot :p. A mod can close this thread now or delete it.
What is it you are trying to achieve?
I need to make a story as a summation assignment. At one point, one character leaves the screen and you press the up arrow to follow him.
What is the problem you are having?
When i press the up arrow nothing happens. No errors are given, but the program isn't register use input
Describe what you have tried to solve this problem
Many things, but I am not that skilled at turing and very new to user input.
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 chars : array char of boolean
var f1 : int
f1 := Font.New ("Qlassik:12")
var Walk1 : int := Pic.FileNew ("Walk1.bmp")
var Walk2 : int := Pic.FileNew ("Walk2.bmp")
var WalkAway1 : int := Pic.FileNew ("WalkAway1.bmp")
var WalkAway2 : int := Pic.FileNew ("WalkAway2.bmp")
var Stand : int := Pic.FileNew ("Stand.bmp")
var Excite : int := Pic.FileNew ("Excite.bmp")
var x : int := 0
var x2 : int := 0
Font.Draw ("Nathan's Story", 280, 370, f1, black)
Font.Draw ("Press 'Enter' to start the story", 230, 340, f1, black)
loop
Input.KeyDown (chars )
if chars (KEY_ENTER ) then %Enter key to start
cls
for i : 1 .. 5 %Walk forward 5 times
x := x + 20
Pic.Draw (Walk1, 200, 250 - x, 0)
delay (300)
cls
Pic.Draw (Walk2, 200, 250 - x, 0)
delay (300)
cls
end for
Pic.Draw (Walk2, 200, 170, 0)
Font.Draw ("-Oh hey", 370, 340, f1, black) %Write
delay (1000)
cls
Pic.Draw (Stand, 200, 170, 0) %Change picture to standing
Font.Draw ("What's going on?", 370, 340, f1, black) %Write
delay (2000)
cls
Pic.Draw (Stand, 200, 170, 0) %Change picture to standing
Font.Draw ("Me? I'm just walking", 370, 340, f1, black) %Write
Font.Draw ("back home from work.", 370, 312, f1, black) %Write
delay (3500)
cls
Pic.Draw (Stand, 200, 170, 0) %Change picture to standing
Font.Draw ("Do you want to see my house?", 370, 340, f1, black) %Write
Font.Draw ("I built it all by myself.", 370, 312, f1, black) %Write
delay (3200)
cls
Pic.Draw (Stand, 200, 170, 0) %Change picture to standing
Font.Draw ("What's that?", 370, 340, f1, black) %Write
delay (1500)
cls
Pic.Draw (Stand, 200, 170, 0) %Change picture to standing
Font.Draw ("You do?", 370, 340, f1, black) %Write
delay (1800)
cls
Pic.Draw (Excite, 200, 170, 0) %Change picture to standing
Font.Draw ("Let's go! :D", 370, 340, f1, black) %Write
delay (2000)
cls
for i : 1 .. 20 %Walk away 25 times
Pic.Draw (WalkAway1, 200, 170 + x2, 0)
delay (100)
cls
Pic.Draw (WalkAway2, 200, 170 + x2, 0)
x2 := x2 + 20
delay (100)
cls
end for
put "Uh oh. It looks like he's gone."
put "Press the up arrow to follow him!"
end if
end loop
loop Input.KeyDown (chars )
if chars (KEY_UP_ARROW) then %UP arrow key to follow
cls
end if
end loop
%Night Sky
drawfillbox (0, 100, 700, 700, black)
%Snow on Ground
drawfillbox (0, 0, 700, 100, white)
%Basic Parts of House
drawfillbox (150, 100, 400, 300, 4) %Draws square base of house
drawfillbox (250, 100, 300, 175, blue) %Draws door
drawfilloval (290, 135, 5, 5, yellow) %Door knob
drawfillbox (170, 310, 195, 360, grey) %Chimney
%Roof
var t : array 1 .. 3 of int := init (120, 275, 420)
var o : array 1 .. 3 of int := init (300, 390, 300)
drawfillpolygon (t, o, 3, blue)
% Windows
drawfillbox (170, 220, 210, 260, yellow) %Left window
drawline (190, 220, 190, 260, black) %Vertical Line
drawline (170, 238, 210, 238, black) %Horizontal Line
drawfillbox (340, 220, 380, 260, 14) %Right Window
drawline (360, 220, 360, 260, black) %Vertical Line
drawline (340, 240, 380, 240, black) %Horizontal Line
%Stars
drawfillstar (100, 360, 120, 380, yellow)
drawfillstar (145, 330, 165, 350, yellow)
drawfillstar (400, 325, 425, 350, yellow)
drawfillstar (420, 225, 440, 245, yellow)
drawfillstar (420, 380, 440, 400, yellow)
%Moon
drawfilloval (75, 300, 27, 26, 92)
%Tree of Awesome!
drawfillbox (500, 100, 517, 145, 114)%Trunk
var a : array 1 .. 3 of int := init (487, 508, 531)%Green
var b : array 1 .. 3 of int := init (120, 190, 120)
drawfillpolygon (a, b, 3, green)
%%%%%%%%%
%Fence%
%Posts (posts go from left to right
drawfillbox (0, 100, 10, 150, brown)
drawfillbox (20, 100, 30, 150, brown)
drawfillbox (40, 100, 50, 150, brown)
drawfillbox (60, 100, 70, 150, brown)
drawfillbox (80, 100, 90, 150, brown)
drawfillbox (100, 100, 110, 150, brown)
drawfillbox (120, 100, 130, 150, brown)
drawfillbox (140, 100, 150, 150, brown)
drawfillbox (160, 100, 170, 150, brown)
drawfillbox (180, 100, 190, 150, brown)
drawfillbox (200, 100, 210, 150, brown)
drawfillbox (220, 100, 230, 150, brown)
%%%%%%%%%%Door Here%%%%%%%%%%%%%%%
drawfillbox (315, 100, 325, 150, brown)
drawfillbox (335, 100, 345, 150, brown)
drawfillbox (355, 100, 365, 150, brown)
drawfillbox (375, 100, 385, 150, brown)
drawfillbox (395, 100, 405, 150, brown)
drawfillbox (415, 100, 425, 150, brown)
drawfillbox (435, 100, 445, 150, brown)
drawfillbox (455, 100, 465, 150, brown)
%Cross Bars
drawfillbox (0, 120, 235, 130, brown)
drawfillbox (310, 120, 470, 130, brown)
%Flashing lights
loop
drawfilloval (500, 150, 5, 5, 10)
drawfilloval (510, 170, 5, 5, 14)
drawfilloval (525, 125, 5, 5, 38)
drawfilloval (495, 125, 5, 5, 9)
drawfilloval (520, 145, 5, 5, 76)
delay (500)
drawfilloval (500, 150, 5, 5, 12)
drawfilloval (510, 170, 5, 5, 43)
drawfilloval (525, 125, 5, 5, 1)
drawfilloval (495, 125, 5, 5, 13)
drawfilloval (520, 145, 5, 5, 79)
delay(500)
end loop
|
Please specify what version of Turing you are using
4.1.1 |
|
|
|
|
|
Sponsor Sponsor
|
|
|
TheGuardian001
|
Posted: Sat Jun 13, 2009 7:55 pm Post subject: Re: Help making keys do actions |
|
|
I'm thinking you don't understand what a loop does. When you put something in a loop, the computer runs that section over and over until you tell it to exit. Since you haven't told either one of your two loops to exit, the computer will keep on running them forever.. |
|
|
|
|
|
|
|