FreeImage

Blitz3D Forums/Blitz3D Beginners Area/FreeImage

Pat33(Posted 2004) [#1]
Hi I just got BlitzPlus yesterday. It's awesome!

I see FreeImage removes it from memory, but how do I remove an image from the screen? This is what I have so far:

; ManHunt game

Graphics 640,480
Global sndHandsUp
SetBuffer BackBuffer()

;;;;;;;;;intro stuff;;;;;;;;;;;;;;;;;;;;;;;
BeginPic=LoadImage( "Pics\setpic.bmp" )
TitleText=LoadImage("Pics\copspic.bmp")
sndHandsUp=LoadSound("sounds\policebullhorn.wav")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

chnSurrounded=PlaySound ( sndHandsUp )

startTime=MilliSecs()
pauseTime=5000

While MilliSecs() < startTime + pausetime

DrawImage BeginPic, 0, 0
DrawImage TitleText, 0, 0
Flip

Wend
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; don't need these anymore / How to remove from screen?
DrawImage BeginPic, 700, 0
DrawImage TitleText, 700, 0
FreeImage BeginPic
FreeImage TitleText
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
While Not KeyHit(1)

; now we can place the game tiles on screen

Flip

Wend

End

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Thanks for helping.


VIP3R(Posted 2004) [#2]
Welcome Pat33

Normally you would use the Cls command to clear the whole screen, you can't really remove single images from the screen.

Inside your main loop you should do something like this:

While Not KeyHit(1) 

Cls

; draw all your stuff here

Flip 

Wend

Hope this helps ;)


BobR3D(Posted 2004) [#3]
Pat33- To expand a little on VIP3R's answer to your question, CLS is the "Clear Screen" command.

When you're done with your setup screen and title, just add a CLS command BEFORE you start drawing the game screens, and all the former images will be erased.

What VIP3R was referring to in the code above is what's called the "Game Loop", where all the action of the game takes place.

Generally when you want to remove something from the screen, like an enemy spaceship that's been blown up, all you do is clear the screen with a CLS command then redraw everything else, but omit the enemy spaceship.

This redrawing happens every "frame" (usually 60 times a second or so), so it's very fast.


Pat33(Posted 2004) [#4]
Works perfectly now, thanks!