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

Username:   Password: 
 RegisterRegister   
 program flashes
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
jrblast




PostPosted: Thu Dec 08, 2005 8:23 pm   Post subject: program flashes

Well, in light of finishing my game of snake, i decided to move onto a more complex game...much of the coded so far i took from the astroids game Embarassed lol, anyways, it keeps flashing, i use the viewupdate thing, but it still flashes, any ideas? heres the code btw

code:


const ballRad : int := 10           %declaring constants and vars
const paddleWidth : int := 30
const paddleThicnkness : int := 10
const paddleHeight : int := 5
const screenX : int := 900
const screenY : int := 700
const frameDelay : int := 5
const rate : int := 5
var mouseX, mouseY, ballX, ballY, button, ballDX, ballDY, ballAngle, collision, paddleX : int

ballX := 450                 %giving values to variables
ballY := 350
ballDX := 0
ballDY := -1
mouseX := screenX div 2
paddleX := 350
setscreen ("offscreenonly, nobuttonbar, graphics:900;,700")

loop
    cls
    mousewhere (mouseX, mouseY, button)
    ballX += ballDX
    ballY += ballDY
    if mouseX > paddleX then
        paddleX += rate
    end if
    if mouseX < 0 or mouseX > maxx then
        mouseX := 0
    end if
    if mouseX - paddleWidth >= 0 and mouseX + paddleWidth <= screenX then
        drawfilloval (ballX, ballY, ballRad, ballRad, brightred)
        drawfillbox (mouseX - paddleWidth, paddleHeight, mouseX + paddleWidth, paddleHeight + paddleThicnkness, black)
    else
   
    end if
    delay (frameDelay)
    View.Update
end loop




any helps appreciated
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Thu Dec 08, 2005 8:28 pm   Post subject: (No subject)

View.Update works with "offscreenonly"

You have a mess of a declaration there
code:

setscreen ("offscreenonly, nobuttonbar, graphics:900;,700")

I'd think that graphics might overwrite offscreenonly.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
jrblast




PostPosted: Thu Dec 08, 2005 8:33 pm   Post subject: (No subject)

:O your right Very Happy tyvm
do_pete




PostPosted: Thu Dec 08, 2005 9:42 pm   Post subject: (No subject)

you have to get rid of the "," after "graphics: 900;"
[Gandalf]




PostPosted: Fri Dec 09, 2005 3:12 am   Post subject: (No subject)

Tony wrote:
I'd think that graphics might overwrite offscreenonly.

It doesn't, any of it can be in any order.
codemage




PostPosted: Fri Dec 09, 2005 8:51 am   Post subject: (No subject)

Your delay needs to be AFTER the View.Update.
Tony




PostPosted: Fri Dec 09, 2005 9:21 am   Post subject: (No subject)

[Gandalf] wrote:
Tony wrote:
I'd think that graphics might overwrite offscreenonly.

It doesn't, any of it can be in any order.

that's why I've said "might", I didn't have Turing at the moment of writing to try it out.

codemage has gotten it though. Delay after View.Update Smile
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
[Gandalf]




PostPosted: Fri Dec 09, 2005 4:18 pm   Post subject: (No subject)

Tony wrote:
[Gandalf] wrote:
Tony wrote:
I'd think that graphics might overwrite offscreenonly.

It doesn't, any of it can be in any order.

that's why I've said "might", I didn't have Turing at the moment of writing to try it out.

Just correcting you for anyone else's benefit. You can't check, so why don't I? Smile

About the delay after View.Update, although that would be better coding, it's not necessary to eliminate the flickering.
Sponsor
Sponsor
Sponsor
sponsor
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  [ 8 Posts ]
Jump to:   


Style:  
Search: