Computer Science Canada How to make the red dot stop at the edge of the window and not go out. |
Author: | puthelloworld [ Wed Dec 10, 2014 9:36 am ] | ||
Post subject: | How to make the red dot stop at the edge of the window and not go out. | ||
What is it you are trying to achieve? I am trying to make a red dot that can move and it stops when it hits the red of the screen. What is the problem you are having? I cannot seem to get the red dot to stop when it hits the edge of the window. Describe what you have tried to solve this problem <Answer Here> I tried using a if statement but it didnt work. to limit the maxx and maxy. Post any relevant code (You may choose to attach the file instead of posting the code if it is too long) <Answer Here> var x : int := 319 var y : int := 199 var w, a, s, d: char setscreen ("graphics:max;max,") drawfilloval (x, y, 30, 30, red) loop drawbox (0, 0, maxx, maxy, black) var c : char := getchar delay (100) if c = 'w' then y := y + 10 elsif c = 'a' then x := x - 10 elsif c = 's' then y := y - 10 elsif c = 'd' then x := x + 10 end if cls drawfilloval (x, y, 30, 30, red) end loop
Please specify what version of Turing you are using <Answer Here> 4.41 |
Author: | DemonWasp [ Wed Dec 10, 2014 10:21 am ] |
Post subject: | RE:How to make the red dot stop at the edge of the window and not go out. |
Quote: I tried using a if statement but it didnt work. to limit the maxx and maxy.
Can we see the if statement? If you deleted it, try writing it again -- that is the correct approach. If you run into problems with it not working as you expect, post your updated code here. |