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

Username:   Password: 
 RegisterRegister   
 Need help with Movement
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
santabruzer




PostPosted: Sat Nov 22, 2003 8:16 pm   Post subject: Need help with Movement

Here.. Let's say i have a program that start out with something like this:
code:

import GUI in "%oot/lib/GUI"
var x : array 1 .. 4 of int := init (155, 165, 160, 160)
var y : array 1 .. 4 of int := init (0, 0, 0, 5)
var chars : array char of boolean
var line :int
setscreen ("graphics:320;320")
loop
Input.KeyDown (chars)
line := GUI.CreateLine (x(1), y(1), x(2), y(2), 0)
line := GUI.CreateLine (x(3), y(3), x(4), y(4), 0)
        if chars (KEY_RIGHT_ARROW) then
            for i : 1..4
                x(i) := x(i) + 1
                delay(3)
                cls
                drawline (x(1), y(1), x(2), y(2), 1)
                drawline (x(3), y(3), x(4), y(4), 1)
            end for
        end if
        if chars (KEY_LEFT_ARROW) then
            for i : 1..4
                x(i) := x(i) - 1
                delay(3)
                cls
                drawline (x(1), y(1), x(2), y(2), 1)
                drawline (x(3), y(3), x(4), y(4), 1)
            end for
        end if
end loop


I think the GUI is pointless here.. but anywho.. what can i do instead of "cls"?
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Sat Nov 22, 2003 9:11 pm   Post subject: (No subject)

what the Shocked

GUI is used to draw lines... which is pointless Confused

anyways, instead of cls, you can just redraw the screen. which would be
code:

Draw.FillBox(0,0,maxx,maxy,white)
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Blade




PostPosted: Sat Nov 22, 2003 10:16 pm   Post subject: (No subject)

well, it seems like you're trying to get rid of flicker... and you obviously are using turing 4.x so you can use

setscreen("offscreenonly")
and
View.Update

this will get rid of your flicker.
the offscreenonly sets the the program so that you update the screen with the command View.Update. so whenever you call View.Update the screen will refreash all at once, instead of refreashing every time you put something out.
santabruzer




PostPosted: Sat Nov 22, 2003 11:08 pm   Post subject: (No subject)

Thanx.. that explanation clears it all... Very Happy
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  [ 4 Posts ]
Jump to:   


Style:  
Search: