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

Username:   Password: 
 RegisterRegister   
 Help with Erasing while dragging objects
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Sceyef




PostPosted: Fri Dec 12, 2014 7:24 pm   Post subject: Help with Erasing while dragging objects

so like, I have never liked animating in turing.
Here's my code. It's a simple drag-an-object program. Primitive, as the object centers on your cursor and stuff, but it works.
code:

var x, y, button, a, b : int
a := 100
b := 100
var buttonpress : boolean := false
setscreen ("offscreenonly")
loop
    mousewhere (x, y, button)
    locate (1, 1)
    if x > a - 50 and x < a + 50 and y > b - 50 and y < b + 50 then
        if button = 1 then
            buttonpress := true
        else
            buttonpress := false
        end if
    end if
    if buttonpress = true then
        a := x
        b := y
    end if
    cls
    drawfillbox (a - 50, b - 50, a + 50, b + 50, red)
    View.Update
end loop


Now here's what I need: I am currently erasing the red square with CLS. Later I need to add a background. How can I do that? Try it yourself, but when I attempt to put the usual identical object with colorbg, there are.. problems..? Even If I make the object bigger. It doesn't erase properly. :/

halp
Sponsor
Sponsor
Sponsor
sponsor
Zren




PostPosted: Fri Dec 12, 2014 7:33 pm   Post subject: RE:Help with Erasing while dragging objects

Draw things that appear underneath first, then draw the thing on top second.

Turing:

cls % Begin drawing a new frame
Draw.FillBox(0, 0, maxx, maxy, black) % Draw background
Draw.Oval(x, y, r, r, red) % Draw foreground
View.Update() % Done drawing the frame, show it on screen.
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: