Computer Science Canada lag problem? or something else? |
Author: | freally [ Fri Apr 25, 2008 10:56 pm ] |
Post subject: | lag problem? or something else? |
I'm making a program similar to the helicopter one, where you fly up and down and try to avoid the bricks... its not done yet, (no collisions or boundaries) but i noticed when i was testing it out, the screen like flickers, i dunno if thats me, something wrong with my code, or just lag... here is the code so far... its not very efficient, just starting to learn turing, so i don't know everything yet no comment lines either ![]() %race_car_game var timed : real := 4 var distance : int := 0 var font1 : int var x, y : int var start : int := 0 var ready : string var chars : array char of boolean var box : int := maxx var z : int := 0 var w : int := 0 var box2 : int var box3 : int := maxx var box4: int x := 100 y := 100 var r:int:= 0 randint (box4, 100, maxy div 3 + maxy div 3 + 15) randint (box2, 100, maxy div 3 + maxy div 3 + 15) font1 := Font.New ("comicsans:10") locate (1, 1) put "Are You Ready?!? (yes/no)" get ready if ready = "yes" or ready = "Yes" or ready = "y" or ready = "Y" or ready = "YES" then loop timed := timed - 1 locate (1, 1) put "Time: " .. put timed delay (1000) exit when timed = 0 end loop timed := 0 loop cls start := 1 r:= r + 5 if r > 220 and z < 630 then drawfillbox (box - z, box2, box - 65 - z, box2 + 25, black) z := z + 8 end if if z >= 630 then z := 0 randint (box2, 100, maxy div 3 + maxy div 3 + 15) end if if w < 630 then drawfillbox (box3 - w, box4, box3 - 65 - w, box4 + 25, black) w := w + 8 end if if w >= 630 then w := 0 randint (box4, 100, maxy div 3 + maxy div 3 + 15) end if drawfillbox (0, 35, maxx, maxy div 3 - 50, black) drawfillbox (0, maxy div 3 + maxy div 3 + 50, maxx, maxy, black) Input.KeyDown (chars) if chars (KEY_UP_ARROW) then y := y + 7 end if if chars (KEY_DOWN_ARROW) then y := y - 7 end if drawfilloval (x, y, 15, 15, red) if start = 1 then timed := timed + .01 locate (24, 18) put "Time: " .. put timed distance := distance + 1 locate (25, 18) put "Distance: " .. put distance end if drawfillbox (0, maxy div 2 + 5, maxx, maxy div 2 - 5, yellow) delay (10) end loop end if |
Author: | gitoxa [ Sat Apr 26, 2008 9:25 am ] |
Post subject: | Re: lag problem? or something else? |
setscreen("offscreenonly") View.Update The two together will stop the program from drawing anything new on screen until it runs the "View.Update" line. So you'll want to use that somewhere near the end of your loop. the setscreen just goes at the top of your code. |
Author: | freally [ Sat Apr 26, 2008 9:36 am ] |
Post subject: | Re: lag problem? or something else? |
THANK YOU SOO MUCH! |