Mosaka
April 16th, 2008, 12:59 PM
Hi
i am new here.
I dont know much about programming (just basic stuff).
I would like to make an excecutable which simply displays a tiny graphic in the center of the screen, and should always be shown ontop of everything.
I think its easy.. But no idea how to apoach it :D
A developed idea would be that it identifies an name of a file eg "image" and uses that, so i would be able to change the image without reprograming :))
Any ideas/sample script would be veeeeeerryyyyyy much apretiated.
thanks so much in advanced!!!
tattooedscorpdc
January 30th, 2009, 02:03 PM
well if its a web application or page you need to define the z index as constant and 0
Hope this helps,
Larry D
PerksPlusPlus
February 2nd, 2009, 01:22 AM
you'd draw the image after you do everything else, always.
the way you'd do this is load all the images/files/sounds.
then enter a loop that the logic of your program is carried out in.
the last thing you should do in your loop is update your screen.
if you want your image to always be on top, draw that to the screen last.
example, allegro probly has the easiest way to load images and a screen to draw on
that's why I chose it for this example:
#include <allegro.h>
BITMAP* buffer = NULL;
BITMAP* interface = NULL;
BITMAP* your_little_pic = NULL;
int main(){
allegro_init();
set_color_depth(16);
set_gfx_mode(640,480,0,0);
buffer = create_bitmap(640,480);
interface = load_bitmap("interface.bmp", NULL);
your_little_pic = load_bitmap("pic_i_always_want_on_top.bmp", NULL);
while (1){
//do whatever needs to be done in your program
//then draw whatever needs to be drawn to a buffer
//then the screen
draw_sprite(buffer, interface,0,0)
draw_sprite(buffer, your_little_pic,(SCREEN_W/2) + (your_little_pic->w/2), (SCREEN_H/2) + (your_little_pic->h/2))
draw_sprite(screen, buffer, 0,0)
}
destroy_bitmap(buffer);
destroy_bitmap(your_little_pic);
destroy_bitmap(buffer);
return 0;
}
END_OF_MAIN()
you'd want to separate things into functions obviously but that's how you'd set a picture in the middle of the screen and make sure its always drawn on top of everything else. Hope you find that useful, check out allegro if you want to get into low level graphics programming. It's probly the easiest and best 2d library there is.
edit: lawl I just noticed how old this post is