summaryrefslogtreecommitdiff
path: root/Unit.c
diff options
context:
space:
mode:
Diffstat (limited to 'Unit.c')
-rw-r--r--Unit.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/Unit.c b/Unit.c
index 3bede4a..e0da0e6 100644
--- a/Unit.c
+++ b/Unit.c
@@ -9,6 +9,8 @@
* Defines *
* **************************************/
+#define MAX_ACTION_LEVELS 2
+
/* **************************************
* Local prototypes *
* **************************************/
@@ -28,16 +30,27 @@ typedef struct
void (*pAction)(TYPE_UNIT*);
}TYPE_UNIT_ACTION;
+typedef enum t_availableactions
+{
+ ACTION_BUILD = 0,
+ ACTION_ATTACK,
+ MAX_ACTIONS
+}UNIT_AVAILABLE_ACTIONS;
+
/* Sprites */
static TYPE_SPRITE PeasantSpr;
static TYPE_SPRITE PeasantWalkingSpr;
/* Tables */
-static uint8_t const UnitHPTable[] = { 25 };
-static uint8_t const UnitSpeedTable[] = { 1 };
+static uint8_t const UnitHPTable[] = { [PEASANT] = 25 };
+static uint8_t const UnitSpeedTable[] = { [PEASANT] = 1 };
-static TYPE_UNIT_ACTION const UnitActionsTable_Level0[] = { {"Build", NULL} };
-static TYPE_UNIT_ACTION const UnitActionsTable_Level1[] = { {"Barracks", &UnitBuildAccept} };
+static TYPE_UNIT_ACTION const UnitActionsTable_Level0[MAX_ACTIONS] = { [ACTION_BUILD] = {"Build", NULL},
+ [ACTION_ATTACK] = {"Attack", NULL} };
+static TYPE_UNIT_ACTION const UnitActionsTable_Level1[MAX_ACTIONS] = { {"Barracks", &UnitBuildAccept} };
+
+static TYPE_UNIT_ACTION* const UnitActionsTable_LevelX[MAX_ACTION_LEVELS] = { &UnitActionsTable_Level0 ,
+ &UnitActionsTable_Level1 };
static TYPE_SPRITE * const UnitSprTable[] = {&PeasantSpr};
static TYPE_SPRITE * const UnitWalkingSprTable[] = {&PeasantWalkingSpr};
@@ -210,10 +223,7 @@ void UnitHandler(TYPE_UNIT * ptrUnit)
ptrUnit->mirror = true;
}
- if(bMoving == false)
- {
- ptrUnit->walking = false;
- }
+ ptrUnit->walking = bMoving;
}
}