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

Username:   Password: 
 RegisterRegister   
 How do i get the circle to move?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
DBZ




PostPosted: Thu Nov 20, 2003 4:07 pm   Post subject: How do i get the circle to move?

i need to move the circle in the middle of the screen faster and i just can't get the circle out of the left side of the screen. i have attatched my program for u to see the problem!
Thanx.



Mubeen_Chap 8 (6).t
 Description:

Download
 Filename:  Mubeen_Chap 8 (6).t
 Filesize:  464 Bytes
 Downloaded:  208 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Mazer




PostPosted: Thu Nov 20, 2003 4:42 pm   Post subject: (No subject)

oh my...
let's start with:
code:

for row : 1 .. 25
    put repeat (" ", 80) ..
end for

it seems to me, that you're trying to use this to clear the screen, because that's all it would be useful for. it's be better to use cls but at the beginning of the program it's useless because it doesn't have anything to clear.

code:

proc circle
    drawfilloval (row, column, 20, 20, magenta)
end circle

it doesn't make much sense to use a procedure for only one line of code, but that's up to you to decide. the main problem here is that you're trying to use the row and column for the x and y coordinates of the center of the circle. that's what's causing the circle to just move around the bottom left corner. it'd be better to use x and y variables to keep track of the position of the circle on the screen in pixels.

code:

exit when column < 1 or column > 80
            or row < 1 or row > 25

that exit statement by itself isn't good for much because once it exits the inner loop, the column is < 1 or > 80 or the row < 1 or > 25 so you're going to be stuck in an endless loop. you should have some way to reset the variables after exiting that loop.

also, you had the delay in the wrong spot. you should draw, delay, then clear the screen.

try something like this:
code:

%This program is suppose to view a circle moving around in the screen like
%smoke motion..
var x := maxx div 2
var y := maxy div 2
proc circle
    drawfilloval (x, y, 20, 20, magenta)
end circle
setscreen ("nocursor")

loop
    loop
        exit when x < 0 or x > maxx or y < 0 or y > maxy
        circle
        delay (50)
        cls
        randint (x, x - 15, x + 15)
        randint (y, y - 15, y + 15)
    end loop
    x := maxx div 2
    y := maxy div 2
end loop


it doesn't really look like a smoke motion, but maybe you can get something closer to what you wanted if you play around with it a bit. and feel free to ask me for help if you have trouble with any of that.
Andy




PostPosted: Fri Nov 21, 2003 6:59 pm   Post subject: (No subject)

wow, nick, you just love to show off your madd turing skillz eh? lol jk
Tendulkar




PostPosted: Thu Dec 04, 2003 10:26 pm   Post subject: Re: How do i get the circle to move?

Here is your program Very Happy


Circle.t
 Description:

Download
 Filename:  Circle.t
 Filesize:  1.43 KB
 Downloaded:  221 Time(s)

Andy




PostPosted: Thu Dec 04, 2003 10:29 pm   Post subject: (No subject)

DBZ do you go to massey?
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  [ 5 Posts ]
Jump to:   


Style:  
Search: