Request Turing Help
Author |
Message |
Ahaurgoon
|
Posted: Tue May 08, 2012 10:25 am Post subject: Request Turing Help |
|
|
Hi, my friend and I were wondering how to make a triangle move from user controlled keys (left and right arrow keys) Could someone help us out please?
Thank you very much |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Dreadnought
|
Posted: Tue May 08, 2012 10:41 am Post subject: Re: Request Turing Help |
|
|
Well, you will need to check if the keys are pressed. For that have a look at the documentation for InputModule and Keycodes. For a triangle, if you don't know how to draw one, what you need is in DrawModule.
Keep track of the position of your triangle with one or more variables (x-position, or maybe all the corners).
Also, you'll likely need a loop to check for key presses, change the position variable(s) and then redraw the triangle on the screen.
If you have any specific problems, post what you've tried. |
|
|
|
|
|
Raknarg
|
Posted: Tue May 08, 2012 11:04 am Post subject: RE:Request Turing Help |
|
|
There's actually a tutorial on thise, btw. Go look at The Turing Walkthrough. |
|
|
|
|
|
Ahaurgoon
|
Posted: Tue May 08, 2012 5:58 pm Post subject: RE:Request Turing Help |
|
|
So i have this, but i want it to go up the screen, not at an angle, also I dont want it to reset back to where it started when you let go of the key
loop
var a, b, c, d, e, f, g, h : int
a := 2
b := 2
c := 9
d := 20
e := 15
f := 8
g := 8
h := 9
for i : a .. maxx - 20
cls
drawline (a, b, c, d, blue)
drawline (c, d, e, a, blue)
drawline (a, b, f, g, blue)
drawline (h, g, e, a, blue)
var chars : array char of boolean
Input.KeyDown (chars)
if chars (KEY_UP_ARROW) then
a := a + 1
b := b + 1
c := c + 1
d := d + 1
e := e + 1
f := f + 1
g := g + 1
h := h + 1
delay (10)
end if
end for
end loop |
|
|
|
|
|
Tony
|
Posted: Tue May 08, 2012 6:03 pm Post subject: RE:Request Turing Help |
|
|
It seems that you were meaning to ask some question, but forgot to post it. Is there a particular problem you are having? |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
Ahaurgoon
|
Posted: Tue May 08, 2012 6:13 pm Post subject: RE:Request Turing Help |
|
|
Well we want this to be a triangular shape that can be controlled by the user using the arrow keys, but when we try and do the above program it makes the triangle go at an angle and when you let go of the key, back to the starting point. We want it to go the correct way (right arrow = triangle goes right) and to stay at same position where it was left off. How would we make it so that it would do those things? |
|
|
|
|
|
Raknarg
|
Posted: Tue May 08, 2012 6:23 pm Post subject: RE:Request Turing Help |
|
|
It's doing exactly what you told it to. You have a loop that resets the variables each time it goes through the loop again. Then look at how your changing the variables. What do you get when you graph the line y = x? |
|
|
|
|
|
Ahaurgoon
|
Posted: Wed May 09, 2012 4:50 pm Post subject: RE:Request Turing Help |
|
|
I'm sorry, we aren't very good at this :/ I'm understanding what you are saying but I literally have no idea how to fix it so that it works. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Wed May 09, 2012 5:48 pm Post subject: RE:Request Turing Help |
|
|
Good. You wouldn't learn much if you were doing only things that you already knew how to do.
First, you'd need to understand exactly what you wrote; typically by stepping through the program and running it in your head. If you have trouble keeping up with where the code is going, debug statements such as
code: |
put "I'm now here!"
delay(1000)
|
would help with tracking code flow. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
Amarylis
|
Posted: Wed May 09, 2012 8:26 pm Post subject: RE:Request Turing Help |
|
|
There's also debugger controls if you feel comfortable enough. You can toggle it to stop when the code hits a certain line, track the code, etc |
|
|
|
|
|
|
|