-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcommand.cpp
executable file
·50 lines (37 loc) · 1.43 KB
/
command.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "command.h"
#include "vaisseau_data.h"
void handle_command(struct command *cmd)
{
struct vaisseau_data *vaisseau=cmd->controlled_ship;
if (!(vaisseau->landed)||(vaisseau->rebound))
{
if (cmd->left) // Left arrow?
vaisseau->angle-=vaisseau->anglestep; // yes, on tourne a droite
if (cmd->right) // Right arrow?
vaisseau->angle+= vaisseau->anglestep; // yes, on tourne a gauche
}
if (vaisseau->fuel > 0 && cmd->thrust)
{ // thrust?
vaisseau->sprite_buffer = vaisseau->gfx->sprite_thrust; // pointe le sprite thrust
vaisseau->thrust = vaisseau->thrust_max; // acceleration
vaisseau->shield = FALSE; // shield desactiv
vaisseau->landed = FALSE; // pas pos
}
else
{
vaisseau->shield = cmd->shield ; // shield activ
if (vaisseau->shield && vaisseau->shield_force>0) // test shield si pas thrust
vaisseau->sprite_buffer = vaisseau->gfx->sprite_shield; // oui shield
else
vaisseau->sprite_buffer = vaisseau->gfx->sprite; // non, normal
vaisseau->thrust = itofix(0); // pas de thrust
}
if (cmd->fire && !vaisseau->fire && !vaisseau->shield)
vaisseau->fire_delay=TRUE;
else
vaisseau->fire_delay=FALSE;
if (cmd->fire && !vaisseau->shield)
vaisseau->fire=TRUE;
else
vaisseau->fire=FALSE;
}