Turing Game Problem [Flashing screen with multiple loops]
Author |
Message |
sliverofshadows475
|
Posted: Mon Dec 08, 2008 1:23 pm Post subject: Turing Game Problem [Flashing screen with multiple loops] |
|
|
Hey guys, I have a problem with having multiple things in one loop process. I searched the site, and I looking briefly through topics that looked relevant, nothing seemed to help, so here I am asking you guys. Basically, what happens is:
When I run the program, the screen flashes a lot, I guess when it's repeatedly drawing the pictures. Here's my syntax.
Turing: |
var mypic : int: = Pic.FileNew ("C:/Users/Owner/Documents/Turing 4.1.1/Final Summitive Evaluation/heavycruiser1.jpg")
var mypic2 : int: = Pic.FileNew ("C:/Users/Owner/Pictures/spaveinvaders101.jpg")
var mypic3 : int: = Pic.FileNew ("C:/Users/Owner/Pictures/spaveinvaders102.jpg")
var mypic4 : int: = Pic.FileNew ("C:/Users/Owner/Pictures/spaveinvaders103.jpg")
var mypic5 : int: = Pic.FileNew ("C:/Users/Owner/Pictures/spaveinvaders104.jpg")
var mypic6 : int: = Pic.FileNew ("C:/Users/Owner/Pictures/spaveinvaders105.jpg")
var x : int := 300
var y : int := 50
var x1 : int := 50
var y1 : int := 300
var keys : array char of boolean
loop
Input.KeyDown (keys )
if keys (KEY_LEFT_ARROW) and x > 0 then
x - = 1
end if
if keys (KEY_RIGHT_ARROW) and x < maxx then
x + = 1
end if
if keys (' ') then
drawline (x+ 10, 510,x+ 10, 95, red)
delay(7)
drawline (x+ 10, 510,x+ 10, 95, white)
end if
Pic.Draw (mypic,x- 20,y- 20, 0)
delay (4)
Pic.Draw (mypic2, 50, 300, 0)
delay (4)
Pic.Draw (mypic3, 150, 300, 0)
delay (4)
Pic.Draw (mypic4, 250, 300, 0)
delay (4)
Pic.Draw (mypic5, 350, 300, 0)
delay (4)
Pic.Draw (mypic6, 450, 300, 0)
delay (4)
cls
end loop
|
Any help would be greatly appreciated. Thanks!
EDIT: I just found out about offscreenonly, but I'm not really sure of where to put View.Update... |
|
|
|
|
|
Sponsor Sponsor
|
|
|
TheGuardian001
|
Posted: Mon Dec 08, 2008 3:08 pm Post subject: Re: Turing Game Problem [Flashing screen with multiple loops] |
|
|
What you're looking for is offscreen drawing. to use this, you need to things
code: |
View.Set("offscreenonly")
|
this sets offscreen drawing mode. all images are drawn offscreen and are invisible to the user
and
code: |
%all of your drawing code goes first
View.Update
|
this takes the everything that has been drawn offscreen and draws it as a solid image on screen where the user can see it.
You want this to come after you've drawn all of you're pictures, but before clearing the screen |
|
|
|
|
|
Tony
|
Posted: Mon Dec 08, 2008 3:28 pm Post subject: Re: Turing Game Problem [Flashing screen with multiple loops] |
|
|
sliverofshadows475 @ Mon Dec 08, 2008 1:23 pm wrote: I'm not really sure of where to put View.Update...
as TheGuardian001 points out, View.Update typically goes right before the cls.
The fact that you have multiple delays inside your loop, is not helping the issue of flickering. If you need to slow down the animation loop, use delay once. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
sliverofshadows475
|
Posted: Mon Dec 08, 2008 7:12 pm Post subject: Re: Turing Game Problem [Flashing screen with multiple loops] |
|
|
Thanks guys, you've really helped me. |
|
|
|
|
|
syntax_error
|
Posted: Mon Dec 08, 2008 9:15 pm Post subject: RE:Turing Game Problem [Flashing screen with multiple loops] |
|
|
Just as a side note, you should keep all your pictures in one folder which contains the .t file as well, that way when you move your program as long as everything is in the folder its set to go. |
|
|
|
|
|
|
|