Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 How to make the red dot stop at the edge of the window and not go out.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
puthelloworld




PostPosted: 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



Turing:


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



Moving dot ASDF.t
 Description:

Download
 Filename:  Moving dot ASDF.t
 Filesize:  504 Bytes
 Downloaded:  103 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: