1 /* multi - a SDL_haa sample with more than one actor
3 * This file is in the public domain, furnished "as is", without technical
4 * support, and with no warranty, express or implied, as to its usefulness for
16 static SDL_Surface *screen;
18 static HAA_Actor *actor1, *actor2, *actor3;
20 static int degrees = 0;
22 static Uint32 tick(Uint32 interval, void* param)
25 e.type = SDL_USEREVENT;
27 degrees = (degrees+2) % 360;
28 SDL_PushEvent((SDL_Event*)&e);
36 res = SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER);
42 screen = SDL_SetVideoMode(0, 0, 16, SDL_SWSURFACE);
45 SDL_TimerID timer = SDL_AddTimer(1, tick, NULL);
46 assert(timer != NULL);
48 actor1 = HAA_CreateActor(0, 200, 200, 16);
51 actor2 = HAA_CreateActor(0, 200, 200, 16);
54 actor3 = HAA_CreateActor(0, 200, 200, 16);
57 SDL_FillRect(actor1->surface, NULL,
58 SDL_MapRGB(actor1->surface->format, 255, 0, 0));
59 SDL_FillRect(actor2->surface, NULL,
60 SDL_MapRGB(actor2->surface->format, 0, 255, 0));
61 SDL_FillRect(actor3->surface, NULL,
62 SDL_MapRGB(actor3->surface->format, 0, 0, 255));
64 HAA_SetPosition(actor1, 100, 150);
67 HAA_SetPosition(actor2, 300, 150);
70 HAA_SetPosition(actor3, 500, 150);
73 res = HAA_Flip(actor1);
75 res = HAA_Flip(actor2);
77 res = HAA_Flip(actor3);
81 while (SDL_WaitEvent(&event)) {
82 if (HAA_FilterEvent(&event) == 0) continue;
87 res = HAA_Flip(actor1);
89 res = HAA_Flip(actor2);
91 res = HAA_Flip(actor3);
95 HAA_SetRotation(actor1, HAA_X_AXIS, degrees, 0, 0, 0);
96 HAA_SetRotation(actor2, HAA_Y_AXIS, degrees, 0, 0, 0);
97 HAA_SetRotation(actor3, HAA_Z_AXIS, degrees, 0, 0, 0);
98 res = HAA_Commit(actor1);
100 res = HAA_Commit(actor2);
102 res = HAA_Commit(actor3);
109 HAA_FreeActor(actor1);
110 HAA_FreeActor(actor2);
111 HAA_FreeActor(actor3);