
-----------------------------------
ABCGUY
Tue Apr 27, 2004 8:03 pm

Why does my program suddenly get laggy?
-----------------------------------
Hi i'm new and i'm wondering if i could get some help.

For my final project (a city) i'm using this animation as my backgroud:

View.Set ("offscreenonly") 
colorback (blue) 
cls 

type SnowType : 
    record 
        X, Y, Spd, Size : int 
    end record 

var Snow : array 1 .. 100 of SnowType 

for rep : 1 .. 100 
    Snow (rep).X := Rand.Int (5, 645) 
    Snow (rep).Y := Rand.Int (5, 475) 
    Snow (rep).Spd := Rand.Int (1, 6) 
    Snow (rep).Size := Snow (rep).Spd 
end for 
var iCount : int := 0 
for caunt: 1..30 
    var num:int:=0
    delay (10) 
    for rep : 1 .. 100 
        Snow (rep).Y -= Snow (rep).Spd 
        if Snow (rep).Y < Snow (rep).Size then 
            Snow (rep).Y := Rand.Int (475, 575) 
        end if 
        if iCount = 4 then 
            Snow (rep).X += Rand.Int (-1, 1) 
        end if 
        drawfillstar (Snow (rep).X, Snow (rep).Y, Snow (rep).X + Snow (rep).Size, Snow (rep).Y + Snow (rep).Size, white) 
    end for 
    if iCount = 4 then 
        iCount := 0 
    else 
        iCount += 1 
    end if
    View.Update 
    cls 

but when my program goes here:

end for

for c: 1..3
drawfillbox (300,151,310,175,yellow)
drawfillbox (320,406,330,431,yellow)
for count: 1..256 by 2
drawfillbox (300,175+count,310,175,yellow)
drawfillbox (300,150+count,310,151,9)
drawfillbox (320,431-count,330,431,9)
drawfillbox (320,406-count,330,407,yellow)
drawfillbox (320,431-count,330,431,9)
delay (25)
end for
drawfillbox (240, 467, 275, 490, yellow)
delay (250)
drawfillbox (240, 467, 275, 490, blue)
delay (250)
drawfillbox (275, 467, 305, 490, yellow)
delay (250)
drawfillbox (275, 467, 305, 490, blue)
delay (250)
drawfillbox (305, 467, 335, 490, yellow)
delay (250)
drawfillbox (305, 467, 335, 490, blue)
delay (250)
drawfillbox (335, 467, 365, 490, yellow)
delay (250)
drawfillbox (335, 467, 365, 490, blue)
delay (250)
drawfillbox (365, 467, 400, 490, yellow)
delay (250)
drawfillbox (365, 467, 400, 490, blue)
for count: 1..256 by 2
drawfillbox (300,406-count,310,407,yellow)
drawfillbox (300,431-count,310,431,9)
drawfillbox (320,175+count,330,175,yellow)
drawfillbox (320,150+count,330,151,9)
delay (25)
end for
drawfillbox (240, 467, 275, 490, yellow)
delay (250)
drawfillbox (240, 467, 275, 490, blue)
delay (250)
drawfillbox (275, 467, 305, 490, yellow)
delay (250)
drawfillbox (275, 467, 305, 490, blue)
delay (250)
drawfillbox (305, 467, 335, 490, yellow)
delay (250)
drawfillbox (305, 467, 335, 490, blue)
delay (250)
drawfillbox (335, 467, 365, 490, yellow)
delay (250)
drawfillbox (335, 467, 365, 490, blue)
delay (250)
drawfillbox (365, 467, 400, 490, yellow)
delay (250)
drawfillbox (365, 467, 400, 490, blue)
end for

to another animation, it gets really laggy

I dunno whats wrong, i'm a real newbie, can someone help me plz.

-----------------------------------
Raugrist
Wed Apr 28, 2004 6:35 am


-----------------------------------
Two things. First of all, you've got an entire shitload, maybe even two shitloads of delays in that program. But that isn't even what's causing the "lag". Which leads me to number two. You're program isn't really lagging (much). It's just that you don't have any View.Update lines in the code to update the screen so the program looks like it just isn't doing anything.

-----------------------------------
ABCGUY
Wed Apr 28, 2004 7:32 pm


-----------------------------------
Thanks, i'll try that.

Edit: Thanks a lot i fixed the problem.
