wow lots going on
This commit is contained in:
parent
6e15ee3d82
commit
7d227606d8
89
combat.c
89
combat.c
|
@ -39,13 +39,33 @@ void setupBullet(
|
||||||
bullet->velocityStep = 0;
|
bullet->velocityStep = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int maybeFireShotCount(
|
||||||
|
struct BulletPosition rabbitBulletPosition[],
|
||||||
|
int availableBullets[],
|
||||||
|
int count
|
||||||
|
) {
|
||||||
|
int i, remaining = count;
|
||||||
|
|
||||||
|
for (i = 0; i < RABBIT_BULLET_LIMIT; ++i) {
|
||||||
|
if (rabbitBulletPosition[i].isActive == 0) {
|
||||||
|
availableBullets[count - remaining] = i;
|
||||||
|
|
||||||
|
remaining--;
|
||||||
|
if (remaining == 0) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return remaining == 0;
|
||||||
|
}
|
||||||
|
|
||||||
int attemptToFireRabbitBullet(
|
int attemptToFireRabbitBullet(
|
||||||
struct RabbitPosition *rabbitPosition,
|
struct RabbitPosition *rabbitPosition,
|
||||||
struct RabbitWeaponry *rabbitWeaponry,
|
struct RabbitWeaponry *rabbitWeaponry,
|
||||||
struct BulletPosition rabbitBulletPosition[]
|
struct BulletPosition rabbitBulletPosition[]
|
||||||
) {
|
) {
|
||||||
int okToFire = 0, i, mouseAngle;
|
int okToFire = 0, i, mouseAngle;
|
||||||
int availableBullets[3];
|
int availableBullets[4];
|
||||||
|
float beamOffsetX, beamOffsetY;
|
||||||
|
|
||||||
if (rabbitWeaponry->cooldown > 0) return 0;
|
if (rabbitWeaponry->cooldown > 0) return 0;
|
||||||
mouseAngle = rabbitPosition->mouseAngle;
|
mouseAngle = rabbitPosition->mouseAngle;
|
||||||
|
@ -53,15 +73,11 @@ int attemptToFireRabbitBullet(
|
||||||
rabbitWeaponry->cooldown = RABBIT_BULLET_COOLDOWN;
|
rabbitWeaponry->cooldown = RABBIT_BULLET_COOLDOWN;
|
||||||
|
|
||||||
if (rabbitWeaponry->currentWeapon == WEAPON_TYPE_SINGLE_SHOT_GUN) {
|
if (rabbitWeaponry->currentWeapon == WEAPON_TYPE_SINGLE_SHOT_GUN) {
|
||||||
for (i = 0; i < RABBIT_BULLET_LIMIT; ++i) {
|
if (!maybeFireShotCount(
|
||||||
if (rabbitBulletPosition[i].isActive == 0) {
|
rabbitBulletPosition,
|
||||||
okToFire = 1;
|
availableBullets,
|
||||||
availableBullets[0] = i;
|
1
|
||||||
break;
|
)) return 0;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!okToFire) return 0;
|
|
||||||
|
|
||||||
setupBullet(
|
setupBullet(
|
||||||
&rabbitBulletPosition[availableBullets[0]],
|
&rabbitBulletPosition[availableBullets[0]],
|
||||||
|
@ -72,14 +88,11 @@ int attemptToFireRabbitBullet(
|
||||||
);
|
);
|
||||||
} else if (rabbitWeaponry->currentWeapon == WEAPON_TYPE_SPREAD_SHOT_GUN) {
|
} else if (rabbitWeaponry->currentWeapon == WEAPON_TYPE_SPREAD_SHOT_GUN) {
|
||||||
// make sure three bullets are available
|
// make sure three bullets are available
|
||||||
for (i = 0; i < RABBIT_BULLET_LIMIT; ++i) {
|
if (!maybeFireShotCount(
|
||||||
if (rabbitBulletPosition[i].isActive == 0) {
|
rabbitBulletPosition,
|
||||||
availableBullets[okToFire++] = i;
|
availableBullets,
|
||||||
if (okToFire == 3) break;
|
3
|
||||||
}
|
)) return 0;
|
||||||
}
|
|
||||||
|
|
||||||
if (okToFire < 3) return 0;
|
|
||||||
|
|
||||||
// if so, fire away
|
// if so, fire away
|
||||||
for (i = 0; i < 3; ++i) {
|
for (i = 0; i < 3; ++i) {
|
||||||
|
@ -91,6 +104,27 @@ int attemptToFireRabbitBullet(
|
||||||
RABBIT_BULLET_VELOCITY
|
RABBIT_BULLET_VELOCITY
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
} else if (rabbitWeaponry->currentWeapon == WEAPON_TYPE_BEAM_SHOT_GUN) {
|
||||||
|
// make sure three bullets are available
|
||||||
|
if (!maybeFireShotCount(
|
||||||
|
rabbitBulletPosition,
|
||||||
|
availableBullets,
|
||||||
|
4
|
||||||
|
)) return 0;
|
||||||
|
|
||||||
|
// if so, fire away
|
||||||
|
for (i = 0; i < 4; ++i) {
|
||||||
|
beamOffsetX = sin(mouseAngle * DEG2RAD) * i * 2;
|
||||||
|
beamOffsetY = -cos(mouseAngle * DEG2RAD) * i * 2;
|
||||||
|
|
||||||
|
setupBullet(
|
||||||
|
&rabbitBulletPosition[availableBullets[i]],
|
||||||
|
rabbitPosition->rabbitPosition[0] + beamOffsetX,
|
||||||
|
rabbitPosition->rabbitPosition[1] + beamOffsetY,
|
||||||
|
mouseAngle,
|
||||||
|
RABBIT_BULLET_VELOCITY
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -262,6 +296,7 @@ void buildCollisionGrids(
|
||||||
struct PlayerPowerup *playerPowerup
|
struct PlayerPowerup *playerPowerup
|
||||||
) {
|
) {
|
||||||
int grid, i;
|
int grid, i;
|
||||||
|
struct CompiledSpriteRender *which;
|
||||||
|
|
||||||
for (grid = 0; grid < 4; ++grid) {
|
for (grid = 0; grid < 4; ++grid) {
|
||||||
rabbitBulletGridIndex[grid] = 0;
|
rabbitBulletGridIndex[grid] = 0;
|
||||||
|
@ -279,17 +314,17 @@ void buildCollisionGrids(
|
||||||
|
|
||||||
switch (playerPowerup->type) {
|
switch (playerPowerup->type) {
|
||||||
case POWERUP_TYPE_SHOTGUN:
|
case POWERUP_TYPE_SHOTGUN:
|
||||||
shotgun.x = playerPowerup->x;
|
which = &shotgun;
|
||||||
shotgun.y = playerPowerup->y;
|
|
||||||
determineGridPositionsForSprite(&shotgun);
|
|
||||||
break;
|
break;
|
||||||
case POWERUP_TYPE_SHIELD_KILLER:
|
case POWERUP_TYPE_BEAM_WEAPON:
|
||||||
shieldKiller.x = playerPowerup->x;
|
which = &beam;
|
||||||
shieldKiller.y = playerPowerup->y;
|
|
||||||
determineGridPositionsForSprite(&shieldKiller);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
which->x = playerPowerup->x;
|
||||||
|
which->y = playerPowerup->y;
|
||||||
|
determineGridPositionsForSprite(which);
|
||||||
|
|
||||||
for (grid = 0; grid < 4; ++grid) {
|
for (grid = 0; grid < 4; ++grid) {
|
||||||
powerupGrid[grid] = gridPosition[grid];
|
powerupGrid[grid] = gridPosition[grid];
|
||||||
}
|
}
|
||||||
|
@ -474,8 +509,8 @@ int handleRabbitToPowerupCollision(
|
||||||
case POWERUP_TYPE_SHOTGUN:
|
case POWERUP_TYPE_SHOTGUN:
|
||||||
which = &shotgun;
|
which = &shotgun;
|
||||||
break;
|
break;
|
||||||
case POWERUP_TYPE_SHIELD_KILLER:
|
case POWERUP_TYPE_BEAM_WEAPON:
|
||||||
which = &shieldKiller;
|
which = &beam;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
6
combat.h
6
combat.h
|
@ -57,3 +57,9 @@ void handleEnemyKills(
|
||||||
);
|
);
|
||||||
|
|
||||||
void fireCurrentWeaponOnce(struct RabbitWeaponry*);
|
void fireCurrentWeaponOnce(struct RabbitWeaponry*);
|
||||||
|
|
||||||
|
int maybeFireShotCount(
|
||||||
|
struct BulletPosition rabbitBulletPosition[],
|
||||||
|
int availableBullets[],
|
||||||
|
int count
|
||||||
|
);
|
||||||
|
|
|
@ -60,6 +60,90 @@ void TestFireCurrentWeaponOnce_TwoRoundsRemaining(CuTest *tc) {
|
||||||
CuAssertIntEquals(tc, 1, rabbitWeaponry.currentWeaponRemainingRounds);
|
CuAssertIntEquals(tc, 1, rabbitWeaponry.currentWeaponRemainingRounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestMaybeFireShotCount_NotOK(CuTest *tc) {
|
||||||
|
struct BulletPosition rabbitBulletPosition[RABBIT_BULLET_LIMIT];
|
||||||
|
int availableBullets[1] = { -1 };
|
||||||
|
int i, result;
|
||||||
|
|
||||||
|
for (i = 0; i < RABBIT_BULLET_LIMIT; ++i) {
|
||||||
|
rabbitBulletPosition[i].isActive = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = maybeFireShotCount(
|
||||||
|
rabbitBulletPosition,
|
||||||
|
availableBullets,
|
||||||
|
1
|
||||||
|
);
|
||||||
|
|
||||||
|
CuAssertIntEquals(tc, 0, result);
|
||||||
|
CuAssertIntEquals(tc, availableBullets[0], -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestMaybeFireShotCount_OK(CuTest *tc) {
|
||||||
|
struct BulletPosition rabbitBulletPosition[RABBIT_BULLET_LIMIT];
|
||||||
|
int availableBullets[1] = { -1 };
|
||||||
|
int i, result;
|
||||||
|
|
||||||
|
for (i = 0; i < RABBIT_BULLET_LIMIT; ++i) {
|
||||||
|
rabbitBulletPosition[i].isActive = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
rabbitBulletPosition[4].isActive = 0;
|
||||||
|
|
||||||
|
result = maybeFireShotCount(
|
||||||
|
rabbitBulletPosition,
|
||||||
|
availableBullets,
|
||||||
|
1
|
||||||
|
);
|
||||||
|
|
||||||
|
CuAssertIntEquals(tc, 1, result);
|
||||||
|
CuAssertIntEquals(tc, availableBullets[0], 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestMaybeFireShotCount_NotEnoughAvailable(CuTest *tc) {
|
||||||
|
struct BulletPosition rabbitBulletPosition[RABBIT_BULLET_LIMIT];
|
||||||
|
int availableBullets[2] = { -1, -1 };
|
||||||
|
int i, result;
|
||||||
|
|
||||||
|
for (i = 0; i < RABBIT_BULLET_LIMIT; ++i) {
|
||||||
|
rabbitBulletPosition[i].isActive = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
rabbitBulletPosition[4].isActive = 0;
|
||||||
|
|
||||||
|
result = maybeFireShotCount(
|
||||||
|
rabbitBulletPosition,
|
||||||
|
availableBullets,
|
||||||
|
2
|
||||||
|
);
|
||||||
|
|
||||||
|
CuAssertIntEquals(tc, 0, result);
|
||||||
|
CuAssertIntEquals(tc, 4, availableBullets[0]);
|
||||||
|
CuAssertIntEquals(tc, -1, availableBullets[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestMaybeFireShotCount_EnoughAvailable(CuTest *tc) {
|
||||||
|
struct BulletPosition rabbitBulletPosition[RABBIT_BULLET_LIMIT];
|
||||||
|
int availableBullets[2] = { -1, -1 };
|
||||||
|
int i, result;
|
||||||
|
|
||||||
|
for (i = 0; i < RABBIT_BULLET_LIMIT; ++i) {
|
||||||
|
rabbitBulletPosition[i].isActive = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
rabbitBulletPosition[4].isActive = 0;
|
||||||
|
rabbitBulletPosition[6].isActive = 0;
|
||||||
|
|
||||||
|
result = maybeFireShotCount(
|
||||||
|
rabbitBulletPosition,
|
||||||
|
availableBullets,
|
||||||
|
2
|
||||||
|
);
|
||||||
|
|
||||||
|
CuAssertIntEquals(tc, 1, result);
|
||||||
|
CuAssertIntEquals(tc, 4, availableBullets[0]);
|
||||||
|
CuAssertIntEquals(tc, 6, availableBullets[1]);
|
||||||
|
}
|
||||||
|
|
||||||
CuSuite *CombatGetSuite() {
|
CuSuite *CombatGetSuite() {
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
|
@ -67,5 +151,9 @@ CuSuite *CombatGetSuite() {
|
||||||
SUITE_ADD_TEST(suite, TestFireCurrentWeaponOnce_NoRoundsRemaining);
|
SUITE_ADD_TEST(suite, TestFireCurrentWeaponOnce_NoRoundsRemaining);
|
||||||
SUITE_ADD_TEST(suite, TestFireCurrentWeaponOnce_OneRoundRemaining);
|
SUITE_ADD_TEST(suite, TestFireCurrentWeaponOnce_OneRoundRemaining);
|
||||||
SUITE_ADD_TEST(suite, TestFireCurrentWeaponOnce_TwoRoundsRemaining);
|
SUITE_ADD_TEST(suite, TestFireCurrentWeaponOnce_TwoRoundsRemaining);
|
||||||
|
SUITE_ADD_TEST(suite, TestMaybeFireShotCount_NotOK);
|
||||||
|
SUITE_ADD_TEST(suite, TestMaybeFireShotCount_OK);
|
||||||
|
SUITE_ADD_TEST(suite, TestMaybeFireShotCount_NotEnoughAvailable);
|
||||||
|
SUITE_ADD_TEST(suite, TestMaybeFireShotCount_EnoughAvailable);
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
27
const.c
27
const.c
|
@ -2,28 +2,7 @@
|
||||||
#include "const.h"
|
#include "const.h"
|
||||||
|
|
||||||
int difficultyBands[MAX_DIFFICULTY];
|
int difficultyBands[MAX_DIFFICULTY];
|
||||||
int hitPointRanges[MAX_DIFFICULTY][4] = {
|
int hitPointRanges[MAX_DIFFICULTY][4];
|
||||||
{ 1, 1, 1, 1 },
|
|
||||||
{ 1, 1, 1, 1 },
|
|
||||||
{ 1, 1, 1, 2 },
|
|
||||||
{ 1, 1, 1, 2 },
|
|
||||||
{ 1, 1, 2, 2 },
|
|
||||||
{ 1, 2, 2, 2 },
|
|
||||||
{ 1, 2, 2, 2 },
|
|
||||||
{ 1, 2, 2, 3 },
|
|
||||||
{ 1, 2, 2, 3 },
|
|
||||||
{ 1, 2, 3, 3 },
|
|
||||||
{ 1, 2, 3, 3 },
|
|
||||||
{ 1, 2, 3, 3 },
|
|
||||||
{ 1, 2, 3, 3 },
|
|
||||||
{ 1, 2, 3, 3 },
|
|
||||||
{ 1, 2, 3, 3 },
|
|
||||||
{ 1, 2, 3, 3 },
|
|
||||||
{ 1, 2, 3, 3 },
|
|
||||||
{ 1, 2, 3, 3 },
|
|
||||||
{ 1, 2, 3, 3 },
|
|
||||||
{ 1, 2, 3, 3 }
|
|
||||||
};
|
|
||||||
|
|
||||||
struct SpriteBounds bounds;
|
struct SpriteBounds bounds;
|
||||||
|
|
||||||
|
@ -34,7 +13,7 @@ struct CompiledSpriteRender rabbit,
|
||||||
enemy,
|
enemy,
|
||||||
enemyBullet,
|
enemyBullet,
|
||||||
shotgun,
|
shotgun,
|
||||||
shieldKiller;
|
beam;
|
||||||
|
|
||||||
void buildDifficultyBands() {
|
void buildDifficultyBands() {
|
||||||
int i;
|
int i;
|
||||||
|
@ -56,7 +35,7 @@ void buildHitPointRages() {
|
||||||
}
|
}
|
||||||
|
|
||||||
countOfCurrent++;
|
countOfCurrent++;
|
||||||
if (countOfCurrent == 2) {
|
if (countOfCurrent == HIT_POINT_DIFFICULTY_INCREASE_DELAY) {
|
||||||
countOfCurrent = 0;
|
countOfCurrent = 0;
|
||||||
|
|
||||||
currentRange[3]++;
|
currentRange[3]++;
|
||||||
|
|
14
const.h
14
const.h
|
@ -55,15 +55,17 @@
|
||||||
#define POWERUP_RESPAWN_COOLDOWN_PER_LEVEL (10)
|
#define POWERUP_RESPAWN_COOLDOWN_PER_LEVEL (10)
|
||||||
|
|
||||||
#define SHOTGUN_ROUNDS_PER_LEVEL (25)
|
#define SHOTGUN_ROUNDS_PER_LEVEL (25)
|
||||||
#define MAX_DIFFICULTY (20)
|
#define MAX_DIFFICULTY (40)
|
||||||
#define BASE_KILLS (10)
|
#define BASE_KILLS (30)
|
||||||
#define KILLS_NEEDED_FOR_NEXT_LEVEL_MULTIPLIER (2.1)
|
#define KILLS_NEEDED_FOR_NEXT_LEVEL_MULTIPLIER (1.25)
|
||||||
|
#define HIT_POINT_DIFFICULTY_INCREASE_DELAY (4)
|
||||||
|
|
||||||
#define WEAPON_TYPE_SINGLE_SHOT_GUN (0)
|
#define WEAPON_TYPE_SINGLE_SHOT_GUN (0)
|
||||||
#define WEAPON_TYPE_SPREAD_SHOT_GUN (1)
|
#define WEAPON_TYPE_SPREAD_SHOT_GUN (1)
|
||||||
|
#define WEAPON_TYPE_BEAM_SHOT_GUN (2)
|
||||||
|
|
||||||
#define POWERUP_TYPE_SHOTGUN (0)
|
#define POWERUP_TYPE_SHOTGUN (1)
|
||||||
#define POWERUP_TYPE_SHIELD_KILLER (1)
|
#define POWERUP_TYPE_BEAM_WEAPON (2)
|
||||||
|
|
||||||
#define KNOCKBACK_DISTANCE (3)
|
#define KNOCKBACK_DISTANCE (3)
|
||||||
|
|
||||||
|
@ -77,7 +79,7 @@ extern struct CompiledSpriteRender rabbit,
|
||||||
enemy,
|
enemy,
|
||||||
enemyBullet,
|
enemyBullet,
|
||||||
shotgun,
|
shotgun,
|
||||||
shieldKiller;
|
beam;
|
||||||
|
|
||||||
void buildDifficultyBands();
|
void buildDifficultyBands();
|
||||||
void buildHitPointRages();
|
void buildHitPointRages();
|
||||||
|
|
50
game.c
50
game.c
|
@ -147,12 +147,12 @@ void setupPowerupSprites() {
|
||||||
);
|
);
|
||||||
|
|
||||||
buildCompiledSprite(
|
buildCompiledSprite(
|
||||||
&sprite_shieldKiller,
|
&sprite_beam,
|
||||||
&shieldKiller,
|
&beam,
|
||||||
SPRITE_SHIELDKILLER_WIDTH,
|
SPRITE_BEAM_WIDTH,
|
||||||
SPRITE_SHIELDKILLER_HEIGHT,
|
SPRITE_BEAM_HEIGHT,
|
||||||
SPRITE_SHIELDKILLER_OFFSET_X,
|
SPRITE_BEAM_OFFSET_X,
|
||||||
SPRITE_SHIELDKILLER_OFFSET_Y
|
SPRITE_BEAM_OFFSET_Y
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,20 +206,22 @@ void renderEnemyBullets() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderPowerup() {
|
void renderPowerup() {
|
||||||
|
struct CompiledSpriteRender *which;
|
||||||
|
|
||||||
if (!playerPowerup.isActive) return;
|
if (!playerPowerup.isActive) return;
|
||||||
|
|
||||||
switch (playerPowerup.type) {
|
switch (playerPowerup.type) {
|
||||||
case POWERUP_TYPE_SHOTGUN:
|
case POWERUP_TYPE_SHOTGUN:
|
||||||
shotgun.x = playerPowerup.x;
|
which = &shotgun;
|
||||||
shotgun.y = playerPowerup.y;
|
|
||||||
drawCompiledSprite(&shotgun);
|
|
||||||
break;
|
break;
|
||||||
case POWERUP_TYPE_SHIELD_KILLER:
|
case POWERUP_TYPE_BEAM_WEAPON:
|
||||||
shieldKiller.x = playerPowerup.x;
|
which = &beam;
|
||||||
shieldKiller.y = playerPowerup.y;
|
|
||||||
drawCompiledSprite(&shieldKiller);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
which->x = playerPowerup.x;
|
||||||
|
which->y = playerPowerup.y;
|
||||||
|
drawCompiledSprite(which);
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawOnlyArenaForSprite(struct CompiledSpriteRender *sprite) {
|
void drawOnlyArenaForSprite(struct CompiledSpriteRender *sprite) {
|
||||||
|
@ -246,21 +248,23 @@ void drawOnlyRabbitArena() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawOnlyPowerupArena() {
|
void drawOnlyPowerupArena() {
|
||||||
|
struct CompiledSpriteRender *which;
|
||||||
|
|
||||||
if (!playerPowerup.isActive) return;
|
if (!playerPowerup.isActive) return;
|
||||||
|
|
||||||
switch (playerPowerup.type) {
|
switch (playerPowerup.type) {
|
||||||
case POWERUP_TYPE_SHOTGUN:
|
case POWERUP_TYPE_SHOTGUN:
|
||||||
shotgun.x = playerPowerup.x;
|
which = &shotgun;
|
||||||
shotgun.y = playerPowerup.y;
|
|
||||||
drawOnlyArenaForSprite(&shotgun);
|
|
||||||
break;
|
break;
|
||||||
case POWERUP_TYPE_SHIELD_KILLER:
|
case POWERUP_TYPE_BEAM_WEAPON:
|
||||||
shieldKiller.x = playerPowerup.x;
|
which = &beam;
|
||||||
shieldKiller.y = playerPowerup.y;
|
|
||||||
drawOnlyArenaForSprite(&shieldKiller);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
which->x = playerPowerup.x;
|
||||||
|
which->y = playerPowerup.y;
|
||||||
|
drawOnlyArenaForSprite(which);
|
||||||
|
|
||||||
if (playerPowerup.willBeInactive) {
|
if (playerPowerup.willBeInactive) {
|
||||||
playerPowerup.isActive = 0;
|
playerPowerup.isActive = 0;
|
||||||
}
|
}
|
||||||
|
@ -427,8 +431,8 @@ void handleCombat() {
|
||||||
|
|
||||||
if (handleRabbitToPowerupCollision(&rabbitPosition, &playerPowerup)) {
|
if (handleRabbitToPowerupCollision(&rabbitPosition, &playerPowerup)) {
|
||||||
playerPowerup.willBeInactive = 1;
|
playerPowerup.willBeInactive = 1;
|
||||||
rabbitWeaponry.currentWeapon = WEAPON_TYPE_SPREAD_SHOT_GUN;
|
rabbitWeaponry.currentWeapon = playerPowerup.type;
|
||||||
rabbitWeaponry.currentWeaponRemainingRounds = determineShotgunRounds(globalGameState.difficulty);
|
rabbitWeaponry.currentWeaponRemainingRounds = determineWeaponRounds(globalGameState.difficulty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,7 +500,7 @@ int main(void) {
|
||||||
renderStringToDrawBuffer(buffer, 1, 0, 210, 40);
|
renderStringToDrawBuffer(buffer, 1, 0, 210, 40);
|
||||||
sprintf(buffer, "Cool: %d ", playerPowerup.cooldown);
|
sprintf(buffer, "Cool: %d ", playerPowerup.cooldown);
|
||||||
renderStringToDrawBuffer(buffer, 1, 0, 210, 50);
|
renderStringToDrawBuffer(buffer, 1, 0, 210, 50);
|
||||||
sprintf(buffer, "Wpn: %d ", rabbitWeaponry.currentWeapon);
|
sprintf(buffer, "Lvl: %d ", globalGameState.difficulty);
|
||||||
renderStringToDrawBuffer(buffer, 1, 0, 210, 60);
|
renderStringToDrawBuffer(buffer, 1, 0, 210, 60);
|
||||||
|
|
||||||
waitStartVbl();
|
waitStartVbl();
|
||||||
|
|
|
@ -17,7 +17,7 @@ int determinePowerupCooldownTime(int difficulty) {
|
||||||
// if every shot lands, you should run out slightly before the next powerup
|
// if every shot lands, you should run out slightly before the next powerup
|
||||||
// should be available
|
// should be available
|
||||||
// so for the first rounds should be difficulty(1) + difficulty(2) % rand() or so
|
// so for the first rounds should be difficulty(1) + difficulty(2) % rand() or so
|
||||||
int determineShotgunRounds(int difficulty) {
|
int determineWeaponRounds(int difficulty) {
|
||||||
if (difficulty > MAX_DIFFICULTY) exit(1);
|
if (difficulty > MAX_DIFFICULTY) exit(1);
|
||||||
|
|
||||||
return difficultyBands[difficulty] +
|
return difficultyBands[difficulty] +
|
||||||
|
@ -40,6 +40,7 @@ void processPowerupCooldown(
|
||||||
playerPowerup->y = TILE_SIZE + rand() % ((ARENA_HEIGHT_TILES - 2) * TILE_SIZE);
|
playerPowerup->y = TILE_SIZE + rand() % ((ARENA_HEIGHT_TILES - 2) * TILE_SIZE);
|
||||||
playerPowerup->isActive = 1;
|
playerPowerup->isActive = 1;
|
||||||
playerPowerup->willBeInactive = 0;
|
playerPowerup->willBeInactive = 0;
|
||||||
|
playerPowerup->type = 2;
|
||||||
|
|
||||||
playerPowerup->cooldown = determinePowerupCooldownTime(globalGameState->difficulty);
|
playerPowerup->cooldown = determinePowerupCooldownTime(globalGameState->difficulty);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "movement.h"
|
#include "movement.h"
|
||||||
|
|
||||||
int determinePowerupCooldownTime(int difficulty);
|
int determinePowerupCooldownTime(int difficulty);
|
||||||
int determineShotgunRounds(int difficulty);
|
int determineWeaponRounds(int difficulty);
|
||||||
void processPowerupCooldown(
|
void processPowerupCooldown(
|
||||||
struct PlayerPowerup*,
|
struct PlayerPowerup*,
|
||||||
struct GlobalGameState*,
|
struct GlobalGameState*,
|
||||||
|
|
|
@ -15,12 +15,12 @@ void TestDeterminePowerupCooldownTime(CuTest *tc) {
|
||||||
CuAssertIntEquals(tc, 81, determinePowerupCooldownTime(2));
|
CuAssertIntEquals(tc, 81, determinePowerupCooldownTime(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestDetermineShotgunRounds(CuTest *tc) {
|
void TestDetermineWeaponRounds(CuTest *tc) {
|
||||||
srand(1);
|
srand(1);
|
||||||
|
|
||||||
CuAssertIntEquals(tc, 18, determineShotgunRounds(0));
|
CuAssertIntEquals(tc, 18, determineWeaponRounds(0));
|
||||||
CuAssertIntEquals(tc, 39, determineShotgunRounds(1));
|
CuAssertIntEquals(tc, 39, determineWeaponRounds(1));
|
||||||
CuAssertIntEquals(tc, 81, determineShotgunRounds(2));
|
CuAssertIntEquals(tc, 81, determineWeaponRounds(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ void TestProcessPowerupCooldown_Triggered(CuTest *tc) {
|
||||||
CuSuite *PowerupGetSuite() {
|
CuSuite *PowerupGetSuite() {
|
||||||
CuSuite *suite = CuSuiteNew();
|
CuSuite *suite = CuSuiteNew();
|
||||||
SUITE_ADD_TEST(suite, TestDeterminePowerupCooldownTime);
|
SUITE_ADD_TEST(suite, TestDeterminePowerupCooldownTime);
|
||||||
SUITE_ADD_TEST(suite, TestDetermineShotgunRounds);
|
SUITE_ADD_TEST(suite, TestDetermineWeaponRounds);
|
||||||
SUITE_ADD_TEST(suite, TestProcessPowerupCooldown_PowerupActive);
|
SUITE_ADD_TEST(suite, TestProcessPowerupCooldown_PowerupActive);
|
||||||
SUITE_ADD_TEST(suite, TestProcessPowerupCooldown_WeaponActive);
|
SUITE_ADD_TEST(suite, TestProcessPowerupCooldown_WeaponActive);
|
||||||
SUITE_ADD_TEST(suite, TestProcessPowerupCooldown_NotTriggered);
|
SUITE_ADD_TEST(suite, TestProcessPowerupCooldown_NotTriggered);
|
||||||
|
|
150
sprites.asm
150
sprites.asm
|
@ -7,7 +7,7 @@ PUBLIC sprite_mouse_
|
||||||
PUBLIC sprite_bullet_
|
PUBLIC sprite_bullet_
|
||||||
PUBLIC sprite_enemy_
|
PUBLIC sprite_enemy_
|
||||||
PUBLIC sprite_shotgun_
|
PUBLIC sprite_shotgun_
|
||||||
PUBLIC sprite_shieldKiller_
|
PUBLIC sprite_beam_
|
||||||
PUBLIC _palette
|
PUBLIC _palette
|
||||||
|
|
||||||
.386
|
.386
|
||||||
|
@ -36,7 +36,7 @@ _palette:
|
||||||
BYTE 38
|
BYTE 38
|
||||||
BYTE 31
|
BYTE 31
|
||||||
BYTE 12
|
BYTE 12
|
||||||
BYTE 0
|
BYTE 63
|
||||||
BYTE 0
|
BYTE 0
|
||||||
BYTE 0
|
BYTE 0
|
||||||
BYTE 0
|
BYTE 0
|
||||||
|
@ -1614,11 +1614,155 @@ sprite_shotgun_:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
sprite_shieldKiller_:
|
sprite_beam_:
|
||||||
push ebp
|
push ebp
|
||||||
mov ebp, esp
|
mov ebp, esp
|
||||||
|
|
||||||
|
|
||||||
|
mov BYTE PTR [eax + -1926], 7
|
||||||
|
mov BYTE PTR [eax + -1925], 7
|
||||||
|
mov BYTE PTR [eax + -1924], 7
|
||||||
|
mov BYTE PTR [eax + -1923], 7
|
||||||
|
mov BYTE PTR [eax + -1922], 7
|
||||||
|
mov BYTE PTR [eax + -1921], 7
|
||||||
|
mov BYTE PTR [eax + -1920], 7
|
||||||
|
mov BYTE PTR [eax + -1919], 7
|
||||||
|
mov BYTE PTR [eax + -1918], 7
|
||||||
|
mov BYTE PTR [eax + -1917], 7
|
||||||
|
mov BYTE PTR [eax + -1916], 7
|
||||||
|
mov BYTE PTR [eax + -1915], 7
|
||||||
|
mov BYTE PTR [eax + -1606], 7
|
||||||
|
mov BYTE PTR [eax + -1605], 7
|
||||||
|
mov BYTE PTR [eax + -1604], 7
|
||||||
|
mov BYTE PTR [eax + -1603], 7
|
||||||
|
mov BYTE PTR [eax + -1602], 7
|
||||||
|
mov BYTE PTR [eax + -1601], 7
|
||||||
|
mov BYTE PTR [eax + -1600], 7
|
||||||
|
mov BYTE PTR [eax + -1599], 7
|
||||||
|
mov BYTE PTR [eax + -1598], 7
|
||||||
|
mov BYTE PTR [eax + -1597], 7
|
||||||
|
mov BYTE PTR [eax + -1596], 7
|
||||||
|
mov BYTE PTR [eax + -1595], 7
|
||||||
|
mov BYTE PTR [eax + -1286], 7
|
||||||
|
mov BYTE PTR [eax + -1285], 7
|
||||||
|
mov BYTE PTR [eax + -1284], 7
|
||||||
|
mov BYTE PTR [eax + -1283], 7
|
||||||
|
mov BYTE PTR [eax + -1282], 7
|
||||||
|
mov BYTE PTR [eax + -1281], 7
|
||||||
|
mov BYTE PTR [eax + -1280], 7
|
||||||
|
mov BYTE PTR [eax + -1279], 7
|
||||||
|
mov BYTE PTR [eax + -1278], 7
|
||||||
|
mov BYTE PTR [eax + -1277], 7
|
||||||
|
mov BYTE PTR [eax + -1276], 7
|
||||||
|
mov BYTE PTR [eax + -1275], 7
|
||||||
|
mov BYTE PTR [eax + -966], 7
|
||||||
|
mov BYTE PTR [eax + -965], 7
|
||||||
|
mov BYTE PTR [eax + -964], 7
|
||||||
|
mov BYTE PTR [eax + -963], 7
|
||||||
|
mov BYTE PTR [eax + -962], 7
|
||||||
|
mov BYTE PTR [eax + -961], 7
|
||||||
|
mov BYTE PTR [eax + -960], 7
|
||||||
|
mov BYTE PTR [eax + -959], 7
|
||||||
|
mov BYTE PTR [eax + -958], 7
|
||||||
|
mov BYTE PTR [eax + -957], 7
|
||||||
|
mov BYTE PTR [eax + -956], 7
|
||||||
|
mov BYTE PTR [eax + -955], 7
|
||||||
|
mov BYTE PTR [eax + -646], 7
|
||||||
|
mov BYTE PTR [eax + -645], 7
|
||||||
|
mov BYTE PTR [eax + -644], 7
|
||||||
|
mov BYTE PTR [eax + -643], 7
|
||||||
|
mov BYTE PTR [eax + -642], 7
|
||||||
|
mov BYTE PTR [eax + -641], 7
|
||||||
|
mov BYTE PTR [eax + -640], 7
|
||||||
|
mov BYTE PTR [eax + -639], 7
|
||||||
|
mov BYTE PTR [eax + -638], 7
|
||||||
|
mov BYTE PTR [eax + -637], 7
|
||||||
|
mov BYTE PTR [eax + -636], 7
|
||||||
|
mov BYTE PTR [eax + -635], 7
|
||||||
|
mov BYTE PTR [eax + -326], 7
|
||||||
|
mov BYTE PTR [eax + -325], 7
|
||||||
|
mov BYTE PTR [eax + -324], 7
|
||||||
|
mov BYTE PTR [eax + -323], 7
|
||||||
|
mov BYTE PTR [eax + -322], 7
|
||||||
|
mov BYTE PTR [eax + -321], 7
|
||||||
|
mov BYTE PTR [eax + -320], 7
|
||||||
|
mov BYTE PTR [eax + -319], 7
|
||||||
|
mov BYTE PTR [eax + -318], 7
|
||||||
|
mov BYTE PTR [eax + -317], 7
|
||||||
|
mov BYTE PTR [eax + -316], 7
|
||||||
|
mov BYTE PTR [eax + -315], 7
|
||||||
|
mov BYTE PTR [eax + -6], 7
|
||||||
|
mov BYTE PTR [eax + -5], 7
|
||||||
|
mov BYTE PTR [eax + -4], 7
|
||||||
|
mov BYTE PTR [eax + -3], 7
|
||||||
|
mov BYTE PTR [eax + -2], 7
|
||||||
|
mov BYTE PTR [eax + -1], 7
|
||||||
|
mov BYTE PTR [eax + 0], 7
|
||||||
|
mov BYTE PTR [eax + 1], 7
|
||||||
|
mov BYTE PTR [eax + 2], 7
|
||||||
|
mov BYTE PTR [eax + 3], 7
|
||||||
|
mov BYTE PTR [eax + 4], 7
|
||||||
|
mov BYTE PTR [eax + 5], 7
|
||||||
|
mov BYTE PTR [eax + 314], 7
|
||||||
|
mov BYTE PTR [eax + 315], 7
|
||||||
|
mov BYTE PTR [eax + 316], 7
|
||||||
|
mov BYTE PTR [eax + 317], 7
|
||||||
|
mov BYTE PTR [eax + 318], 7
|
||||||
|
mov BYTE PTR [eax + 319], 7
|
||||||
|
mov BYTE PTR [eax + 320], 7
|
||||||
|
mov BYTE PTR [eax + 321], 7
|
||||||
|
mov BYTE PTR [eax + 322], 7
|
||||||
|
mov BYTE PTR [eax + 323], 7
|
||||||
|
mov BYTE PTR [eax + 324], 7
|
||||||
|
mov BYTE PTR [eax + 325], 7
|
||||||
|
mov BYTE PTR [eax + 634], 7
|
||||||
|
mov BYTE PTR [eax + 635], 7
|
||||||
|
mov BYTE PTR [eax + 636], 7
|
||||||
|
mov BYTE PTR [eax + 637], 7
|
||||||
|
mov BYTE PTR [eax + 638], 7
|
||||||
|
mov BYTE PTR [eax + 639], 7
|
||||||
|
mov BYTE PTR [eax + 640], 7
|
||||||
|
mov BYTE PTR [eax + 641], 7
|
||||||
|
mov BYTE PTR [eax + 642], 7
|
||||||
|
mov BYTE PTR [eax + 643], 7
|
||||||
|
mov BYTE PTR [eax + 644], 7
|
||||||
|
mov BYTE PTR [eax + 645], 7
|
||||||
|
mov BYTE PTR [eax + 954], 7
|
||||||
|
mov BYTE PTR [eax + 955], 7
|
||||||
|
mov BYTE PTR [eax + 956], 7
|
||||||
|
mov BYTE PTR [eax + 957], 7
|
||||||
|
mov BYTE PTR [eax + 958], 7
|
||||||
|
mov BYTE PTR [eax + 959], 7
|
||||||
|
mov BYTE PTR [eax + 960], 7
|
||||||
|
mov BYTE PTR [eax + 961], 7
|
||||||
|
mov BYTE PTR [eax + 962], 7
|
||||||
|
mov BYTE PTR [eax + 963], 7
|
||||||
|
mov BYTE PTR [eax + 964], 7
|
||||||
|
mov BYTE PTR [eax + 965], 7
|
||||||
|
mov BYTE PTR [eax + 1274], 7
|
||||||
|
mov BYTE PTR [eax + 1275], 7
|
||||||
|
mov BYTE PTR [eax + 1276], 7
|
||||||
|
mov BYTE PTR [eax + 1277], 7
|
||||||
|
mov BYTE PTR [eax + 1278], 7
|
||||||
|
mov BYTE PTR [eax + 1279], 7
|
||||||
|
mov BYTE PTR [eax + 1280], 7
|
||||||
|
mov BYTE PTR [eax + 1281], 7
|
||||||
|
mov BYTE PTR [eax + 1282], 7
|
||||||
|
mov BYTE PTR [eax + 1283], 7
|
||||||
|
mov BYTE PTR [eax + 1284], 7
|
||||||
|
mov BYTE PTR [eax + 1285], 7
|
||||||
|
mov BYTE PTR [eax + 1594], 7
|
||||||
|
mov BYTE PTR [eax + 1595], 7
|
||||||
|
mov BYTE PTR [eax + 1596], 7
|
||||||
|
mov BYTE PTR [eax + 1597], 7
|
||||||
|
mov BYTE PTR [eax + 1598], 7
|
||||||
|
mov BYTE PTR [eax + 1599], 7
|
||||||
|
mov BYTE PTR [eax + 1600], 7
|
||||||
|
mov BYTE PTR [eax + 1601], 7
|
||||||
|
mov BYTE PTR [eax + 1602], 7
|
||||||
|
mov BYTE PTR [eax + 1603], 7
|
||||||
|
mov BYTE PTR [eax + 1604], 7
|
||||||
|
mov BYTE PTR [eax + 1605], 7
|
||||||
|
|
||||||
pop ebp
|
pop ebp
|
||||||
ret
|
ret
|
||||||
|
|
10
sprites.h
10
sprites.h
|
@ -97,15 +97,15 @@ extern void sprite_shotgun(byte *);
|
||||||
#define SPRITE_SHOTGUN_OFFSET_Y (6)
|
#define SPRITE_SHOTGUN_OFFSET_Y (6)
|
||||||
|
|
||||||
|
|
||||||
extern void sprite_shieldKiller(byte *);
|
extern void sprite_beam(byte *);
|
||||||
|
|
||||||
#define SPRITE_SHIELDKILLER_WIDTH (12)
|
#define SPRITE_BEAM_WIDTH (12)
|
||||||
|
|
||||||
#define SPRITE_SHIELDKILLER_HEIGHT (12)
|
#define SPRITE_BEAM_HEIGHT (12)
|
||||||
|
|
||||||
#define SPRITE_SHIELDKILLER_OFFSET_X (6)
|
#define SPRITE_BEAM_OFFSET_X (6)
|
||||||
|
|
||||||
#define SPRITE_SHIELDKILLER_OFFSET_Y (6)
|
#define SPRITE_BEAM_OFFSET_Y (6)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ files:
|
||||||
position: [32, 20]
|
position: [32, 20]
|
||||||
dimensions: [12, 12]
|
dimensions: [12, 12]
|
||||||
offset: [6, 6]
|
offset: [6, 6]
|
||||||
shieldKiller:
|
beam:
|
||||||
position: [44, 20]
|
position: [44, 20]
|
||||||
dimensions: [12, 12]
|
dimensions: [12, 12]
|
||||||
offset: [6, 6]
|
offset: [6, 6]
|
||||||
|
|
BIN
sprtsht.bmp
BIN
sprtsht.bmp
Binary file not shown.
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
Loading…
Reference in New Issue