way more stuff

This commit is contained in:
John Bintz 2024-02-27 08:16:16 -05:00
parent 20bf569dac
commit 7039359067
10 changed files with 251 additions and 83 deletions

160
combat.c
View File

@ -8,7 +8,18 @@
#include "const.h"
#include "system/vga.h"
void setupBullet(struct BulletPosition *bullet, int x, int y, signed int doubleVelocityX, signed int doubleVelocityY, int velocity) {
void setupBullet(
struct BulletPosition *bullet,
int x,
int y,
int angle,
int velocity
) {
signed int doubleVelocityX, doubleVelocityY;
doubleVelocityX = sin(angle * DEG2RAD) * (velocity * 2);
doubleVelocityY = -cos(angle * DEG2RAD) * (velocity * 2);
bullet->isActive = 1;
bullet->willBeInactive = 0;
bullet->x = x;
@ -16,6 +27,7 @@ void setupBullet(struct BulletPosition *bullet, int x, int y, signed int doubleV
bullet->oldX = x;
bullet->oldY = y;
bullet->wallCooldown = 1;
bullet->angle = angle;
bullet->velocityXSteps[0] = doubleVelocityX / velocity;
bullet->velocityXSteps[1] = doubleVelocityX - bullet->velocityXSteps[0];
@ -26,21 +38,20 @@ void setupBullet(struct BulletPosition *bullet, int x, int y, signed int doubleV
bullet->velocityStep = 0;
}
void attemptToFireRabbitBullet(
int attemptToFireRabbitBullet(
struct RabbitPosition *rabbitPosition,
struct RabbitWeaponry *rabbitWeaponry,
struct BulletPosition rabbitBulletPosition[]
) {
int okToFire = 0, i, mouseAngle;
signed int doubleVelocityX, doubleVelocityY;
int availableBullets[3];
if (rabbitWeaponry->cooldown > 0) return;
if (rabbitWeaponry->cooldown > 0) return 0;
mouseAngle = rabbitPosition->mouseAngle;
rabbitWeaponry->cooldown = RABBIT_BULLET_COOLDOWN;
if (rabbitWeaponry->currentWeapon == SINGLE_SHOT_GUN) {
if (rabbitWeaponry->currentWeapon == WEAPON_TYPE_SINGLE_SHOT_GUN) {
for (i = 0; i < RABBIT_BULLET_LIMIT; ++i) {
if (rabbitBulletPosition[i].isActive == 0) {
okToFire = 1;
@ -49,20 +60,16 @@ void attemptToFireRabbitBullet(
}
}
if (!okToFire) return;
doubleVelocityX = sin(mouseAngle * DEG2RAD) * (RABBIT_BULLET_VELOCITY * 2);
doubleVelocityY = -cos(mouseAngle * DEG2RAD) * (RABBIT_BULLET_VELOCITY * 2);
if (!okToFire) return 0;
setupBullet(
&rabbitBulletPosition[availableBullets[0]],
rabbitPosition->rabbitPosition[0],
rabbitPosition->rabbitPosition[1],
doubleVelocityX,
doubleVelocityY,
mouseAngle,
RABBIT_BULLET_VELOCITY
);
} else if (rabbitWeaponry->currentWeapon == SPREAD_SHOT_GUN) {
} else if (rabbitWeaponry->currentWeapon == WEAPON_TYPE_SPREAD_SHOT_GUN) {
// make sure three bullets are available
for (i = 0; i < RABBIT_BULLET_LIMIT; ++i) {
if (rabbitBulletPosition[i].isActive == 0) {
@ -71,23 +78,38 @@ void attemptToFireRabbitBullet(
}
}
if (okToFire < 3) return;
if (okToFire < 3) return 0;
// if so, fire away
for (i = 0; i < 3; ++i) {
doubleVelocityX = sin((mouseAngle + (i - 1) * RABBIT_BULLET_SHOTGUN_SPREAD) * DEG2RAD) * (RABBIT_BULLET_VELOCITY * 2);
doubleVelocityY = -cos((mouseAngle + (i - 1) * RABBIT_BULLET_SHOTGUN_SPREAD) * DEG2RAD) * (RABBIT_BULLET_VELOCITY * 2);
setupBullet(
&rabbitBulletPosition[availableBullets[i]],
rabbitPosition->rabbitPosition[0],
rabbitPosition->rabbitPosition[1],
doubleVelocityX,
doubleVelocityY,
mouseAngle + (i - 1) * RABBIT_BULLET_SHOTGUN_SPREAD,
RABBIT_BULLET_VELOCITY
);
}
}
return 1;
}
void limitBulletToArena(struct BulletPosition *bullet) {
if (bullet->x < MOUSE_LIMIT_LEFT) bullet->willBeInactive = 1;
if (bullet->x >= MOUSE_LIMIT_RIGHT) bullet->willBeInactive = 1;
if (bullet->y < MOUSE_LIMIT_TOP) bullet->willBeInactive = 1;
if (bullet->y >= MOUSE_LIMIT_BOTTOM) bullet->willBeInactive = 1;
}
void moveBullet(struct BulletPosition *bullet) {
bullet->oldX = bullet->x;
bullet->oldY = bullet->y;
bullet->x += bullet->velocityXSteps[bullet->velocityStep];
bullet->y += bullet->velocityYSteps[bullet->velocityStep];
bullet->velocityStep = 1 - bullet->velocityStep;
}
void advanceRabbitBullets(
@ -99,23 +121,13 @@ void advanceRabbitBullets(
for (i = 0; i < RABBIT_BULLET_LIMIT; ++i) {
if (!rabbitBulletPosition[i].isActive) continue;
rabbitBulletPosition[i].oldX = rabbitBulletPosition[i].x;
rabbitBulletPosition[i].oldY = rabbitBulletPosition[i].y;
rabbitBulletPosition[i].x += rabbitBulletPosition[i].velocityXSteps[rabbitBulletPosition[i].velocityStep];
rabbitBulletPosition[i].y += rabbitBulletPosition[i].velocityYSteps[rabbitBulletPosition[i].velocityStep];
moveBullet(&rabbitBulletPosition[i]);
if (rabbitBulletPosition[i].wallCooldown == 0) {
if (rabbitBulletPosition[i].x < MOUSE_LIMIT_LEFT) rabbitBulletPosition[i].willBeInactive = 1;
if (rabbitBulletPosition[i].x >= MOUSE_LIMIT_RIGHT) rabbitBulletPosition[i].willBeInactive = 1;
if (rabbitBulletPosition[i].y < MOUSE_LIMIT_TOP) rabbitBulletPosition[i].willBeInactive = 1;
if (rabbitBulletPosition[i].y >= MOUSE_LIMIT_BOTTOM) rabbitBulletPosition[i].willBeInactive = 1;
limitBulletToArena(&rabbitBulletPosition[i]);
} else {
rabbitBulletPosition[i].wallCooldown--;
}
rabbitBulletPosition[i].velocityStep = 1 - rabbitBulletPosition[i].velocityStep;
}
if (rabbitWeaponry->cooldown > 0) rabbitWeaponry->cooldown--;
@ -129,18 +141,8 @@ void advanceEnemyBullets(
for (i = 0; i < ENEMY_BULLET_LIMIT; ++i) {
if (!enemyBulletPosition[i].isActive) continue;
enemyBulletPosition[i].oldX = enemyBulletPosition[i].x;
enemyBulletPosition[i].oldY = enemyBulletPosition[i].y;
enemyBulletPosition[i].x += enemyBulletPosition[i].velocityXSteps[enemyBulletPosition[i].velocityStep];
enemyBulletPosition[i].y += enemyBulletPosition[i].velocityYSteps[enemyBulletPosition[i].velocityStep];
if (enemyBulletPosition[i].x < MOUSE_LIMIT_LEFT) enemyBulletPosition[i].willBeInactive = 1;
if (enemyBulletPosition[i].x >= MOUSE_LIMIT_RIGHT) enemyBulletPosition[i].willBeInactive = 1;
if (enemyBulletPosition[i].y < MOUSE_LIMIT_TOP) enemyBulletPosition[i].willBeInactive = 1;
if (enemyBulletPosition[i].y >= MOUSE_LIMIT_BOTTOM) enemyBulletPosition[i].willBeInactive = 1;
enemyBulletPosition[i].velocityStep = 1 - enemyBulletPosition[i].velocityStep;
moveBullet(&enemyBulletPosition[i]);
limitBulletToArena(&enemyBulletPosition[i]);
}
}
@ -173,17 +175,13 @@ void attemptToFireEnemyBullets(
angle = atan2(distanceY, distanceX) * RAD2DEG + 90;
if (angle < 0) angle += 360;
doubleVelocityX = sin(angle * DEG2RAD) * (ENEMY_BULLET_VELOCITY * 2);
doubleVelocityY = -cos(angle * DEG2RAD) * (ENEMY_BULLET_VELOCITY * 2);
availableBullet = availableBullets[--maxAvailableBulletIndex];
setupBullet(
&enemyBulletPosition[availableBullet],
enemyPosition[i].enemyPosition[0],
enemyPosition[i].enemyPosition[1],
doubleVelocityX,
doubleVelocityY,
angle,
ENEMY_BULLET_VELOCITY
);
@ -229,7 +227,7 @@ void populateTargetCollision(struct CompiledSpriteRender *sprite) {
// We are hardcoding a 2x2 grid on the screen as our collision partitioning
// scheme.
int rabbitGrid[4];
int rabbitGrid[4], powerupGrid[4];
int rabbitBulletGrid[4][RABBIT_BULLET_LIMIT];
int enemyGrid[4][ENEMY_MAX_COUNT];
int enemyBulletGrid[4][ENEMY_BULLET_LIMIT];
@ -259,7 +257,8 @@ void buildCollisionGrids(
struct BulletPosition rabbitBulletPosition[],
struct BulletPosition enemyBulletPosition[],
struct RabbitPosition *rabbitPosition,
struct EnemyPosition enemyPosition[]
struct EnemyPosition enemyPosition[],
struct PlayerPowerup *playerPowerup
) {
int grid, i;
@ -277,6 +276,23 @@ void buildCollisionGrids(
rabbitGrid[grid] = gridPosition[grid];
}
switch (playerPowerup->type) {
case POWERUP_TYPE_SHOTGUN:
shotgun.x = playerPowerup->x;
shotgun.y = playerPowerup->y;
determineGridPositionsForSprite(&shotgun);
break;
case POWERUP_TYPE_SHIELD_KILLER:
shieldKiller.x = playerPowerup->x;
shieldKiller.y = playerPowerup->y;
determineGridPositionsForSprite(&shieldKiller);
break;
}
for (grid = 0; grid < 4; ++grid) {
powerupGrid[grid] = gridPosition[grid];
}
for (i = 0; i < RABBIT_BULLET_LIMIT; ++i) {
if (!rabbitBulletPosition[i].isActive) continue;
if (rabbitBulletPosition[i].willBeInactive) continue;
@ -358,6 +374,20 @@ int handleEnemyBulletToRabbitCollisions(
return hitCount;
}
#define KNOCKBACK_DISTANCE (3)
void knockbackEnemy(
struct EnemyPosition *enemy,
int angle
) {
int distanceX, distanceY;
distanceX = sin(angle * DEG2RAD) * (KNOCKBACK_DISTANCE * 2);
distanceY = -cos(angle * DEG2RAD) * (KNOCKBACK_DISTANCE * 2);
enemy->enemyPosition[0] += distanceX;
enemy->enemyPosition[1] += distanceY;
}
void handleRabbitBulletToEnemyCollisions(
struct BulletPosition rabbitBulletPosition[],
struct EnemyPosition enemyPosition[]
@ -386,7 +416,9 @@ void handleRabbitBulletToEnemyCollisions(
enemyPosition[resolvedEnemyIdx].hitPoints--;
if (enemyPosition[resolvedEnemyIdx].hitPoints < 1) {
enemyPosition[resolvedEnemyIdx].willBeInactive = 1;
enemyPosition[resolvedBulletIdx].wasKilled = 1;
enemyPosition[resolvedEnemyIdx].wasKilled = 1;
} else {
knockbackEnemy(&enemyPosition[resolvedEnemyIdx], rabbitBulletPosition[resolvedBulletIdx].angle);
}
rabbitBulletPosition[resolvedBulletIdx].willBeInactive = 1;
break;
@ -402,9 +434,6 @@ int handleRabbitToEnemyCollisions(
) {
int enemyIdx, grid, resolvedEnemyIdx, hitCount = 0;
// to start: brute force items
// possible performance improvements:
// * grid partitioning
rabbit.x = rabbitPosition->rabbitPosition[0];
rabbit.y = rabbitPosition->rabbitPosition[1];
populateSourceCollision(&rabbit);
@ -430,3 +459,28 @@ int handleRabbitToEnemyCollisions(
return hitCount;
}
int handleRabbitToPowerupCollision(
struct RabbitPosition *rabbitPosition,
struct PlayerPowerup *playerPowerup
) {
if (!playerPowerup->isActive) return 0;
rabbit.x = rabbitPosition->rabbitPosition[0];
rabbit.y = rabbitPosition->rabbitPosition[1];
populateSourceCollision(&rabbit);
switch (playerPowerup->type) {
case POWERUP_TYPE_SHOTGUN:
shotgun.x = playerPowerup->x;
shotgun.y = playerPowerup->y;
populateTargetCollision(&shotgun);
break;
case POWERUP_TYPE_SHIELD_KILLER:
shieldKiller.x = playerPowerup->x;
shieldKiller.y = playerPowerup->y;
populateTargetCollision(&shieldKiller);
break;
}
return isCollision();
}

View File

@ -1,4 +1,5 @@
void attemptToFireRabbitBullet(
#include "movement.h"
int attemptToFireRabbitBullet(
struct RabbitPosition*,
struct RabbitWeaponry*,
struct BulletPosition[]
@ -28,7 +29,8 @@ void buildCollisionGrids(
struct BulletPosition rabbitBulletPosition[],
struct BulletPosition enemyBulletPosition[],
struct RabbitPosition *rabbitPosition,
struct EnemyPosition enemyPosition[]
struct EnemyPosition enemyPosition[],
struct PlayerPowerup *playerPowerup
);
void attemptToFireEnemyBullets(
@ -41,3 +43,8 @@ void attemptToFireEnemyBullets(
void advanceEnemyBullets(
struct BulletPosition[]
);
int handleRabbitToPowerupCollision(
struct RabbitPosition *rabbitPosition,
struct PlayerPowerup *playerPowerup
);

View File

@ -46,3 +46,7 @@
#define DIFFICULTY_SPAWN_COOLDOWN_REDUCTION (2)
#define MINIMUM_ENEMY_SPAWN_COOLDOWN (3)
#define VARIABLE_ENEMY_SPAWN_COOLDOWN (10)
#define POWERUP_RESPAWN_COOLDOWN_PER_LEVEL (10)
#define SHOTGUN_ROUNDS_PER_LEVEL (25)

122
game.c
View File

@ -24,7 +24,8 @@ struct CompiledSpriteRender rabbit,
bullet,
enemy,
enemyBullet,
shotgun;
shotgun,
shieldKiller;
struct SpriteBounds bounds;
struct BMPImage spritesheetImage;
@ -68,12 +69,15 @@ void setupRabbitBullets() {
}
rabbitWeaponry.cooldown = 0;
rabbitWeaponry.currentWeapon = SPREAD_SHOT_GUN;
rabbitWeaponry.currentWeapon = WEAPON_TYPE_SINGLE_SHOT_GUN;
rabbitWeaponry.currentWeaponRemainingRounds = 0;
}
void setupPowerup() {
playerPowerup.x = 100;
playerPowerup.y = 100;
playerPowerup.cooldown = 20 + rand() % 10;
playerPowerup.type = POWERUP_TYPE_SHOTGUN;
playerPowerup.isActive = 0;
}
@ -103,12 +107,15 @@ int health = RABBIT_HEALTH_MAX;
int difficultyBands[10] = { 10, 20, 30, 50, 80, 130, 210, 340, 550, 890 };
void handleEnemyKills() {
int i, hadKill;
int i, hadKill, currentKillCount;
currentKillCount = 0;
for (i = 0; i < ENEMY_MAX_COUNT; ++i) {
if (enemyPosition[i].wasKilled) {
enemyPosition[i].wasKilled = 0;
kills++;
currentKillCount++;
health += ENEMY_KILL_HEALTH_GAIN;
if (health > RABBIT_HEALTH_MAX) health = RABBIT_HEALTH_MAX;
@ -116,6 +123,18 @@ void handleEnemyKills() {
}
}
kills += currentKillCount;
playerPowerup.cooldown -= currentKillCount;
if (playerPowerup.cooldown <= 0) {
playerPowerup.x = TILE_SIZE + rand() % ((ARENA_WIDTH_TILES - 2) * TILE_SIZE);
playerPowerup.y = TILE_SIZE + rand() % ((ARENA_HEIGHT_TILES - 2) * TILE_SIZE);
playerPowerup.isActive = 1;
playerPowerup.cooldown = POWERUP_RESPAWN_COOLDOWN_PER_LEVEL * difficulty +
rand() % (POWERUP_RESPAWN_COOLDOWN_PER_LEVEL * difficulty);
}
if (hadKill) {
for (i = 0; i < 10; ++i) {
if (kills > difficultyBands[i]) {
@ -233,12 +252,20 @@ void setupPowerupSprites() {
SPRITE_SHOTGUN_OFFSET_X,
SPRITE_SHOTGUN_OFFSET_Y
);
buildCompiledSprite(
&sprite_shieldKiller,
&shieldKiller,
SPRITE_SHIELDKILLER_WIDTH,
SPRITE_SHIELDKILLER_HEIGHT,
SPRITE_SHIELDKILLER_OFFSET_X,
SPRITE_SHIELDKILLER_OFFSET_Y
);
}
void renderMouse() {
mouse.x = rabbitPosition.mousePosition[0];
mouse.y = rabbitPosition.mousePosition[1];
drawCompiledSprite(&mouse);
drawPixel(rabbitPosition.mouseDotPosition[0], rabbitPosition.mouseDotPosition[1], 2);
}
@ -246,7 +273,6 @@ void renderMouse() {
void renderRabbit() {
rabbit.x = rabbitPosition.rabbitPosition[0];
rabbit.y = rabbitPosition.rabbitPosition[1];
drawCompiledSprite(&rabbit);
}
@ -258,7 +284,6 @@ void renderEnemies() {
enemy.x = enemyPosition[i].enemyPosition[0];
enemy.y = enemyPosition[i].enemyPosition[1];
drawCompiledSprite(&enemy);
}
}
@ -271,7 +296,6 @@ void renderRabbitBullets() {
bullet.x = rabbitBulletPosition[i].x;
bullet.y = rabbitBulletPosition[i].y;
drawCompiledSprite(&bullet);
}
}
@ -284,23 +308,36 @@ void renderEnemyBullets() {
enemyBullet.x = enemyBulletPosition[i].x;
enemyBullet.y = enemyBulletPosition[i].y;
drawCompiledSprite(&enemyBullet);
}
}
void renderPowerup() {
shotgun.x = playerPowerup.x;
shotgun.y = playerPowerup.y;
if (!playerPowerup.isActive) return;
drawCompiledSprite(&shotgun);
switch (playerPowerup.type) {
case POWERUP_TYPE_SHOTGUN:
shotgun.x = playerPowerup.x;
shotgun.y = playerPowerup.y;
drawCompiledSprite(&shotgun);
break;
case POWERUP_TYPE_SHIELD_KILLER:
shieldKiller.x = playerPowerup.x;
shieldKiller.y = playerPowerup.y;
drawCompiledSprite(&shieldKiller);
break;
}
}
void drawOnlyArenaForSprite(struct CompiledSpriteRender *sprite) {
getSpriteBounds(sprite, &bounds);
drawOnlyArena(&bounds);
}
void drawOnlyMouseArena() {
mouse.x = rabbitPosition.oldMousePosition[0];
mouse.y = rabbitPosition.oldMousePosition[1];
getSpriteBounds(&mouse, &bounds);
drawOnlyArena(&bounds);
drawOnlyArenaForSprite(&mouse);
bounds.top = rabbitPosition.oldMouseDotPosition[1];
bounds.bottom = rabbitPosition.oldMouseDotPosition[1];
@ -312,8 +349,28 @@ void drawOnlyMouseArena() {
void drawOnlyRabbitArena() {
rabbit.x = rabbitPosition.oldRabbitPosition[0];
rabbit.y = rabbitPosition.oldRabbitPosition[1];
getSpriteBounds(&rabbit, &bounds);
drawOnlyArena(&bounds);
drawOnlyArenaForSprite(&rabbit);
}
void drawOnlyPowerupArena() {
if (!playerPowerup.isActive) return;
switch (playerPowerup.type) {
case POWERUP_TYPE_SHOTGUN:
shotgun.x = playerPowerup.x;
shotgun.y = playerPowerup.y;
drawOnlyArenaForSprite(&shotgun);
break;
case POWERUP_TYPE_SHIELD_KILLER:
shieldKiller.x = playerPowerup.x;
shieldKiller.y = playerPowerup.y;
drawOnlyArenaForSprite(&shieldKiller);
break;
}
if (playerPowerup.willBeInactive) {
playerPowerup.isActive = 0;
}
}
void drawOnlyEnemiesArena() {
@ -324,8 +381,7 @@ void drawOnlyEnemiesArena() {
enemy.x = enemyPosition[i].oldEnemyPosition[0];
enemy.y = enemyPosition[i].oldEnemyPosition[1];
getSpriteBounds(&enemy, &bounds);
drawOnlyArena(&bounds);
drawOnlyArenaForSprite(&enemy);
if (enemyPosition[i].willBeInactive) {
enemyPosition[i].isActive = 0;
@ -340,8 +396,7 @@ void drawOnlyRabbitBulletArena() {
bullet.x = rabbitBulletPosition[i].oldX;
bullet.y = rabbitBulletPosition[i].oldY;
getSpriteBounds(&bullet, &bounds);
drawOnlyArena(&bounds);
drawOnlyArenaForSprite(&bullet);
if (rabbitBulletPosition[i].willBeInactive) {
rabbitBulletPosition[i].isActive = 0;
@ -356,8 +411,7 @@ void drawOnlyEnemyBulletArena() {
enemyBullet.x = enemyBulletPosition[i].oldX;
enemyBullet.y = enemyBulletPosition[i].oldY;
getSpriteBounds(&enemyBullet, &bounds);
drawOnlyArena(&bounds);
drawOnlyArenaForSprite(&enemyBullet);
if (enemyBulletPosition[i].willBeInactive) {
enemyBulletPosition[i].isActive = 0;
@ -380,7 +434,10 @@ int setupGame() {
setupWallSprites();
setupRabbitSprites();
setupRabbitBullets();
setupEnemies();
setupEnemyBullets();
setupEnemySprites();
setupPowerup();
setupPowerupSprites();
setVideoMode(VIDEO_MODE_VGA_256);
@ -420,11 +477,18 @@ void handleCombat() {
int didHitRabbit;
if (mouseStatus.leftButtonDown) {
attemptToFireRabbitBullet(
if (attemptToFireRabbitBullet(
&rabbitPosition,
&rabbitWeaponry,
rabbitBulletPosition
);
)) {
if (rabbitWeaponry.currentWeaponRemainingRounds > 0) {
rabbitWeaponry.currentWeaponRemainingRounds--;
if (rabbitWeaponry.currentWeaponRemainingRounds == 0) {
rabbitWeaponry.currentWeapon = WEAPON_TYPE_SINGLE_SHOT_GUN;
}
}
}
}
attemptToFireEnemyBullets(
@ -447,7 +511,8 @@ void handleCombat() {
rabbitBulletPosition,
enemyBulletPosition,
&rabbitPosition,
enemyPosition
enemyPosition,
&playerPowerup
);
didHitRabbit = handleRabbitToEnemyCollisions(
@ -472,6 +537,12 @@ void handleCombat() {
rabbitBulletPosition,
enemyPosition
);
if (handleRabbitToPowerupCollision(&rabbitPosition, &playerPowerup)) {
playerPowerup.willBeInactive = 1;
rabbitWeaponry.currentWeapon = WEAPON_TYPE_SPREAD_SHOT_GUN;
rabbitWeaponry.currentWeaponRemainingRounds = (difficulty + 1) * SHOTGUN_ROUNDS_PER_LEVEL;
}
}
void handleRedraw() {
@ -480,6 +551,7 @@ void handleRedraw() {
drawOnlyMouseArena();
drawOnlyRabbitBulletArena();
drawOnlyEnemyBulletArena();
drawOnlyPowerupArena();
redrawArena();
@ -524,6 +596,8 @@ int main(void) {
renderStringToDrawBuffer(buffer, 1, 0, 210, 20);
sprintf(buffer, "Health: %d ", health);
renderStringToDrawBuffer(buffer, 1, 0, 210, 30);
sprintf(buffer, "Rnds: %d ", rabbitWeaponry.currentWeaponRemainingRounds);
renderStringToDrawBuffer(buffer, 1, 0, 210, 40);
waitStartVbl();
copyDrawBufferToDisplay();

2
game.h
View File

@ -8,7 +8,7 @@ struct SpawnPointRange {
int top, height;
};
extern struct CompiledSpriteRender rabbit, mouse, bullet, enemy, enemyBullet;
extern struct CompiledSpriteRender rabbit, mouse, bullet, enemy, enemyBullet, shotgun, shieldKiller;
extern struct SpriteBounds bounds;
extern struct SpawnPointRange spawnPointRanges[];

View File

@ -18,8 +18,8 @@ struct RabbitPosition {
int mouseAngle;
};
#define SINGLE_SHOT_GUN (0)
#define SPREAD_SHOT_GUN (1)
#define WEAPON_TYPE_SINGLE_SHOT_GUN (0)
#define WEAPON_TYPE_SPREAD_SHOT_GUN (1)
struct RabbitWeaponry {
char cooldown;
@ -27,12 +27,14 @@ struct RabbitWeaponry {
int currentWeaponRemainingRounds;
};
#define POWERUP_SHOTGUN (0);
#define POWERUP_TYPE_SHOTGUN (0)
#define POWERUP_TYPE_SHIELD_KILLER (1)
struct PlayerPowerup {
int x, y;
int cooldown;
char isActive;
char willBeInactive;
char type;
};
@ -48,6 +50,7 @@ struct BulletPosition {
signed int velocityXSteps[2], velocityYSteps[2];
int velocityStep;
int angle;
};
struct EnemyPosition {

View File

@ -7,6 +7,7 @@ PUBLIC sprite_mouse_
PUBLIC sprite_bullet_
PUBLIC sprite_enemy_
PUBLIC sprite_shotgun_
PUBLIC sprite_shieldKiller_
.386
.model flat,c
@ -1558,4 +1559,14 @@ sprite_shotgun_:
ret
sprite_shieldKiller_:
push ebp
mov ebp, esp
pop ebp
ret
end

View File

@ -92,5 +92,16 @@ extern void sprite_shotgun(byte *);
#define SPRITE_SHOTGUN_OFFSET_Y (6)
extern void sprite_shieldKiller(byte *);
#define SPRITE_SHIELDKILLER_WIDTH (12)
#define SPRITE_SHIELDKILLER_HEIGHT (12)
#define SPRITE_SHIELDKILLER_OFFSET_X (6)
#define SPRITE_SHIELDKILLER_OFFSET_Y (6)
#endif

Binary file not shown.

View File

@ -37,3 +37,7 @@ files:
position: [32, 20]
dimensions: [12, 12]
offset: [6, 6]
shieldKiller:
position: [44, 20]
dimensions: [12, 12]
offset: [6, 6]