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

Username:   Password: 
 RegisterRegister   
 My Characters wont stop flashing flickering blinking
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Qwatch




PostPosted: Fri May 03, 2019 8:31 am   Post subject: My Characters wont stop flashing flickering blinking

What is it you are trying to achieve?
I would Like the flickering to stop


What is the problem you are having?
All 4 of my yoshi image characters are flickering,Flashing,Blinking


Describe what you have tried to solve this problem
I have added and removed cls and View.Update all over my coding as well as put the setscreen("offscreenonly")


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)



Turing:


setscreen ("offscreenonly")
View.Set ("graphics:1000;600,position:center;center,nobuttonbar,title:View.Set tut")
var Yoshi : int := Pic.FileNew ("Yoshi.bmp")
var Yoshi2 : int := Pic.FileNew ("Yoshi2.bmp")
var Yoshi3 : int := Pic.FileNew ("Yoshi3.bmp")
var Yoshi4 : int := Pic.FileNew ("Yoshi4.bmp")
var Fruit : int := Pic.FileNew ("Fruit.bmp")
var posx, posy : int
var posx2, posy2 : int
var rposx, rposy : int
var rposx2, rposy2 : int
var bposx, bposy : int
var bposx2, bposy2 : int
var yposx, yposy : int
var yposx2, yposy2 : int
var x, y : int
posx := 100
posy := 100
posx2 := posx + 45
posy2 := posy + 45
rposx := 200
rposy := 200
rposx2 := rposx + 45
rposy2 := rposy + 45
bposx := 300
bposy := 300
bposx2 := bposx + 45
bposy2 := bposy + 45
yposx := 400
yposy := 400
yposx2 := yposx + 45
yposy2 := yposy + 45
randint (x, 15, maxx - 15)
randint (y, 15, maxy - 15)
var chars : array char of boolean
var chars2 : array char of boolean
var chars3 : array char of boolean
var chars4 : array char of boolean





loop


    %movement pour le Yoshi Vert
    Input.KeyDown (chars)

    if chars ('w') and posy < maxy - Pic.Height (Yoshi) then
        posy := posy + 5
    end if
    if chars ('d') and posx < maxx - Pic.Width (Yoshi) then
        posx := posx + 5
    end if
    if chars ('a') and posx > 0 then
        posx := posx - 5
    end if
    if chars ('s') and posy > 0 then
        posy := posy - 5
    end if
    %Character Yoshi Vert et le Fruit
    Pic.Draw (Fruit, x, y, picMerge)
    Pic.Draw (Yoshi, posx, posy, picMerge)

    View.Update
    cls
    delay (3)



    %voir pour des collisions Yoshi vert
    if posx + Pic.Width (Yoshi) > x and posx < x + Pic.Width (Fruit) and posy + Pic.Height (Yoshi) > y and posy < y + Pic.Height (Fruit) then
        randint (x, 15, maxx - 15)
        randint (y, 15, maxy - 15)
        Pic.Draw (Fruit, x, y, picMerge)
        Pic.Draw (Yoshi, posx, posy, picMerge)
        View.Update
        delay (3)
        cls
        Music.PlayFile ("Mlem.mp3")

    end if

    %movement pour le Yoshi Rouge
    Input.KeyDown (chars2)

    if chars2 ('i') and rposy < maxy - Pic.Height (Yoshi2) then
        rposy := rposy + 5
    end if
    if chars2 ('l') and rposx < maxx - Pic.Width (Yoshi2) then
        rposx := rposx + 5
    end if
    if chars2 ('j') and rposx > 0 then
        rposx := rposx - 5
    end if
    if chars2 ('k') and rposy > 0 then
        rposy := rposy - 5
    end if
    %Character Yoshi Rouge et le Fruit
    Pic.Draw (Fruit, x, y, picMerge)
    Pic.Draw (Yoshi2, rposx, rposy, picMerge)

    View.Update
    cls
    delay (3)


    %voir pour des collisions Yoshi Rouge
    if rposx + Pic.Width (Yoshi2) > x and rposx < x + Pic.Width (Fruit) and rposy + Pic.Height (Yoshi2) > y and rposy < y + Pic.Height (Fruit) then
        randint (x, 15, maxx - 15)
        randint (y, 15, maxy - 15)
        Pic.Draw (Fruit, x, y, picMerge)
        Pic.Draw (Yoshi2, rposx, rposy, picMerge)
        View.Update
        delay (3)
        cls
        Music.PlayFile ("Mlem.mp3")

    end if

    %movement pour le Yoshi Bleu
    Input.KeyDown (chars3)

    if chars3 (KEY_UP_ARROW) and bposy < maxy - Pic.Height (Yoshi3) then
        bposy := bposy + 5
    end if
    if chars3 (KEY_RIGHT_ARROW) and bposx < maxx - Pic.Width (Yoshi3) then
        bposx := bposx + 5
    end if
    if chars3 (KEY_LEFT_ARROW) and bposx > 0 then
        bposx := bposx - 5
    end if
    if chars3 (KEY_DOWN_ARROW) and bposy > 0 then
        bposy := bposy - 5
    end if
    %Character Yoshi Bleu et le Fruit
    Pic.Draw (Fruit, x, y, picMerge)
    Pic.Draw (Yoshi3, bposx, bposy, picMerge)

    View.Update
    cls
    delay (3)



    %voir pour des collisions Yoshi Bleu
    if bposx + Pic.Width (Yoshi3) > x and bposx < x + Pic.Width (Fruit) and bposy + Pic.Height (Yoshi3) > y and bposy < y + Pic.Height (Fruit) then
        randint (x, 15, maxx - 15)
        randint (y, 15, maxy - 15)
        Pic.Draw (Fruit, x, y, picMerge)
        Pic.Draw (Yoshi3, bposx, bposy, picMerge)
        View.Update
        delay (3)
        cls
        Music.PlayFile ("Mlem.mp3")

    end if
    %movement pour le Yoshi Jaune
    Input.KeyDown (chars4)

    if chars4 ('8') and yposy < maxy - Pic.Height (Yoshi4) then
        yposy := yposy + 5
    end if
    if chars4 ('6') and yposx < maxx - Pic.Width (Yoshi4) then
        yposx := yposx + 5
    end if
    if chars4 ('4') and yposx > 0 then
        yposx := yposx - 5
    end if
    if chars4 ('5') and yposy > 0 then
        yposy := yposy - 5
    end if
    %Character Yoshi Jaune et le Fruit
    Pic.Draw (Fruit, x, y, picMerge)
    Pic.Draw (Yoshi4, yposx, yposy, picMerge)

    View.Update
    cls
    delay (3)


    %voir pour des collisions Yoshi Jaune
    if yposx + Pic.Width (Yoshi4) > x and yposx < x + Pic.Width (Fruit) and yposy + Pic.Height (Yoshi4) > y and yposy < y + Pic.Height (Fruit) then
        randint (x, 15, maxx - 15)
        randint (y, 15, maxy - 15)
        Pic.Draw (Fruit, x, y, picMerge)
        Pic.Draw (Yoshi4, yposx, yposy, picMerge)

        View.Update
        delay (3)

        Music.PlayFile ("Mlem.mp3")

    end if
    View.Update







end loop



Please specify what version of Turing you are using
4.1.2.0
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Sat May 04, 2019 8:45 pm   Post subject: RE:My Characters wont stop flashing flickering blinking

You aren't supposed to put view.update all over your code, that's just like not using it at all. The flickering comes from many things getting drawn and erased very quickly. Setscreen(offscreenonly) creates a virtual screen to draw to that you cannot see. Draw everything there where it won't flicker. View.update copies the virtual screen to the real one in one fel swoop. If you have lots of View.Updates, you're still doing lots of random draws to the screen. If you only have one, then there's only one draw, therefore no flickering.
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  [ 2 Posts ]
Jump to:   


Style:  
Search: