-
Notifications
You must be signed in to change notification settings - Fork 0
/
foecommand.cc
100 lines (80 loc) · 2.13 KB
/
foecommand.cc
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
* $Id: foecommand.cc,v 1.2 2003/08/15 07:06:52 kenta Exp $
*
* Copyright 2003 Kenta Cho. All rights reserved.
*/
/**
* Handle bullet commands.
*
* @version $Revision: 1.2 $
*/
#include "bulletml/bulletmlparser.h"
#include "bulletml/bulletmlparser-tinyxml.h"
#include "bulletml/bulletmlrunner.h"
#include "foe.h"
extern "C" {
#include "rr.h"
#include "genmcr.h"
#include "degutil.h"
#include "ship.h"
}
FoeCommand::FoeCommand(BulletMLParser *parser, Foe *f)
: BulletMLRunner(parser) {
foe = f;
}
FoeCommand::FoeCommand(BulletMLState *state, Foe *f)
: BulletMLRunner(state) {
foe = f;
}
FoeCommand::~FoeCommand() {}
float FoeCommand::getBulletDirection() {
return (float)foe->d*360/DIV;
}
float FoeCommand::getAimDirection() {
int d = getPlayerDeg(foe->pos.x, foe->pos.y);
if ( foe->xReverse == -1 ) d = (-d)&1023;
return ((float)d*360/DIV);
}
float FoeCommand::getBulletSpeed() {
return ((float)foe->spd)/COMMAND_SCREEN_SPD_RATE;
}
float FoeCommand::getDefaultSpeed() {
return 1;
}
float FoeCommand::getRank() {
return foe->rank;
}
void FoeCommand::createSimpleBullet(float direction, float speed) {
int d = (int)(direction*DIV/360); d &= (DIV-1);
addFoeNormalBullet(foe, d, (int)(speed*COMMAND_SCREEN_SPD_RATE), foe->color+1);
foe->fireCnt++;
}
void FoeCommand::createBullet(BulletMLState* state, float direction, float speed) {
int d = (int)(direction*DIV/360); d &= (DIV-1);
addFoeActiveBullet(foe, d, (int)(speed*COMMAND_SCREEN_SPD_RATE), foe->color+1, state);
foe->fireCnt++;
}
int FoeCommand::getTurn() {
return tick;
}
void FoeCommand::doVanish() {
removeFoeCommand(foe);
}
void FoeCommand::doChangeDirection(float d) {
foe->d = (int)(d*DIV/360);
}
void FoeCommand::doChangeSpeed(float s) {
foe->spd = (int)(s*COMMAND_SCREEN_SPD_RATE);
}
void FoeCommand::doAccelX(float ax) {
foe->vel.x = (int)(ax*COMMAND_SCREEN_VEL_RATE);
}
void FoeCommand::doAccelY(float ay) {
foe->vel.y = (int)(ay*COMMAND_SCREEN_VEL_RATE);
}
float FoeCommand::getBulletSpeedX() {
return ((float)foe->vel.x/COMMAND_SCREEN_VEL_RATE);
}
float FoeCommand::getBulletSpeedY() {
return ((float)foe->vel.y/COMMAND_SCREEN_VEL_RATE);
}