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

Username:   Password: 
 RegisterRegister   
 heavy flickering problem
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Velocity




PostPosted: Thu Dec 08, 2011 7:30 pm   Post subject: 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.

Turing:


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
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Dec 08, 2011 7:55 pm   Post subject: RE:heavy flickering problem

If you are doing fullscreen anyway, might as well be just View.Update -- read the docs to find what you are missing.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Velocity




PostPosted: Thu Dec 08, 2011 8:17 pm   Post subject: 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




PostPosted: Thu Dec 08, 2011 8:21 pm   Post subject: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Insectoid




PostPosted: Thu Dec 08, 2011 10:01 pm   Post subject: RE:heavy flickering problem

"putting those everywhere" is exactly the wrong thing to do.
Aange10




PostPosted: Fri Dec 09, 2011 1:11 am   Post subject: 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




PostPosted: Fri Dec 09, 2011 6:41 am   Post subject: 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) <-- you only put one View.Update after the code for ALL your visible things Very Happy hope it helps

example:

(wrong way - will flicker)
%----------------------------------------------------------------------------%

loop
drawfilloval (100,100,20,20,7) % <-- this would flicker like crazy
cls
end loop

%-----------------------------------------------------------------------------%


(right way - will not flicker)
%-----------------------------------------------------------------------------%

View.Set ("offscreenonly") % <-- at the beginning
loop
drawfilloval (100,100,20,20,7) % <-- You can put anything inbetween your "loop" and your "View.Update" and you can have
% more than one thing
View.Update % <-- After your drawfill's etc. and BEFORE your cls
cls
end loop

%------------------------------------------------------------------------------%
Velocity




PostPosted: Mon Dec 12, 2011 4:35 pm   Post subject: RE:heavy flickering problem

%Ilan Portman
%Grade 11 Final Project
%Brick Breaker vs AI
%December 9th, 2011
import GUI
View.Set ("graphics:638;690")
var PicID : int
var x : int := 700
var y : int := 500
PicID := Pic.FileNew ("ball02.jpg")
Pic.Draw (PicID, maxx div 2 - (638 div 2), maxy div 2 - (690 div 2), picCopy)
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 ball_x1, ball_x2, ball_y1, ball_y2 : int %
ball_x1 := 512 %
ball_y1 := 200 %
ball_x2 := 512 %
ball_y2 := 500 %
%------------------------------------------------

%----------------------------------------
%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 (5, maxy - 25, maxx - 5, 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

if x1 > 250 and x2 < 350 then
x1 := 100
elsif x1 < 250 and x2 > 350 then
x2 := 100
elsif y1 > 25 and y2 < 50 then
y1 := 25
elsif y1 < 25 and y2 > 50 then
y2 := 25
end if
if arrowKeys (KEY_ESC) then
cls
exit
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 (ball_x1, ball_y1, 15, 15, 48)
drawfill (maxx - 15, maxy - 15, 71, 51)


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


View.UpdateArea (0,0,maxx,maxy)



%%%% I PUT IT IN THERE AND IT STILL FLICKERS!

if ball_y1 < 25 then
lives -= 1
% put lives
end if
end loop
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 font1 : int
font1 := Font.New ("Arial:13")
assert font1 > 0
Pic.Draw (PicID, maxx div 2 - (638 div 2), maxy div 2 - (690 div 2), picCopy)
var game_Button : int := GUI.CreateButton (265, 275, 0, "Click To Play!", TheGame)
var instruction : string
locate (37, 4)
Font.Draw ("Please hold 'Click to Play' while you type your answer below!", 50, 150, font1, yellow)
locate (38, 4)
Font.Draw ("You will be redirected to the instructions so keep holding your mouse.", 50, 125, font1, green)
locate (39, 4)
Font.Draw ("Or drag away from 'Click to Play' then read and Click it afterwards.", 50, 75, font1, yellow)
locate (40, 4)
Font.Draw ("Do you want to see the game Instructions? ", 50, 40, font1, green)
locate (50, 47)
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
Sponsor
Sponsor
Sponsor
sponsor
Velocity




PostPosted: Mon Dec 12, 2011 4:43 pm   Post subject: RE:heavy flickering problem

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 ball_x1, ball_x2, ball_y1, ball_y2 : int %
ball_x1 := 512 %
ball_y1 := 200 %
ball_x2 := 512 %
ball_y2 := 500 %
%------------------------------------------------

%----------------------------------------
%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
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

if x1 > 250 and x2 < 350 then
x1 := 100
elsif x1 < 250 and x2 > 350 then
x2 := 100
elsif y1 > 25 and y2 < 50 then
y1 := 25
elsif y1 < 25 and y2 > 50 then
y2 := 25
end if
if arrowKeys (KEY_ESC) then
cls
exit
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 (ball_x1, ball_y1, 15, 15, 48)
drawfill (maxx - 15, maxy - 15, 71, 51)
View.UpdateArea (0,0,maxx,maxy)
Time.DelaySinceLast (50)
cls
end loop
Velocity




PostPosted: Mon Dec 12, 2011 4:44 pm   Post subject: RE:heavy flickering problem

I added the thing at the bottom, i read the faq, it doesnt help.
Tony




PostPosted: Mon Dec 12, 2011 4:59 pm   Post subject: Re: heavy flickering problem

chipanpriest @ Fri Dec 09, 2011 6:41 am wrote:
First of all, your View.Update ("offscreenonly") should be at the very beginning of your code, before anything happens.

was probably meant as View.Set.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Velocity




PostPosted: Mon Dec 12, 2011 5:04 pm   Post subject: RE:heavy flickering problem

tony so how come it still flickers?
Tony




PostPosted: Mon Dec 12, 2011 5:18 pm   Post subject: RE:heavy flickering problem

because you are still not in "offscreenonly" mode.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
chipanpriest




PostPosted: Mon Dec 12, 2011 6:47 pm   Post subject: Re: heavy flickering problem

Yea sorry, i meant View.Set ("offscreenonly") sorry about that.

and anyways, you still need to add that line to the beginning of your program - View.Set ("offscreenonly")
Velocity




PostPosted: Mon Dec 12, 2011 7:55 pm   Post subject: RE:heavy flickering problem

doesnt work for my program... why?
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 2  [ 19 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: