123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- /*--------------------------------------------------------------------------
- DEPUI-GFX-TK 3.0 - GPL portable source code libraries
- http://www.deleveld.dds.nl/depui.htm
- See file docs/copying for copyright details
- ---------------------------------------------------------------------------*/
- #define MXMODULE_BITLINE
- #define MXMODULE_LOADTGA
- #include "degfx/degfx.c"
- #include <time.h>
- int x, y, dx, dy;
- static MX_BITMAP *bitmap;
- static void draw(const MX_RECT * r)
- {
- /* Draw a background */
- mx_rectfill(r->x1, r->y1, r->x2, r->y2, MXCOLOR_lightskyblue3);
- /* Draw the bitmap on the screen */
- mx_blit(bitmap, 0, 0, x, y, MXDEFAULT, MXDEFAULT);
- }
- int main(int argc, char *argv[])
- {
- (void) argc;
- (void) argv;
- /* Start the graphic system */
- if (!mx_gfx_start(0))
- return 1;
- /* Load in the bitmap */
- bitmap = mx_bitmap_tga("title.tga");
- if (!bitmap)
- return 2;
- /* Start it in the upper left */
- x = 0;
- y = 0;
- dx = 1;
- dy = 1;
- /* Tell what the redraw funtion is */
- mx_gfx_redraw(draw);
- /* Main loop */
- while (mx_gfx_poll()) {
- MX_RECT rect;
- /* Get some screen info */
- const MX_GFX_ARGS *info = mx_gfx_info();
- const MX_RECT *screen = &info->screen;
- /* Move the pointer */
- mx_gfx_pointer(0, 0, 0);
- /* Exit when key is hit */
- if (mx_gfx_key(0, 0))
- break;
- /* Update where the bitmap was */
- rect = *MXRECT(bitmap);
- rect.x1 += x;
- rect.y1 += y;
- rect.x2 += x;
- rect.y2 += y;
- mx_gfx_dirty(&rect);
- /* Move the bitmap */
- x += dx;
- y += dy;
- /* Keep the bitmap on the screen */
- if (x < screen->x1)
- dx *= -1;
- if (x + mx_w(bitmap) > screen->x2)
- dx *= -1;
- if (y < screen->y1)
- dy *= -1;
- if (y + mx_h(bitmap) > screen->y2)
- dy *= -1;
- /* Update where the bitmap is now */
- rect = *MXRECT(bitmap);
- rect.x1 += x;
- rect.y1 += y;
- rect.x2 += x;
- rect.y2 += y;
- mx_gfx_dirty(&rect);
- }
- /* Free the bitmap */
- mx_delete(bitmap);
- return 0;
- }
|