Computer Science Canada Making a Border in turing |
Author: | orbez [ Sat Dec 07, 2013 7:35 pm ] | ||
Post subject: | Making a Border in turing | ||
What is it you are trying to achieve? I am attempting to make a game kinda like pac man. In this game a yellow dot can not leave the screen. What is the problem you are having? I made a border but you can still exit the screen by spamming/holding an arrow key down, is there a way to change that? Describe what you have tried to solve this problem I have tried bouncing the dot back by making the delta x and/or delta y the opposite but since then I have been specific introductions that the dot much stop at the border. I also expanded the border but all that does is just delay the out come. (only included part of my program as it is somewhat long) Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Please specify what version of Turing you are using 4.1.1 |
Author: | Insectoid [ Sat Dec 07, 2013 7:39 pm ] |
Post subject: | RE:Making a Border in turing |
If pac-man ever crosses the border, simply teleport him back to the correct side of it. If the left border is x = 0, then 'if (pacmanX <0) then packmanX := 0'. Tweak to suit your own game. |
Author: | orbez [ Sat Dec 07, 2013 7:52 pm ] |
Post subject: | Re: Making a Border in turing |
I have never thought about it that way, thanks man. |
Author: | Zren [ Sat Dec 07, 2013 8:01 pm ] | ||
Post subject: | RE:Making a Border in turing | ||
Don't move Pacman until you are sure the destination is in bounds. Eg:
This way, he's never out of bounds to begin with. Unless of course the walls move and the bounds change from one iteration to the next. |
Author: | Zren [ Sun Dec 08, 2013 2:25 pm ] | ||
Post subject: | RE:Making a Border in turing | ||
Version without records/types in case they threw you for a loop.
More on records/types: There's the Turing Documention on those keywords: record, type There's also this tutorial Records Part I Declaration and other Introductory Concepts which is part of the greater tutorial called The Turing Walkthrough. |
Author: | orbez [ Sun Dec 08, 2013 3:44 pm ] |
Post subject: | Re: Making a Border in turing |
Yeah, this is allot better, I came up with something similar but your code is much smaller and simpler, thanks. |