shit!
This commit is contained in:
parent
1702a06d9f
commit
364a34ce33
20 changed files with 453 additions and 64 deletions
67
src/global.h
67
src/global.h
|
|
@ -50,15 +50,16 @@ void updateControls(u16 joy, u16 changed, u16 state){
|
|||
struct playerStruct {
|
||||
Vect2D_f32 pos, vel;
|
||||
s16 shotAngle;
|
||||
u8 lives;
|
||||
u8 lives, recoveringClock;
|
||||
fix32 camera, yCamera;
|
||||
Sprite* image;
|
||||
};
|
||||
struct playerStruct player;
|
||||
bool killBullets;
|
||||
|
||||
|
||||
// bullets
|
||||
#define BULLET_COUNT 64
|
||||
#define BULLET_COUNT 70
|
||||
|
||||
struct bulletSpawner {
|
||||
fix32 x, y, speed;
|
||||
|
|
@ -92,6 +93,31 @@ struct enemy {
|
|||
};
|
||||
struct enemy enemies[ENEMY_COUNT];
|
||||
|
||||
// humans
|
||||
#define HUMAN_COUNT 8
|
||||
#define HUMAN_WALKING 0
|
||||
#define HUMAN_CARRIED 1
|
||||
#define HUMAN_FALLING 2
|
||||
|
||||
struct human {
|
||||
bool active;
|
||||
u8 state;
|
||||
s16 carriedBy;
|
||||
Vect2D_f32 pos, vel;
|
||||
Sprite* image;
|
||||
};
|
||||
struct human humans[HUMAN_COUNT];
|
||||
bool humanBeingCarried;
|
||||
|
||||
void killHuman(u8 i){
|
||||
if(humans[i].state == HUMAN_CARRIED && humans[i].carriedBy >= 0){
|
||||
enemies[humans[i].carriedBy].ints[3] = -1;
|
||||
humanBeingCarried = FALSE;
|
||||
}
|
||||
humans[i].active = FALSE;
|
||||
SPR_releaseSprite(humans[i].image);
|
||||
}
|
||||
|
||||
void killBullet(u8 i, bool explode){
|
||||
if(explode){
|
||||
if(bullets[i].player){
|
||||
|
|
@ -120,6 +146,16 @@ void killBullet(u8 i, bool explode){
|
|||
}
|
||||
|
||||
void killEnemy(u8 i){
|
||||
if(enemies[i].ints[3] >= 0){
|
||||
s16 h = enemies[i].ints[3];
|
||||
if(humans[h].active){
|
||||
humans[h].state = HUMAN_FALLING;
|
||||
humans[h].carriedBy = -1;
|
||||
humans[h].vel.x = 0;
|
||||
humans[h].vel.y = FIX32(2);
|
||||
}
|
||||
humanBeingCarried = FALSE;
|
||||
}
|
||||
enemies[i].active = FALSE;
|
||||
SPR_releaseSprite(enemies[i].image);
|
||||
}
|
||||
|
|
@ -142,4 +178,31 @@ static s16 getScreenX(fix32 worldX, fix32 camera) {
|
|||
screenX -= GAME_WRAP;
|
||||
}
|
||||
return fix32ToInt(screenX);
|
||||
}
|
||||
|
||||
|
||||
// homing
|
||||
#define PI_MOD 2.84444444444
|
||||
#define PI_F FIX16(3.14159265358 * PI_MOD)
|
||||
#define PI_F_2 FIX16(1.57079632679 * PI_MOD)
|
||||
#define PI_F_4 FIX16(0.78539816339 * PI_MOD)
|
||||
fix16 arctan(fix16 x) {
|
||||
return fix16Mul(PI_F_4, x) - fix16Mul(fix16Mul(x, (abs(x) - 1)), (FIX16(0.245) + fix16Mul(FIX16(0.066), abs(x))));
|
||||
}
|
||||
fix16 arctan2(fix16 y, fix16 x) {
|
||||
return x >= 0 ?
|
||||
(y >= 0 ? (y < x ? arctan(fix16Div(y, x)) : PI_F_2 - arctan(fix16Div(x, y))) : (-y < x ? arctan(fix16Div(y, x)) : -PI_F_2 - arctan(fix16Div(x, y)))) :
|
||||
(y >= 0 ? (y < -x ? arctan(fix16Div(y, x)) + PI_F : PI_F_2 - arctan(fix16Div(x, y))) : (-y < -x ? arctan(fix16Div(y, x)) - PI_F : -PI_F_2 - arctan(fix16Div(x, y))));
|
||||
}
|
||||
s16 arcAngle;
|
||||
s16 honeAngle(fix16 x1, fix16 x2, fix16 y1, fix16 y2){
|
||||
arcAngle = arctan2(y2 - y1, x2 - x1);
|
||||
if(arcAngle >= 128) arcAngle -= 32;
|
||||
if(arcAngle >= 384) arcAngle -= 32;
|
||||
if(arcAngle < 0){
|
||||
arcAngle = 1024 + arcAngle;
|
||||
if(arcAngle < 896) arcAngle += 32;
|
||||
if(arcAngle < 640) arcAngle += 32;
|
||||
}
|
||||
return arcAngle;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue