1 A GAME PROGRAMMING LIBRARY “Allegro Low Level Game ...
1 A GAME PROGRAMMING LIBRARY “Allegro Low Level Game ...
1 A GAME PROGRAMMING LIBRARY “Allegro Low Level Game ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
*<br />
* Example program for the Allegro library, by Shawn Hargreaves.<br />
*<br />
* This program demonstrates the use of memory bitmaps. It creates<br />
* a small temporary bitmap in memory, draws some circles onto it,<br />
* and then blits lots of copies of it onto the screen.<br />
*/<br />
#include <br />
#include <br />
#include "allegro.h"<br />
int main()<br />
{<br />
BITMAP *memory_bitmap;<br />
int x, y;<br />
}<br />
allegro_init();<br />
install_keyboard();<br />
set_gfx_mode(GFX_VGA, 320, 200, 0, 0);<br />
set_pallete(desktop_pallete);<br />
/* make a memory bitmap sized 20x20 */<br />
memory_bitmap = create_bitmap(20, 20);<br />
/*<br />
* Example program for the Allegro library, by Shawn Hargreaves.<br />
*<br />
* This program demonstrates how to get mouse input.<br />
*/<br />
#include <br />
#include <br />
#include "allegro.h"<br />
int main()<br />
{<br />
int mickeyx = 0;<br />
int mickeyy = 0;<br />
BITMAP *custom_cursor;<br />
char msg[80];<br />
int c = 0;<br />
allegro_init();<br />
install_keyboard();<br />
install_mouse();<br />
install_timer();<br />
set_gfx_mode(GFX_VGA, 320, 200, 0, 0);<br />
set_pallete(desktop_pallete);<br />
do {<br />
/* the mouse position is stored in the variables mouse_x and mouse_y */<br />
sprintf(msg, "mouse_x = %-5d", mouse_x);<br />
textout(screen, font, msg, 16, 16, 255);<br />
sprintf(msg, "mouse_y = %-5d", mouse_y);<br />
textout(screen, font, msg, 16, 32, 255);<br />
/* or you can use this function to measure the speed of movement.<br />
* Note that we only call it every fourth time round the loop:<br />
* there's no need for that other than to slow the numbers down<br />
* a bit so that you will have time to read them...<br />
*/<br />
c++;<br />
if ((c & 3) == 0)<br />
get_mouse_mickeys(&mickeyx, &mickeyy);<br />
/* draw some circles onto it */<br />
clear(memory_bitmap);<br />
for (x=0; x