background image

BlitzPlus Forums/BlitzPlus Beginners Area/background image

o-q(Posted 2009) [#1]
Going to give this code thingy a new bash...
I have had a go at gamemaker but feel unforfilled buy it!

So my questions will be somewhat simplistic...sorry for that!

Question:
How do I load/code (make work) a background image,
for a very simple graphics window.

There will be more questions no doubt!


Sauer(Posted 2009) [#2]
Hi,

Here's a quick code sample with comments:

GRAPHICS 640,480,32,2   ;creates a 640x480 windows with 32 bit depth and 2 for windowed mode

GLOBAL myimage=LOADIMAGE("myimage.bmp") ;loads the image into memory.  Make sure the "myimage.bmp" is in the same directory as the source or you'll get an error

SETBUFFER BACKBUFFER()  ;sets the backbuffer for drawing.  When you draw an image in B+ (as well as other languages), you're really just drawing to somewhere "behind the screen"

WHILE NOT KEYHIT(1) ;while you have not pressed escape...
  CLS ;Clear the screen each fram
  DRAWIMAGE myimage,0,0  ;draws the image at 0,0, the top left corner of the screen
  FLIP  ; "flip" the 'behind the screen' part you drew to actually to the screen so you can see it
WEND  ;end of while loop

END ;end the program


Hopefully that helped, that's a pretty basic example on how a graphics window works. For a background image, you're going to want your image to have the same dimensions as the window, and draw it at 0,0.


o-q(Posted 2009) [#3]
Thank you very much Sauer.
So there is no special function for background graphics?


Sauer(Posted 2009) [#4]
Nope, everything you do graphically will be done with the DrawImage command, or the B+ graphics commands Rect, Oval, Line, etc.

Keep in mind that if you draw an image, then in the next line draw another image, that second image will cover the first. For this reason, a background image is usually the first thing you want to draw in your While loop, as everything else should always be drawn on top of it.


SuperSonic7(Posted 2009) [#5]
Heh, you took a dip into Game Maker? Yeah, it's a completely different pool with that software. Blitz may look a little hard at first but you'll get the hang of it.


o-q(Posted 2009) [#6]
Yep...the results may be a little slower ariving but, I feel I have achieved more!