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

Username:   Password: 
 RegisterRegister   
 flashing reduction while ina game
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
kousha41564




PostPosted: Fri Dec 19, 2008 8:13 pm   Post subject: flashing reduction while ina game

alrigt this is my first rough sketch of a game, i am doing it so it says when u colide, whihc is wworking quite well , but the figure taht moves is flickering. could anyone help me get rid of that ?



code:


var x1,y1,x2,y2,a,b:int:=0
var c,csq:real:=0
var key : array char of boolean
x1:=300
y1:=300
x2:=150
y2:=150
loop
drawoval(x1,y1,25,25,1)
drawoval(x2,y2,50,50,1)
a:=x2-x1
b:=y2-y1
csq:=a*a+b*b
c:=sqrt(csq)

if 50+25>c then
    put "collide"
    end if
   

   Input.KeyDown (key)
    if key (KEY_UP_ARROW) and y1 < maxy then %makes sure the character won't go past the top of the screen
        y1 += 1
    end if

    if key (KEY_DOWN_ARROW) and y1 > 0 then
        y1 -= 1
    end if

    if key (KEY_LEFT_ARROW) and x1 > 0 then
        x1 -= 1
    end if

    if key (KEY_RIGHT_ARROW) and x1 < maxx then
        x1 += 1
    end if

drawfilloval(x1,y1,25,25,1)

delay (10)

cls
end loop
Sponsor
Sponsor
Sponsor
sponsor
syntax_error




PostPosted: Fri Dec 19, 2008 8:31 pm   Post subject: RE:flashing reduction while ina game

View.Set look that up along with View.Update

F10 is an ally.

As is The Turing Walkthrough
andrew.




PostPosted: Fri Dec 19, 2008 9:16 pm   Post subject: RE:flashing reduction while ina game

You have to set your program to draw the picture in it's own memory and show it on the screen when you want it to.

e.g.
Turing:

View.Set ("graphics:800,600,offscreenonly") % offscreenonly tells it to do that

loop % your main game loop
    cls % clear screen
    % some code
    View.Update
end loop


You can see in View.Set that the program is now running in offscreenonly mode. This means it draws the image and when you put View.Update, it draws it all at once to the screen. The reason it's flickering is because it is drawing each item individually, but this makes it draw all at once.

For more help, follow syntax_error's advice.
kousha41564




PostPosted: Fri Dec 19, 2008 9:52 pm   Post subject: Re: flashing reduction while ina game

Turing:

View.Set ("graphics:800,600,offscreenonly")
var x1,y1,x2,y2,a,b:int:=0
var c,csq:real:=0
var key : array char of boolean
x1:=300
y1:=300
x2:=150
y2:=150
loop
drawoval(x1,y1,25,25,1)
drawoval(x2,y2,50,50,1)
a:=x2-x1
b:=y2-y1
csq:=a*a+b*b
c:=sqrt(csq)

if 50+25>c then
    put "collide"
    end if
   

   Input.KeyDown (key)
    if key (KEY_UP_ARROW) and y1 < maxy then %makes sure the character won't go past the top of the screen
        y1 += 1
    end if

    if key (KEY_DOWN_ARROW) and y1 > 0 then
        y1 -= 1
    end if

    if key (KEY_LEFT_ARROW) and x1 > 0 then
        x1 -= 1
    end if

    if key (KEY_RIGHT_ARROW) and x1 < maxx then
        x1 += 1
    end if

drawfilloval(x1,y1,25,25,1)

delay (10)

cls
 View.Update
end loop


dosnt work



Mod Edit: Remember to use syntax tags! Thanks Smile
code:
[syntax="Turing"]Code Here[/syntax]
Tyr_God_Of_War




PostPosted: Fri Dec 19, 2008 10:18 pm   Post subject: Re: flashing reduction while ina game

cls should go after View.Update.
kousha41564




PostPosted: Sat Dec 20, 2008 2:12 pm   Post subject: RE:flashing reduction while ina game

thank you very much
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  [ 6 Posts ]
Jump to:   


Style:  
Search: