Getting input from user while running a loop at the same time
Author |
Message |
Shadowlight117
|
Posted: Wed Apr 13, 2016 7:41 pm Post subject: Getting input from user while running a loop at the same time |
|
|
What is it you are trying to achieve?
I'm trying to create a program which runs an idle animation for a character on screen, and asks the user for input while still continuing the idle. the get command will ask for input, and depending on the number the user inputs, a different animation will be played. (I know how to do this, but it isnt done because i want to figure out the fix to this program before i program this) the part I'm having problems with is trying to get input while the idle animation continues until the input is given.
What is the problem you are having?
Trying to get input from the user while the idle animation continues until the input is given.
Describe what you have tried to solve this problem
Googling fixes, tried to use getch command instead of get
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing: |
setscreen ("graphics:1000;800")
var P1AttackPrompt : int
put "Choose which attack you want to do (1, 2 or 3)"
get P1AttackPrompt
if P1AttackPrompt = 1 then
%DO ATTACK 1
elsif P1AttackPrompt = 2 then
%DO ATTACK 2
elsif P1AttackPrompt = 3 then
%DO ATTACK 3
else
put "Invalid choice"
end if
loop
%DECLARING PICTURE VARIABLES%
var P1GokuIdleFrame1 : int := Pic.FileNew ("Gokuidle1.bmp")
var P1GokuIdleFrame2 : int := Pic.FileNew ("Gokuidle2.bmp")
var P1GokuIdleFrame3 : int := Pic.FileNew ("Gokuidle3.bmp")
var P1GokuIdleFrame4 : int := Pic.FileNew ("Gokuidle4.bmp")
%SETTING BACKGROUND COLORS TRANSPARENT
Pic.SetTransparentColor (P1GokuIdleFrame1, white)
Pic.SetTransparentColor (P1GokuIdleFrame2, white)
Pic.SetTransparentColor (P1GokuIdleFrame3, white)
Pic.SetTransparentColor (P1GokuIdleFrame3, white)
Pic.SetTransparentColor (P2GokuIdleFrame1, white)
Pic.SetTransparentColor (P2GokuIdleFrame2, white)
Pic.SetTransparentColor (P2GokuIdleFrame3, white)
Pic.SetTransparentColor (P2GokuIdleFrame3, white)
%DRAWING THE FRAMES OUT%
Draw.Cls
Pic.Draw (P1GokuIdleFrame1, 50, 50, picMerge)
delay (100)
Draw.Cls
Pic.Draw (P1GokuIdleFrame2, 50, 50, picMerge)
delay (100)
Draw.Cls
Pic.Draw (P1GokuIdleFrame3, 50, 50, picMerge)
delay (100)
Draw.Cls
Pic.Draw (P1GokuIdleFrame4, 50, 50, picMerge)
delay (100)
end loop
|
Please specify what version of Turing you are using
4.1.1
The code shows the idle animation in the loop and i want the get command to continue the idle animation until the input is given by the user. I don't know where in the code im supposed to write the get command with the if statement (or even if i am supposed to use the get command) |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Insectoid
|
Posted: Thu Apr 14, 2016 4:30 am Post subject: RE:Getting input from user while running a loop at the same time |
|
|
Here's a very similar question. The solution is the same for you: http://compsci.ca/v3/viewtopic.php?p=290422 |
|
|
|
|
|
|
|