----------------------------------- Ahaurgoon Tue May 08, 2012 10:25 am 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 ----------------------------------- Dreadnought Tue May 08, 2012 10:41 am Re: Request Turing Help ----------------------------------- Well, you will need to check if the keys are pressed. For that have a look at the documentation for [tdoc]InputModule[/tdoc] and [tdoc]Keycodes[/tdoc]. For a triangle, if you don't know how to draw one, what you need is in [tdoc]DrawModule[/tdoc]. 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 Tue May 08, 2012 11:04 am RE:Request Turing Help ----------------------------------- There's actually a tutorial on thise, btw. Go look at The Turing Walkthrough. ----------------------------------- Ahaurgoon Tue May 08, 2012 5:58 pm 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 Tue May 08, 2012 6:03 pm 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? ----------------------------------- Ahaurgoon Tue May 08, 2012 6:13 pm 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 Tue May 08, 2012 6:23 pm 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 Wed May 09, 2012 4:50 pm 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. ----------------------------------- Tony Wed May 09, 2012 5:48 pm 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) [/code] would help with tracking code flow. ----------------------------------- Amarylis Wed May 09, 2012 8:26 pm 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