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() {}
double FoeCommand::getBulletDirection() {
return (double)foe->d*360/DIV;
}
double FoeCommand::getAimDirection() {
int d = getPlayerDeg(foe->pos.x, foe->pos.y);
if ( foe->xReverse == -1 ) d = (-d)&1023;
return ((double)d*360/DIV);
}
double FoeCommand::getBulletSpeed() {
return ((double)foe->spd)/COMMAND_SCREEN_SPD_RATE;
}
double FoeCommand::getDefaultSpeed() {
return 1;
}
double FoeCommand::getRank() {
return foe->rank;
}
void FoeCommand::createSimpleBullet(double direction, double 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, double direction, double 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(double d) {
foe->d = (int)(d*DIV/360) & (DIV-1);
}
void FoeCommand::doChangeSpeed(double s) {
foe->spd = (int)(s*COMMAND_SCREEN_SPD_RATE);
}
void FoeCommand::doAccelX(double ax) {
foe->vel.x = (int)(ax*COMMAND_SCREEN_VEL_RATE);
}
void FoeCommand::doAccelY(double ay) {
foe->vel.y = (int)(ay*COMMAND_SCREEN_VEL_RATE);
}
double FoeCommand::getBulletSpeedX() {
return ((double)foe->vel.x/COMMAND_SCREEN_VEL_RATE);
}
double FoeCommand::getBulletSpeedY() {
return ((double)foe->vel.y/COMMAND_SCREEN_VEL_RATE);
}
|