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

Username:   Password: 
 RegisterRegister   
 images disappear when snow falls...
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Ray




PostPosted: Sat Jan 08, 2005 7:02 pm   Post subject: images disappear when snow falls...

code:
var x5,y5:int 
loop
for i:1..1000
x5 := Rand.Int(1,maxx)
y5 := Rand.Int(1,maxy)
drawdot(x5,y5,white)
end for
delay(100)
cls


after dis steps, my other images disappeared, i can only see the snow

pls help
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Sat Jan 08, 2005 7:10 pm   Post subject: (No subject)

Well, if I understand your... question... at all, I would reply by saying that you should redraw your "other images" each time through the loop. That is, put the drawing for the other images inside your loop.
Ray




PostPosted: Sat Jan 08, 2005 7:27 pm   Post subject: (No subject)

i want to make a star move around the screen, buh i have to use "cls" in the for loop...buh it'll also clear my other images
Cervantes




PostPosted: Sat Jan 08, 2005 7:38 pm   Post subject: (No subject)

There are two ways to do this:
1.) use a cls, then redraw everything.
2.) draw what you want, and erase what you want by drawing it again (after the View.Update and delay), only in the background colour.

Ex 1.)
code:

setscreen ("offscreenonly")
var x := 0
loop
    x += 5
    cls
    drawfilloval (x, maxy div 2, 10, 10, blue)
    View.Update
    delay (10)

    exit when x >= maxx
end loop


Ex. 2)
code:

setscreen ("offscreenonly")
var x := 0
loop
    x += 5
    drawfilloval (x, maxy div 2, 10, 10, blue)
    View.Update
    delay (10)
    drawfilloval (x, maxy div 2, 10, 10, white)

    exit when x >= maxx
end loop
Ray




PostPosted: Sat Jan 08, 2005 7:57 pm   Post subject: (No subject)

i got the snow and other pics in a loop, buh everyrthing will clear away if i include the code below... the cls will clear everything else wen it moves

%star
for i : 1 .. 70
Draw.FillStar (480 + i, 140, 550 + i, 200, yellow)
delay (10)
cls
end for
Cervantes




PostPosted: Sat Jan 08, 2005 10:16 pm   Post subject: (No subject)

If you're trying to move that star across the screen, don't do it in a for loop. Because, as you said, everything else will get cleared if you do it like that. Instead, create a variable to store the x position of the star. Each time through the loop, increase the x position of the star by whatever amount you want (to match what the for loop was doing, increase it by one each time). Then, to make the star stop moving, you could wrap the x += 1 (that's the same as x := x + 1) in an if statement.
code:

if x < some_integer then
   x += 1
end if

Hope that helps

(btw, use [ code][ /code] tags please Smile
Ray




PostPosted: Sun Jan 09, 2005 2:01 pm   Post subject: (No subject)

im confused on wut u said...

code:
for i : 1 .. 70
Draw.FillStar (480 + i, 140, 550 + i, 200, yellow)
delay (10)
cls
end for


...so wut do i take out to include the x position? cls?
Cervantes




PostPosted: Sun Jan 09, 2005 6:18 pm   Post subject: (No subject)

Ray wrote:

...so wut do i take out to include the x position? cls?

Try it. Wink

You'll quite quickly see that taking the cls out only makes things worse. No, what I've been trying to tell you is that you don't want to have a for loop (that's inside your main loop) with drawing/cls/delays inside it, at all. Because, if you do, nothing will work simotaneously.
The best advice I can give is this: think about the program logically and linearly. Think about it line by line. If you have trouble thinking like that, try running the program line by line (check the trace execution box on the debugger controls [click the run menu, click Show Debugger Menu. Then, click the debugger menu and click show debugger controls]).
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: