#include <stdlib.h>
#include <vgagames2.h>
int main(int argc, char ** argv) {
bitmap * bmp;
int x,y,color;
/* first call: initialize vgagames, always pass argv[0] */
if (vg_init_vgagames(argv[0],0,NULL) < 0) {exit(1);}
/* creating window */
if (vg_window_open("Some titlename",0,0) < 0) {exit(1);}
/* load a bitmap */
bmp=vg_bitmap_createfromfile("bitmaps/bmp.vga");
if (bmp==NULL) {vg_window_close(); exit(1);} // error
/* program loop */
for (;;) {
/* get keystrokes */
vg_key_update();
/* examinate keystrokes: check for Space-key to leave the loop */
if (vg_key_pressed(KEY_SPACE, SHORTKEY)) {break;}
/* clear the window (not visible unless called vg_window_flush()) */
vg_bitmap_clear(NULL, RGB_BLACK); // bitmap NULL represents the window
/* copy the bitmap bmp to the window at position x,y */
x=10; y=10;
vg_bitmap_copyto(NULL,x,y,bmp,0,0,0,0,RGB_FULL);
/* draw a yellow line from 100,50 to 150,50 to the window */
color=vg_color_index(CL_YELLOW,100); // get index of current yellow color
vg_draw_line(NULL,100,50,150,50,color);
/* flush out the window (make it visible) */
vg_window_flush();
/* wait a time until 70 milliseconds for this loop have been reached */
vg_wait_time(70);
} /* end of game loop */
/* close the window */
vg_window_close();
exit(0);
}
|