
-----------------------------------
Deadmon
Thu Apr 27, 2006 8:11 pm

View.Update &amp; 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. :P

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. :P

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!

-----------------------------------
Clayton
Thu Apr 27, 2006 8:29 pm

Re: View.Update &amp; 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. :P

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. :P

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


loop
    Draw.FillBox(x,y,x+25,y+25,black)
    getch(a)
    if a="d" then
        x+=10
    end if
    Draw.Cls
    View.Update
end if


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
Thu Apr 27, 2006 8:38 pm


-----------------------------------
Well, I'm not not sure if you understood my question SuperFreak? :P

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
Thu Apr 27, 2006 8:55 pm


-----------------------------------
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
Thu Apr 27, 2006 9:05 pm


-----------------------------------


setscreen ("graphics:offscreenonly:640,480")



That line is your problem.  You've not setup the 'offscreenonly' correctly.  Try:

setscreen ("graphics;offscreenonly")

Instead.  Since the window size you've specified is the default size, no need to change it.

-----------------------------------
do_pete
Thu Apr 27, 2006 9:07 pm


-----------------------------------
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
Fri Apr 28, 2006 8:35 am


-----------------------------------
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.
