[airstrike] Triggers and level ending
Erik Auerswald
auerswal at unix-ag.uni-kl.de
Tue Jul 12 12:29:13 EDT 2005
Hi,
> I think Erik's self-destruct button would be nice (or dying after some
> time).
I've implemented a simple suicide key in engine/ai.c by using
msg_set_damage(30) in the player_message() function. I don't like
the hardcoded damage value, but I do not know how to query the actual
hitpoints (or their starting value), therefor I have not yet commited
the changes. If someone could tell me how to query the hitpoints I would
do a cleaner implementation, otherwise I can commit the code as it is.
Attached is an svn diff of my changes so far.
Erik
-------------- next part --------------
Index: src/tests/testengine.c
===================================================================
--- src/tests/testengine.c (revision 25)
+++ src/tests/testengine.c (working copy)
@@ -139,18 +139,20 @@
printf(" ESC -- Exit game\n\n");
printf("Player 1:\n");
- printf(" Up -- Left arrow\n");
- printf(" Down -- Right arrow\n");
- printf(" Accelerate -- Up arrow\n");
- printf(" Fire bullet -- Right Shift\n");
- printf(" Drop bomb -- Right Ctrl\n\n");
+ printf(" Up -- Left arrow\n");
+ printf(" Down -- Right arrow\n");
+ printf(" Accelerate -- Up arrow\n");
+ printf(" Fire bullet -- Right Shift\n");
+ printf(" Drop bomb -- Right Ctrl\n");
+ printf(" Self-destruct -- Backspace\n\n");
printf("Player 2:\n");
- printf(" Up -- x\n");
- printf(" Down -- c\n");
- printf(" Accelerate -- q\n");
- printf(" Fire bullet -- Left Alt\n");
- printf(" Drop bomb -- TAB\n\n");
+ printf(" Up -- x\n");
+ printf(" Down -- c\n");
+ printf(" Accelerate -- q\n");
+ printf(" Fire bullet -- Left Alt\n");
+ printf(" Drop bomb -- TAB\n");
+ printf(" Self-destruct -- s\n\n");
printf("Note unless you give two -ai options, the game starts in single\n"
"player mode. I.e. only the first plane is user controllable.\n\n");
Index: src/engine/ai.c
===================================================================
--- src/engine/ai.c (revision 25)
+++ src/engine/ai.c (working copy)
@@ -52,6 +52,7 @@
int key_right;
int key_fire;
int key_drop;
+ int key_suicide;
/* Joystick */
int joy_no; /* negative for no joystick */
int joy_accelerate;
@@ -60,6 +61,7 @@
int joy_right;
int joy_fire;
int joy_drop;
+ int joy_suicide;
};
static enum msgret player_message(ai_t *ai, sprite_t *target, msg_t message)
@@ -93,6 +95,11 @@
joy_active(pai->joy_no, pai->joy_drop))
obj_message(target,msg_ctrl(MSG_DROP));
+ if (key_pressed(pai->key_suicide) ||
+ joy_active(pai->joy_no, pai->joy_suicide))
+ /* biplane red baron has 30 hitpoints */
+ obj_message(target,msg_set_damage(30));
+
return MSG_RET_CONT;
case MSG_CAN_HAVE_AI:
return MSG_RET_YES;
@@ -115,6 +122,7 @@
ai->key_right = conf_number(key_conf,"right",SDLK_RIGHT);
ai->key_fire = conf_number(key_conf,"fire",SDLK_RSHIFT);
ai->key_drop = conf_number(key_conf,"drop",SDLK_RCTRL);
+ ai->key_suicide = conf_number(key_conf,"suicide",SDLK_BACKSPACE);
}
else if (player_nr == 2)
{
@@ -125,6 +133,7 @@
ai->key_right = conf_number(key_conf,"right",SDLK_c);
ai->key_fire = conf_number(key_conf,"fire",SDLK_LALT);
ai->key_drop = conf_number(key_conf,"drop",SDLK_TAB);
+ ai->key_suicide = conf_number(key_conf,"suicide",SDLK_s);
}
else
{
@@ -140,6 +149,7 @@
ai->joy_right = conf_number(key_conf,"joy_right",JOY_AXIS0_POS);
ai->joy_fire = conf_number(key_conf,"joy_fire",JOY_BUTTON0);
ai->joy_drop = conf_number(key_conf,"joy_drop",JOY_BUTTON1);
+ ai->joy_suicide = conf_number(key_conf,"joy_drop",JOY_BUTTON3);
/* try to open joystick and set joy_no to -1 on error */
ai->joy_no = open_joystick(ai->joy_no);
More information about the airstrike
mailing list