
-----------------------------------
antiLogic
Wed Jun 10, 2009 1:34 pm

Animation Flickering...
-----------------------------------
What is it you are trying to achieve?
Have the autonomous planes fly and the keyboard control plane fly without flickering

What is the problem you are having?
The autonomous planes flicker whenever the keyboard control plane stops moving. Also, the animation in general is a bit choppy.

Describe what you have tried to solve this problem
I've tried having 2 procedures draw the plane step by step at the same time using a fork procedure. I know forks are problematic but its the best way for me to attack my problem.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)



setscreen ("graphics:800;600")
View.Set ("offscreenonly")
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
var pic := Pic.FileNew ("plane_sprite.bmp")
var picRotated : array 0 .. 35 of int
for i : 0 .. 35
    picRotated (i) := Pic.Rotate (pic, i * 10, Pic.Width (pic) div 2, Pic.Height (pic) div 2)
end for
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Picture declaration and array to hold rotated images
proc plane_flight
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    var r : int := Rand.Int (0, 35)
    var chars : array char of boolean
    var tmpShip : int := picRotated (r)
    var ctr : int := r
    var x, y : real := Rand.Int (20, 400)
    loop
        delay (20)
        %Exit when plane reaches border
        exit when x >= 600 or x  0 and x < 300 and y > 0 and y < 400 then
            delay (10)
            landingCTR += 1
        end if

        Pic.SetTransparentColor (tmpShip, white)
        Pic.ScreenLoad ("airport.bmp", 0, 0, picCopy)
        Pic.Draw (tmpShip, round (x), round (y), picMerge)
        % exit when x > 100 and x < 1000 and y > 100 and y < 200
        View.Update
    end loop
end plane_control


proc refresh
    % var picNew := Pic.New (0, 0, maxx, maxy)
    % Pic.SetTransparentColor (picNew, white)
    % Pic.ScreenLoad ("airport.bmp", 0, 0, picCopy)
    % Pic.Draw (picNew, 0, 0, picMerge)
    % Pic.Free (picNew)
    View.Update
end refresh

process processrefresh
    loop
        refresh
        delay (10)
    end loop
end processrefresh

process processplane_control
    plane_control
end processplane_control

process processplane_flight
    loop
        plane_flight
        delay (5000)
    end loop
end processplane_flight

fork processplane_control
fork processplane_flight
fork processplane_flight
%fork processrefresh


Please specify what version of Turing you are using
4.1.1

-----------------------------------
Tony
Wed Jun 10, 2009 4:50 pm

RE:Animation Flickering...
-----------------------------------
You have 3 View.Updates in your code, which is a problem. The entire point of View.Update is to have it in only one place.

I figure that
[code]
loop
        refresh
        delay (10)
    end loop 
[/code]
is causing major problems, as it would randomly draw partially rendered screens.
