
-----------------------------------
orbez
Sat Dec 07, 2013 7:35 pm

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)



 %Border 
    if X = maxx - (R1 + 1) then
        DX := 0
    end if
    if Y = maxy - (R1 + 1) then
        DY := 0
    end if
%Movement/speed
    if hasch then
        getch (key)
        if ord (key) = 205 then
            DX := speed
            DY := 0
        elsif ord (key) = 203 then
            DX := -speed
            DY := 0
        elsif ord (key) = 200 then
            DX := 0
            DY := speed
        elsif ord (key) = 208 then
            DX := 0
            DY := -speed
        end if
    end if




Please specify what version of Turing you are using
4.1.1

-----------------------------------
Insectoid
Sat Dec 07, 2013 7:39 pm

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 