summaryrefslogtreecommitdiff
path: root/src/gameui.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gameui.c')
-rw-r--r--src/gameui.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/gameui.c b/src/gameui.c
index fa96244..c099e45 100644
--- a/src/gameui.c
+++ b/src/gameui.c
@@ -11,13 +11,36 @@ do { \
gUI->renderList[idx].onmousebuttonevent_proc = mouseevt; \
} while(0)
+void testevent(struct _renderItem_t *self, Uint8 button, Uint8 state, gameState_t *gState) {
+ printf("BLAH !\n");
+}
int buildGameRenderList(gameRess_t *gRess, gameUI_t *gUI) {
- SET_RENDER_ITEM(RLI_terrain, gUI->terrainSprite,0,0,0,1,0,NULL);
+ SET_RENDER_ITEM(RLI_terrain, gUI->terrainSprite,0,0,0,1,2,NULL);
+
+ SET_RENDER_ITEM(RLI_lem0, gRess->lemmingAnims[0],700,200,0,0,5,testevent);
SET_RENDER_ITEM(RLI_cursor, gRess->cursor,0,0,0,1,0,NULL);
+ gUI->cursor = &gUI->renderList[RLI_cursor];
return 0;
}
+renderItem_t * findActionnableItemUnderCursor(gameUI_t *gUI) {
+ int i;
+ for (i=MAX_RENDERLIST_SIZE-1; i>=0; i--) {
+ if ( gUI->renderList[i].onmousebuttonevent_proc ) {
+ SDL_Rect curhot;
+ curhot.x=gUI->cursor->x + gUI->cursor->sprite->size.w / 2;
+ curhot.y=gUI->cursor->y + gUI->cursor->sprite->size.h / 2;
+ curhot.w=1; curhot.h=1;
+
+ if ( SDL_HasIntersection(&curhot, &gUI->renderList[i].lastDstRect) ) {
+ return &gUI->renderList[i];
+ }
+ }
+ }
+
+ return NULL;
+}