2d stuff

Blitz3D Forums/Blitz3D Beginners Area/2d stuff

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

1) put the Flip command just after the latest Drawimage, and before the Wend statement

2) choose a standard screen resolution. More, if you want that your game ran on other pcs, choose a smaller resolution:
Graphics 640,480,0,1 ;(2 for windowed)
or
Graphics 800,600,0,1 ;(2 for windowed)

should be fine.

3) I would change the If statement, checking first the mousedown(), because it happens less frequently, so it would make the process slight faster:
If Mousedown(1) then
   If ImagesOverlap (pointer,MouseX(),MouseY(),button,0,711) then
.
.


4) do not use fixed numbers to indicate where to display your image. If you write in your code 100 times:
drawimage popup,700,14
and then you want to change the coordinates, you have to edit it 100 times. Instead, declare two variables like, for example, buttonx and buttony, and use them when you draw the image on the screen:
drawimage button,buttonx,buttony

About the status thingy. Basically, you may do in this way:

if the left button mouse has been pressed then
if it has been pressed on an image then
change status to the image flag
endif
endif

And, in the main loop:

if the image status is 1 then display it
.
.
flip
wend


The image status does not exist really, but you can create a flag (or use a type structure, but perhaps right now is too complicated if you are a beginner).

So, for example:
my_img = LoadImage("popup.png")
my_img_status = 0
my_imgx = 100
my_imgy = 100
.
.
if mousehit(1) then ;left mouse click ?
flushmouse() ;reset mouse
if imagesoverlap(mouse_img,mousex(),mousey(),button,buttonx,buttony) then
my_img_status = 1 - my_img_status ;this will toggle between 0 and 1
endif
endif

;
;
if my_img_status = 1 then
drawimage my_img,my_imgx,my_imgy
endif

flip
wend


In the example above, the image my_img will be displayed when you left click on it, and will disappear if you left click again on it.

Hope this has sense for you,
Sergio.