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

Username:   Password: 
 RegisterRegister   
 Why does my program suddenly get laggy?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ABCGUY




PostPosted: Tue Apr 27, 2004 8:03 pm   Post subject: 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:

code:
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:

code:
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.
Sponsor
Sponsor
Sponsor
sponsor
Raugrist




PostPosted: Wed Apr 28, 2004 6:35 am   Post subject: (No subject)

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




PostPosted: Wed Apr 28, 2004 7:32 pm   Post subject: (No subject)

Thanks, i'll try that.

Edit: Thanks a lot i fixed the problem.
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  [ 3 Posts ]
Jump to:   


Style:  
Search: