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

Username:   Password: 
 RegisterRegister   
 View.Set("offscreenonly") and View.Update (or) View.Update(area) (0,0,maxx,maxy) Still flickering.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
poww10s




PostPosted: Thu Apr 03, 2014 5:01 pm   Post subject: View.Set("offscreenonly") and View.Update (or) View.Update(area) (0,0,maxx,maxy) Still flickering.

What is it you are trying to achieve?
Stopping the occasional flickering


What is the problem you are having?
No matter where or how many View.Update or View.UpdateArea I put, my program still flickers occasionally, It stopped for a while once, but has started up again.


Describe what you have tried to solve this problem
Choosing where to place the code occasionally.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
I am working on a project, and it has a rather large amount of code spread across lots of modules, here is the one causing problems.

Turing:


% Platforming Test (WITH SAVE WIP)
% Unit 11
% Daniel Bradley
% 21/03/14


import loadingModule


View.Set ("text")

loadingModule.LoadFile("dan2")

View.Set("graphics:640;400,echo")

proc collision (cx1, cy1, cx2, cy2 : int)

end collision

var x, y, ex, ey : int

var xspeed, yspeed, exspeed, eyspeed : int := 0
var gravity : int := 1
var jump, ground, ejump : boolean := false
var mx, my, button, cnt : int
var menu, quiting, options, running : boolean := false
cnt := 0
var chars : array char of boolean

%##################################################################%
%#                    Beginning of Game Segment                   #%
%##################################################################%

% Create Player, then cause them to fall down to bottom of screen. Plus Jumping stuff.
x := 16
y := maxy - 16
ex := maxx - 16
ey := y
loop
   
    Input.KeyDown (chars)
    if menu = false and options = false  then
    for i : 1 .. upper (loadingModule.platform, 1)
        drawbox (loadingModule.platform (i, 1), loadingModule.platform (i, 2), loadingModule.platform (i, 3), loadingModule.platform (i, 4), black)
    end for
    end if
   
    % Draw Oval (Player)
    if menu = false and options = false  then
    drawfilloval (x, y, 16, 16, red)
    end if
    if menu = false and options = false  then
    drawfilloval (ex, ey, 16, 16, blue)
    end if

    % I need to go enemy stuff somewhere this is a reminder.

    % Landing on Platforms
    for i : 1 .. upper (loadingModule.platform, 1)
        if x > loadingModule.platform (i, 1) - 8 and x < loadingModule.platform (i, 3) + 8 and y > loadingModule.platform (i, 2) + 2 and y < loadingModule.platform (i, 2) + 20 and yspeed > 0  then
            yspeed := 0
            y := loadingModule.platform (i, 2) + 16
            jump := true
            ground := true
        end if
        if x > loadingModule.platform (i, 1) - 8 and x < loadingModule.platform (i, 3) + 8 and y = loadingModule.platform (i, 2) and yspeed > 0 then
            yspeed := 0
            y := loadingModule.platform (i, 2) + 16
        end if
    end for

    % Physics!
    if gravity not= 0
            then
        yspeed := yspeed + gravity
    elsif gravity not= 0 and yspeed > 30 then
        yspeed := 30
    else
        yspeed := -yspeed
    end if
    y := y - yspeed

    % Stop
    if y < 17 then
        yspeed := 0
        y := 16
        jump := true
        ground := true
    end if
    if ground = false then
        jump := false
    end if

    if xspeed > 15 then
        xspeed := 15
    elsif xspeed < -15 then
        xspeed := -15
    end if

    % Movement
    if chars (KEY_LEFT_ARROW) and menu = false and options = false  then
        xspeed := xspeed - 1
    elsif chars (KEY_RIGHT_ARROW) and menu = false and options = false  then
        xspeed := xspeed + 1
    elsif xspeed < 0 then
        xspeed := xspeed + 1
    elsif xspeed > 0 then
        xspeed := xspeed - 1
    elsif xspeed = 0 then
        xspeed := 0
        x := x
    end if

    x := x + xspeed

    % Stopping at side of screen.
    if x < 17 then
        x := 17
        xspeed := 0
    elsif x > maxx - 17 then
        x := maxx - 17
        xspeed := 0
    end if

    % Jumping
    if chars ('w') and jump = true and menu = false and options = false then
        yspeed := yspeed - 16
        jump := false
    end if   
%##################################################################%
%#                      End of Player Segment                     #%
%#                   Beginning of Enemy Segment                   #%
%##################################################################%
    % Enemy Landing On Platforms
    for i : 1 .. upper (loadingModule.platform, 1)
         if ex > loadingModule.platform (i, 1) - 8 and ex < loadingModule.platform (i, 3) + 8 and ey > loadingModule.platform (i, 2) + 2 and ey < loadingModule.platform (i, 2) + 20 and eyspeed > 0  then
            eyspeed := 0
            ey := loadingModule.platform (i, 2) + 16
            ejump := true
        end if
        if ex > loadingModule.platform (i, 1) - 8 and ex < loadingModule.platform (i, 3) + 8 and ey = loadingModule.platform (i, 2) and eyspeed > 0 then
            eyspeed := 0
            ey := loadingModule.platform (i, 2) + 16
        end if   
    end for

    % Enemy Physics!
    if gravity not= 0
            then
        eyspeed := eyspeed + gravity
    elsif gravity not= 0 and eyspeed > 30 then
        eyspeed := 30
    else
        eyspeed := -eyspeed
    end if
    ey := ey - eyspeed
   
    % Enemy Stop
    if ey < 17 then
        eyspeed := 0
        ey := 16
        ejump := true
    end if
   
    if ey > (maxy - 17) then
        eyspeed := 0
        ey := (maxy - 17)
    end if
   
    % Enemy X- axis Movement
    if exspeed > 6 then
        exspeed := 6
    elsif exspeed < -6 then
        exspeed := -6
    end if
   
    if x > ex and menu = false and options = false then
       exspeed := exspeed + 1
    elsif x < ex and menu = false and options = false then
        exspeed := exspeed - 1
    elsif exspeed < 0 then
        exspeed := exspeed + 1
    elsif exspeed > 0 then
        exspeed := exspeed - 1
    elsif exspeed = 0 then
        exspeed := 0
        ex := ex
    end if
   
    ex := ex + exspeed
   
    % Enemy Stopping at side of screen.
    if ex < 17 then
        ex := 17
        exspeed := 0
    elsif ex > maxx - 17 then
        ex := maxx - 17
        exspeed := 0
    end if
   
    % Enemy Jumping
    if y > ey and menu = false and options = false and ejump = true then
        eyspeed := eyspeed - 20
        ejump := false
    end if
   
    if menu = false and options = false then
    View.Update
    Time.Delay(35)
    %cls
    end if
    View.Update
    cls
%end loop
%##################################################################%
%#                        End of Enemy Segment                    #%
%#                     Beginning of Menu Segment                  #%
%##################################################################%

% Check to see if ESC pressed, if so then draw menu (And save all other variables for reloading later.)
%loop
    Mouse.Where (mx, my, button)
    %Options Menu
    if options = true then
        menu := false
        drawbox (150, 350, 500, 300, black)
    end if
    if options = true and menu = false and mx > 150 and mx < 250 and my < 250 and my > 150 and button = 1 then
        drawbox (150, 250, 250, 150, brightblue)
    elsif options = true and menu = false and mx > 150 and mx < 250 and my < 250 and my > 150then
        drawbox (150, 250, 250, 150, brightblue)
    elsif options = true and menu = false then
        drawbox (150, 250, 250, 150, black)
    end if
     if options = true and menu = false and mx > 400 and mx < 500 and my < 250and my > 150 and button = 1 then
        drawbox (400, 250, 500, 150, brightblue)
    elsif options = true and menu = false and mx > 400 and mx < 500 and my < 250and my > 150 then
        drawbox (400, 250, 500, 150, brightblue)
    elsif options = true and menu = false then
        drawbox (400, 250, 500, 150, black)
    end if
     if options = true and menu = false and mx > 150 and mx < 500 and my < 100 and my > 50 and button = 1 then
        drawbox (150, 100, 500, 50, brightblue)
        menu := true
        options := false
        cls
    elsif options = true and menu = false and mx > 150 and mx < 500 and my < 100 and my > 50 then
        drawbox (150, 100, 500, 50, brightblue)
    elsif options = true and menu = false then
        drawbox (150, 100, 500, 50, black)
        Font.Draw ("Back to Menu", 275, 73, defFontID, black)
    end if
    % Auto Save on Quit
    if quiting = true then
        put "Saving."
        loadingModule.SaveFile ("sav") %(WORK ON THIS LATER)
        delay (500)
        put "Saved!"
        delay (500)
        put "Closing.."
        delay (500)
        Window.Close (defWinID)
        %DO NOTHING
    end if
   
    % Resume Button
    if menu = true and quiting = false and mx >= 200 and mx <= 450 and my <= 350 and my >= 300 and button = 1 then
        drawbox (200, 350, 450, 300, brightred)
        Font.Draw ("Resume", 300, 325, defFontID, black)
        menu := false
        cls
        running := false
    elsif menu = true and quiting = false and mx >= 200 and mx <= 450 and my <= 350 and my >= 300 then
        drawbox (200, 350, 450, 300, brightblue)
        Font.Draw ("Resume", 300, 325, defFontID, black)
    elsif menu = true and quiting = false then
        drawbox (200, 350, 450, 300, black)
        Font.Draw ("Resume", 300, 325, defFontID, black)
    end if
    % Options Button
    if menu = true and quiting = false and mx >= 200 and mx <= 450 and my <= 250 and my >= 200 and button = 1 then
        drawbox (200, 250, 450, 200, brightred)
        Font.Draw ("Options", 295, 225, defFontID, black)
        cls
        options := true
        %(loadingModule.LoadFile)
    elsif menu = true and quiting = false and mx >= 200 and mx <= 450 and my <= 250 and my >= 200 then
        drawbox (200, 250, 450, 200, brightblue)
        Font.Draw ("Options", 295, 225, defFontID, black)
    elsif menu = true and quiting = false then
        drawbox (200, 250, 450, 200, black)
        Font.Draw ("Options", 295, 225, defFontID, black)
    end if
    %Quit Button
    if menu = true and quiting = false and mx >= 200 and mx <= 450 and my <= 150 and my >= 100 and button = 1 then
        drawbox (200, 150, 450, 100, brightred)
        Font.Draw ("Quit Game", 290, 125, defFontID, black)
        quiting := true
        cls
        %quitGame
    elsif menu = true and quiting = false and mx >= 200 and mx <= 450 and my <= 150 and my >= 100 then
        drawbox (200, 150, 450, 100, brightblue)
        Font.Draw ("Quit Game", 290, 125, defFontID, black)
    elsif menu = true and quiting = false and options = false then
        drawbox (200, 150, 450, 100, black)
        Font.Draw ("Quit Game", 290, 125, defFontID, black)
    end if

    % Detect ESC Being Pressed
    if chars (KEY_ESC) and menu = false and options = false and quiting = false then
        menu := true
        running := true
        cls
    end if
   
   
    % if menu = true and options = true then
    % View.UpdateArea (0, 0, maxx, maxy)
    % Time.Delay (35)
    % cld if
   
end loop

%end menuproc
%

%menuproc

% if y > ey and ey < loadingModule.platform (i, 2) + 2 and ex < loadingModule.platform (i, 1) - 8 then
%             exspeed := + 1
%         end if




Please specify what version of Turing you are using
4.1
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Apr 03, 2014 5:11 pm   Post subject: Re: View.Set("offscreenonly") and View.Update (or) View.Update(area) (0,0,maxx,maxy) Still flickering.

poww10s @ Thu Apr 03, 2014 5:01 pm wrote:
how many View.Update

A number that is more than exactly 1 call per frame is wrong.

More importantly, you are not actually enabling the "offscreenonly" mode in the code posted.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
poww10s




PostPosted: Thu Apr 03, 2014 5:13 pm   Post subject: RE:View.Set("offscreenonly") and View.Update (or) View.Update(area) (0,0,maxx,maxy) Still flickering.

Oh, really? what am I doing wrong? I read the tutorial on the wiki, so maybe I interpreted it wrong, because This has worked with everything else. do I have to put
Turing:
View.Set ("offscreenonly")
poww10s




PostPosted: Thu Apr 03, 2014 5:27 pm   Post subject: RE:View.Set("offscreenonly") and View.Update (or) View.Update(area) (0,0,maxx,maxy) Still flickering.

Oh, another mistake made by forgetting one line of code.
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 1  [ 4 Posts ]
Jump to:   


Style:  
Search: