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

Username:   Password: 
 RegisterRegister   
 View.Update + background trouble
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
xevious




PostPosted: Sat Nov 12, 2005 9:52 am   Post subject: View.Update + background trouble

I'm having a little trouble with View.Update.
When I use cls it wipes my background, and I don't know any way around it.
Here's what I have so far:
code:

var y : int := 0
var mypic :int := Pic.FileNew ("mypic.bmp")
var bg :int :=Pic.FileNew ("bg.bmp")
proc drawmypic
      Pic.Draw (mypic,190,y,picMerge)
end drawmypic
    Pic.Draw (bg,0,0,picCopy)
procedure move
loop
View.Set ("offscreenonly")
cls
drawmypic
    delay (2)
drawmypic
    y += 1
    exit when y = 400
    View.Update
end loop
y := 0
end move
move
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Sat Nov 12, 2005 10:01 am   Post subject: (No subject)

Don't put View.Set ("offscreenonly") inside a loop. It's not necessary.

Indent! Try pressing F2 in the turing editor.

Why draw your picture twice? Once before the delay and once after. Drawing it once is enough.

If you want your background to stay, you've got to redraw it, much like you are redrawing "mypic" inside the loop.
ZeroPaladn




PostPosted: Mon Nov 14, 2005 11:19 am   Post subject: (No subject)

just a question, why do you have procedures with 1 line of code in it, especially when you run that procedure only once? Do what cervantes says, and put the picture in the code, like so (this is jsut an example)

code:

View.Set ("offscreenonly,graphics:200;200") %we set the screen to
%offscreenonly so we can call back the picture from the inactive screen
%to the active (seen) screen using View.Update

var pic : int := Pic.FileNew ("pic.bmp") %we declare the picture here

loop
cls %we clear the active screen
Pic.Draw (pic, 0, 0, picMerge) %we draw the picture in the inactive screen
View.Update %and move it to the active screen
end loop


Hope this sheds some light on the subject.
iker




PostPosted: Mon Nov 14, 2005 7:14 pm   Post subject: (No subject)

write a code that has a loop such as
code:

View.Set ("offscreenonly") %plus any other modes you like
var y : int := 0
%processes/procedures such as movement and background
procedure background
    drawfillbox (0, 0, maxx, 40, brightgreen)
    drawfillbox (0, 41, maxx, maxy, brightblue)
    %you can replace these with your picture
end background

procedure movement
    y += 1
    %any other movement too
end movement

procedure object
    drawoval (190, y, 5, 5, white)
    %you can replace this with a picture
end object

loop
    %go to procedures
    background
    movement
    object
    View.Update
    delay (10)
    cls
end loop

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: