program flashes
Author |
Message |
jrblast
|
Posted: 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 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
|
|
|
Tony
|
Posted: 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. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
jrblast
|
Posted: Thu Dec 08, 2005 8:33 pm Post subject: (No subject) |
|
|
:O your right tyvm |
|
|
|
|
|
do_pete
|
Posted: Thu Dec 08, 2005 9:42 pm Post subject: (No subject) |
|
|
you have to get rid of the "," after "graphics: 900;" |
|
|
|
|
|
[Gandalf]
|
Posted: 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
|
Posted: Fri Dec 09, 2005 8:51 am Post subject: (No subject) |
|
|
Your delay needs to be AFTER the View.Update. |
|
|
|
|
|
Tony
|
Posted: 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 |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
[Gandalf]
|
Posted: 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?
About the delay after View.Update, although that would be better coding, it's not necessary to eliminate the flickering. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
|
|