View.Update & Pic.Draw?
Author |
Message |
Deadmon
|
Posted: Thu Apr 27, 2006 8:11 pm Post subject: View.Update & Pic.Draw? |
|
|
Hello compsci...I been trying to an answer to this problem:
As this is now May, most compsci classes are asking for games..and I'm in the process of making one.
Now, I been trying to find out how to move a picture around without flickering, but to no avail. :\
Basically, with the code below, if I were to hold "d", I would be able to see the flickering..if I were to remove cls, it would work fine, except I would see clones of my character.
code: | setscreen ("nocursor")
setscreen ("graphics:offscreenonly:640,480")
var x : int := 150
var y : int := 10
var pic : int
var move : string (1)
pic := Pic.FileNew ("GFX/eph.bmp")
loop
Pic.Draw (pic, x, y, picMerge)
getch (move)
if move = "d" then
x := x + 10
end if
View.Update
end loop
|
Suggestions? Or something I missed? and..thanks! |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Clayton
|
Posted: Thu Apr 27, 2006 8:29 pm Post subject: Re: View.Update & Pic.Draw? |
|
|
Deadmon wrote: Hello compsci...I been trying to an answer to this problem:
As this is now May, most compsci classes are asking for games..and I'm in the process of making one.
Now, I been trying to find out how to move a picture around without flickering, but to no avail. :\
Basically, with the code below, if I were to hold "d", I would be able to see the flickering..if I were to remove cls, it would work fine, except I would see clones of my character.
code: | setscreen ("nocursor")
setscreen ("graphics:offscreenonly:640,480")
var x : int := 150
var y : int := 10
var pic : int
var move : string (1)
pic := Pic.FileNew ("GFX/eph.bmp")
loop
Pic.Draw (pic, x, y, picMerge)
getch (move)
if move = "d" then
x := x + 10
end if
View.Update
end loop
|
Suggestions? Or something I missed? and..thanks!
with your code you can do this to eliminate the flickering
the above code is pretty much the same as yours with the exception i drew a box instead of a pic. you pretty much had it right except you use a combination of Draw.Cls and View.Update to remove the flickering |
|
|
|
|
|
Deadmon
|
Posted: Thu Apr 27, 2006 8:38 pm Post subject: (No subject) |
|
|
Well, I'm not not sure if you understood my question SuperFreak?
code: | setscreen ("nocursor")
setscreen ("graphics:offscreenonly:640,480")
var x : int := 150
var y : int := 10
var pic : int
var move : string (1)
pic := Pic.FileNew ("GFX/eph.bmp")
loop
Pic.Draw (pic, x, y, picMerge)
getch (move)
if move = "d" then
x +=10
end if
Draw.Cls
View.Update
end loop |
So now my code looks like that, but like I mentioned before, if I were to hold or push D, my picture would "flicker" (as in it gets cls'd and reappears). Thanks though![/code] |
|
|
|
|
|
Clayton
|
Posted: Thu Apr 27, 2006 8:55 pm Post subject: (No subject) |
|
|
it shouldnt flicker, not if your using View.Update properly, the odd flicker is normal, which is much better than the constant flickering without View.Update, thats about as good as its going to get im afraid, unless a mod or some sort of Turing God knows how to prevent even the odd exceptional flicker |
|
|
|
|
|
Delos
|
Posted: Thu Apr 27, 2006 9:05 pm Post subject: (No subject) |
|
|
Deadmon wrote:
code: |
setscreen ("graphics:offscreenonly:640,480")
|
That line is your problem. You've not setup the 'offscreenonly' correctly. Try:
code: |
setscreen ("graphics;offscreenonly")
|
Instead. Since the window size you've specified is the default size, no need to change it. |
|
|
|
|
|
do_pete
|
Posted: Thu Apr 27, 2006 9:07 pm Post subject: (No subject) |
|
|
You need a delay and lower the number you increment x by. If you make that number a decimal like 0.2 or something you can have a smooth animation without a delay but you should still have something controlling the fps. |
|
|
|
|
|
codemage
|
Posted: Fri Apr 28, 2006 8:35 am Post subject: (No subject) |
|
|
You should also NOT clear the screen right before you do an update.
For best results,
clear screen
draw everything
update
really short delay
having a short delay helps Turing's weak image buffering system to prevent most of the flickering. |
|
|
|
|
|
|
|