
-----------------------------------
Velocity
Thu Dec 08, 2011 7:30 pm

heavy flickering problem
-----------------------------------
What is it you are trying to achieve?
Remove the flickering in my program...

What is the problem you are having?
The screen is flickering like crrrrazy

Describe what you have tried to solve this problem
View.UpdateArea (0, 0, maxx, maxy) i tried to place it everywhere, still doesnt work.



import GUI

procedure TheGame
    setscreen ("graphics:700;700")
    %---------------------------
    %Player Co-ords            %
    var x1, y1, x2, y2 : int   %
    x1 := 250                  %
    y1 := 25                   %
    x2 := 350                  %
    y2 := 50                   %
    %---------------------------

    %---------------------------
    %Ball Co-ords              %
    var ballx, bally : int     %
    ballx := 512               %
    bally := 200               %
    %---------------------------

    %----------------------------------------
    %Game Basics                            %
    var lives : int := 3                    %
    var score : int := 0                    %
    var timeElapsed : int := Time.Elapsed   %
    %----------------------------------------

    %----------------------------------------------------
    %Boundaries (paddle + ball)                         %
    var boundary_x1 : int := ((maxx div maxx) - 1) + 20 %
    var boundary_x2 : int := maxx - 20                  %
    var boundary_y1 : int := maxy - 20                  %
    var boundary_y2 : int := ((maxy div maxy) - 1) + 20 %
    %----------------------------------------------------

    var arrowKeys : array char of boolean
    loop
    drawfillbox (0, maxy - 25, maxx, maxy,48)
    locate (1,10)
        put "Lives ", lives
        locate (1, 30)
        put "Score: ", score
        locate (1, 50)
        put "Game Time : ", Time.Elapsed / 1000
        Input.KeyDown (arrowKeys)

        if arrowKeys (KEY_RIGHT_ARROW) then
            x1 += 5
            x2 += 5
        end if
        if arrowKeys (KEY_LEFT_ARROW) then
            x2 -= 5
            x1 -= 5
        end if

        drawfillbox (x1, y1, x2, y2, red)
        delay (15)
        cls
        drawbox (20, 20, maxx - 20, maxy - 20, 51)
        drawbox (5, 5, maxx - 5, maxy - 5, 51)
        drawfillbox (250, 900, 350, 925, 101)
        drawfillbox (20, 355, maxx - 20, 360, 51)
        drawfilloval (ballx, bally, 15, 15, 48)
        drawfill (maxx - 15, maxy - 15, 71, 51)
        if arrowKeys (KEY_ESC) then
            cls
            exit
        end if
    end loop
    View.UpdateArea (0, 0, maxx, maxy)
end TheGame

procedure Instructions
    colorback (16)
    color (48)
    cls
    locate (4, 1)
    put "The objective of the game is..."
    locate (7, 1)
    color (58)
    put "to destroy all of the blocks on your side of the screen (bottom)"
    locate (10, 1)
    color (73)
    put "Before the computer destroys all of his blocks on his side of the screen (top)"
    locate (13, 1)
    color (81)
    put "You will use the 'Left' and 'Right' Arrow keys to move left and right"
    locate (16, 1)
    color (96)
    put "Good Luck and go smash some blocks. HINT : You only have 3 Lives!"
end Instructions

procedure TheTitleScreen
    var game_Button : int := GUI.CreateButton (300, 275, 0, "Click To Play!", TheGame)
    var instruction : string
    locate (18, 10)
    put "Please hold 'Click to Play' while you type your answer below!"
    locate (20, 10)
    put "You will be redirected to the instructions so keep holding your mouse."
    locate (22, 10)
    put "Or drag away from 'Click to Play' then read and Click it afterwards."
    locate (24, 10)
    put "Do you want to see the game Instructions? " ..
    get instruction
    if instruction = "yes" then
        Instructions
    else
        Instructions
    end if
end TheTitleScreen

procedure returnBack
    var go_back : char := "n"
    loop
        get go_back
        if go_back = "y" then
            TheTitleScreen
        end if
    end loop
end returnBack

TheTitleScreen

loop
    exit when GUI.ProcessEvent
end loop



Please specify what version of Turing you are using
4.1.1a

-----------------------------------
Tony
Thu Dec 08, 2011 7:55 pm

RE:heavy flickering problem
-----------------------------------
If you are doing fullscreen anyway, might as well be just [tdoc]View.Update[/tdoc] -- read the docs to find what you are missing.

-----------------------------------
Velocity
Thu Dec 08, 2011 8:17 pm

RE:heavy flickering problem
-----------------------------------
Tony i checked out that document but i tried putting those everywhere still doesnt work... where exactly or how exactly do i have to put the View.Set ("offscreenonly")
and View.Update?

-----------------------------------
Tony
Thu Dec 08, 2011 8:21 pm

RE:heavy flickering problem
-----------------------------------
You were indeed missing View.Set ("offscreenonly"). Good.

You should defer to the documentation of View.Update and View.Set for examples, or to the tutorial linked to from Turing Walkthrough.

-----------------------------------
Insectoid
Thu Dec 08, 2011 10:01 pm

RE:heavy flickering problem
-----------------------------------
"putting those everywhere" is exactly the wrong thing to do.

-----------------------------------
Aange10
Fri Dec 09, 2011 1:11 am

RE:heavy flickering problem
-----------------------------------
Doing what normal, smart people would, you'd look at the stickies & announcements on the forums. Namely the FAQ, which completely answers your question.

http://compsci.ca/v3/viewtopic.php?t=12610

-----------------------------------
chipanpriest
Fri Dec 09, 2011 6:41 am

Re: heavy flickering problem
-----------------------------------
First of all, your View.Update ("offscreenonly") should be at the very beginning of your code, before anything happens. Then you put your View.Update after your drawfillbox's,drawfilloval's,put's,ect (anything thats visible on the screen) 