starting on shotgun
This commit is contained in:
parent
71a6c65f3b
commit
20bf569dac
29
combat.c
29
combat.c
@ -31,10 +31,12 @@ void attemptToFireRabbitBullet(
|
||||
struct RabbitWeaponry *rabbitWeaponry,
|
||||
struct BulletPosition rabbitBulletPosition[]
|
||||
) {
|
||||
int okToFire = 0, availableBullet, i;
|
||||
int okToFire = 0, i, mouseAngle;
|
||||
signed int doubleVelocityX, doubleVelocityY;
|
||||
int availableBullets[3];
|
||||
|
||||
if (rabbitWeaponry->cooldown > 0) return;
|
||||
mouseAngle = rabbitPosition->mouseAngle;
|
||||
|
||||
rabbitWeaponry->cooldown = RABBIT_BULLET_COOLDOWN;
|
||||
|
||||
@ -42,18 +44,18 @@ void attemptToFireRabbitBullet(
|
||||
for (i = 0; i < RABBIT_BULLET_LIMIT; ++i) {
|
||||
if (rabbitBulletPosition[i].isActive == 0) {
|
||||
okToFire = 1;
|
||||
availableBullet = i;
|
||||
availableBullets[0] = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!okToFire) return;
|
||||
|
||||
doubleVelocityX = sin(rabbitPosition->mouseAngle * DEG2RAD) * (RABBIT_BULLET_VELOCITY * 2);
|
||||
doubleVelocityY = -cos(rabbitPosition->mouseAngle * DEG2RAD) * (RABBIT_BULLET_VELOCITY * 2);
|
||||
doubleVelocityX = sin(mouseAngle * DEG2RAD) * (RABBIT_BULLET_VELOCITY * 2);
|
||||
doubleVelocityY = -cos(mouseAngle * DEG2RAD) * (RABBIT_BULLET_VELOCITY * 2);
|
||||
|
||||
setupBullet(
|
||||
&rabbitBulletPosition[availableBullet],
|
||||
&rabbitBulletPosition[availableBullets[0]],
|
||||
rabbitPosition->rabbitPosition[0],
|
||||
rabbitPosition->rabbitPosition[1],
|
||||
doubleVelocityX,
|
||||
@ -62,13 +64,22 @@ void attemptToFireRabbitBullet(
|
||||
);
|
||||
} else if (rabbitWeaponry->currentWeapon == SPREAD_SHOT_GUN) {
|
||||
// make sure three bullets are available
|
||||
for (i = 0; i < RABBIT_BULLET_LIMIT; ++i) {
|
||||
if (rabbitBulletPosition[i].isActive == 0) {
|
||||
availableBullets[okToFire++] = i;
|
||||
if (okToFire == 3) break;
|
||||
}
|
||||
}
|
||||
|
||||
if (okToFire < 3) return;
|
||||
|
||||
// if so, fire away
|
||||
for (i = -1; i <= 1; ++i) {
|
||||
doubleVelocityX = sin(rabbitPosition->mouseAngle * DEG2RAD) * (RABBIT_BULLET_VELOCITY * 2);
|
||||
doubleVelocityY = -cos(rabbitPosition->mouseAngle * DEG2RAD) * (RABBIT_BULLET_VELOCITY * 2);
|
||||
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[availableBullet],
|
||||
&rabbitBulletPosition[availableBullets[i]],
|
||||
rabbitPosition->rabbitPosition[0],
|
||||
rabbitPosition->rabbitPosition[1],
|
||||
doubleVelocityX,
|
||||
|
4
const.h
4
const.h
@ -10,11 +10,13 @@
|
||||
#define RABBIT_MOTION_MAX_SPEED (12)
|
||||
#define RABBIT_MOTION_VELOCITY_DECAY (5)
|
||||
|
||||
#define RABBIT_BULLET_LIMIT (12)
|
||||
#define RABBIT_BULLET_LIMIT (9)
|
||||
#define RABBIT_BULLET_VELOCITY ((RABBIT_MOTION_ACCELERATION / 2) + 1)
|
||||
#define RABBIT_BULLET_COOLDOWN (10)
|
||||
#define RABBIT_BULLET_HEIGHT_START (8)
|
||||
|
||||
#define RABBIT_BULLET_SHOTGUN_SPREAD (15)
|
||||
|
||||
#define RABBIT_HEALTH_MAX (100)
|
||||
|
||||
#define MOUSE_LIMIT_TOP (TILE_SIZE)
|
||||
|
34
game.c
34
game.c
@ -19,7 +19,12 @@
|
||||
#include "game.h"
|
||||
|
||||
// TODO: centralize these outside of game.c
|
||||
struct CompiledSpriteRender rabbit, mouse, bullet, enemy, enemyBullet;
|
||||
struct CompiledSpriteRender rabbit,
|
||||
mouse,
|
||||
bullet,
|
||||
enemy,
|
||||
enemyBullet,
|
||||
shotgun;
|
||||
struct SpriteBounds bounds;
|
||||
|
||||
struct BMPImage spritesheetImage;
|
||||
@ -41,6 +46,7 @@ struct EnemyPosition enemyPosition[ENEMY_MAX_COUNT];
|
||||
struct BulletPosition rabbitBulletPosition[RABBIT_BULLET_LIMIT];
|
||||
struct BulletPosition enemyBulletPosition[ENEMY_BULLET_LIMIT];
|
||||
struct RabbitWeaponry rabbitWeaponry;
|
||||
struct PlayerPowerup playerPowerup;
|
||||
|
||||
struct SpawnPointRange spawnPointRanges[4] = {
|
||||
// top
|
||||
@ -65,6 +71,12 @@ void setupRabbitBullets() {
|
||||
rabbitWeaponry.currentWeapon = SPREAD_SHOT_GUN;
|
||||
}
|
||||
|
||||
void setupPowerup() {
|
||||
playerPowerup.x = 100;
|
||||
playerPowerup.y = 100;
|
||||
playerPowerup.isActive = 0;
|
||||
}
|
||||
|
||||
void setupEnemyBullets() {
|
||||
int i;
|
||||
|
||||
@ -212,6 +224,17 @@ void setupRabbitSprites() {
|
||||
);
|
||||
}
|
||||
|
||||
void setupPowerupSprites() {
|
||||
buildCompiledSprite(
|
||||
&sprite_shotgun,
|
||||
&shotgun,
|
||||
SPRITE_SHOTGUN_WIDTH,
|
||||
SPRITE_SHOTGUN_HEIGHT,
|
||||
SPRITE_SHOTGUN_OFFSET_X,
|
||||
SPRITE_SHOTGUN_OFFSET_Y
|
||||
);
|
||||
}
|
||||
|
||||
void renderMouse() {
|
||||
mouse.x = rabbitPosition.mousePosition[0];
|
||||
mouse.y = rabbitPosition.mousePosition[1];
|
||||
@ -266,6 +289,13 @@ void renderEnemyBullets() {
|
||||
}
|
||||
}
|
||||
|
||||
void renderPowerup() {
|
||||
shotgun.x = playerPowerup.x;
|
||||
shotgun.y = playerPowerup.y;
|
||||
|
||||
drawCompiledSprite(&shotgun);
|
||||
}
|
||||
|
||||
void drawOnlyMouseArena() {
|
||||
mouse.x = rabbitPosition.oldMousePosition[0];
|
||||
mouse.y = rabbitPosition.oldMousePosition[1];
|
||||
@ -351,6 +381,7 @@ int setupGame() {
|
||||
setupRabbitSprites();
|
||||
setupRabbitBullets();
|
||||
setupEnemySprites();
|
||||
setupPowerupSprites();
|
||||
|
||||
setVideoMode(VIDEO_MODE_VGA_256);
|
||||
bmp256ColorPaletteToVGAColorPalette(&spritesheetImage, vgaColors);
|
||||
@ -452,6 +483,7 @@ void handleRedraw() {
|
||||
|
||||
redrawArena();
|
||||
|
||||
renderPowerup();
|
||||
renderRabbit();
|
||||
renderEnemies();
|
||||
renderMouse();
|
||||
|
4
makefile
4
makefile
@ -1,4 +1,4 @@
|
||||
obj = game.o bmpload.o arena.o movement.o sprites.o combat.o
|
||||
obj = sprites.o game.o bmpload.o arena.o movement.o combat.o
|
||||
|
||||
all: system/system.lib game.exe .SYMBOLIC
|
||||
|
||||
@ -17,7 +17,7 @@ sprites.asm: sprtsht.bmp spritesheet.yml
|
||||
bin/build_spritesheet_asm.rb
|
||||
|
||||
game.exe: $(obj) system/system.lib
|
||||
wcl386 -q -bt=dos -l=dos4g $(obj) system/system.lib
|
||||
wcl386 -q -fe=game -bt=dos -l=dos4g $(obj) system/system.lib
|
||||
|
||||
clean: .SYMBOLIC
|
||||
rm *.o
|
||||
|
10
movement.h
10
movement.h
@ -24,6 +24,16 @@ struct RabbitPosition {
|
||||
struct RabbitWeaponry {
|
||||
char cooldown;
|
||||
char currentWeapon;
|
||||
int currentWeaponRemainingRounds;
|
||||
};
|
||||
|
||||
#define POWERUP_SHOTGUN (0);
|
||||
|
||||
struct PlayerPowerup {
|
||||
int x, y;
|
||||
int cooldown;
|
||||
char isActive;
|
||||
char type;
|
||||
};
|
||||
|
||||
struct BulletPosition {
|
||||
|
155
sprites.asm
155
sprites.asm
@ -6,6 +6,7 @@ PUBLIC sprite_rabbit_
|
||||
PUBLIC sprite_mouse_
|
||||
PUBLIC sprite_bullet_
|
||||
PUBLIC sprite_enemy_
|
||||
PUBLIC sprite_shotgun_
|
||||
|
||||
.386
|
||||
.model flat,c
|
||||
@ -1403,4 +1404,158 @@ sprite_enemy_:
|
||||
ret
|
||||
|
||||
|
||||
sprite_shotgun_:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
|
||||
|
||||
mov BYTE PTR [eax + -1926], 6
|
||||
mov BYTE PTR [eax + -1925], 6
|
||||
mov BYTE PTR [eax + -1924], 6
|
||||
mov BYTE PTR [eax + -1923], 6
|
||||
mov BYTE PTR [eax + -1922], 6
|
||||
mov BYTE PTR [eax + -1921], 6
|
||||
mov BYTE PTR [eax + -1920], 6
|
||||
mov BYTE PTR [eax + -1919], 6
|
||||
mov BYTE PTR [eax + -1918], 6
|
||||
mov BYTE PTR [eax + -1917], 6
|
||||
mov BYTE PTR [eax + -1916], 6
|
||||
mov BYTE PTR [eax + -1915], 6
|
||||
mov BYTE PTR [eax + -1606], 6
|
||||
mov BYTE PTR [eax + -1605], 6
|
||||
mov BYTE PTR [eax + -1604], 6
|
||||
mov BYTE PTR [eax + -1603], 6
|
||||
mov BYTE PTR [eax + -1602], 6
|
||||
mov BYTE PTR [eax + -1601], 6
|
||||
mov BYTE PTR [eax + -1600], 6
|
||||
mov BYTE PTR [eax + -1599], 6
|
||||
mov BYTE PTR [eax + -1598], 6
|
||||
mov BYTE PTR [eax + -1597], 6
|
||||
mov BYTE PTR [eax + -1596], 6
|
||||
mov BYTE PTR [eax + -1595], 6
|
||||
mov BYTE PTR [eax + -1286], 6
|
||||
mov BYTE PTR [eax + -1285], 6
|
||||
mov BYTE PTR [eax + -1284], 6
|
||||
mov BYTE PTR [eax + -1283], 6
|
||||
mov BYTE PTR [eax + -1282], 6
|
||||
mov BYTE PTR [eax + -1281], 6
|
||||
mov BYTE PTR [eax + -1280], 6
|
||||
mov BYTE PTR [eax + -1279], 6
|
||||
mov BYTE PTR [eax + -1278], 6
|
||||
mov BYTE PTR [eax + -1277], 6
|
||||
mov BYTE PTR [eax + -1276], 6
|
||||
mov BYTE PTR [eax + -1275], 6
|
||||
mov BYTE PTR [eax + -966], 6
|
||||
mov BYTE PTR [eax + -965], 6
|
||||
mov BYTE PTR [eax + -964], 6
|
||||
mov BYTE PTR [eax + -963], 6
|
||||
mov BYTE PTR [eax + -962], 6
|
||||
mov BYTE PTR [eax + -961], 6
|
||||
mov BYTE PTR [eax + -960], 6
|
||||
mov BYTE PTR [eax + -959], 6
|
||||
mov BYTE PTR [eax + -958], 6
|
||||
mov BYTE PTR [eax + -957], 6
|
||||
mov BYTE PTR [eax + -956], 6
|
||||
mov BYTE PTR [eax + -955], 6
|
||||
mov BYTE PTR [eax + -646], 6
|
||||
mov BYTE PTR [eax + -645], 6
|
||||
mov BYTE PTR [eax + -644], 6
|
||||
mov BYTE PTR [eax + -643], 6
|
||||
mov BYTE PTR [eax + -642], 6
|
||||
mov BYTE PTR [eax + -641], 6
|
||||
mov BYTE PTR [eax + -640], 6
|
||||
mov BYTE PTR [eax + -639], 6
|
||||
mov BYTE PTR [eax + -638], 6
|
||||
mov BYTE PTR [eax + -637], 6
|
||||
mov BYTE PTR [eax + -636], 6
|
||||
mov BYTE PTR [eax + -635], 6
|
||||
mov BYTE PTR [eax + -326], 6
|
||||
mov BYTE PTR [eax + -325], 6
|
||||
mov BYTE PTR [eax + -324], 6
|
||||
mov BYTE PTR [eax + -323], 6
|
||||
mov BYTE PTR [eax + -322], 6
|
||||
mov BYTE PTR [eax + -321], 6
|
||||
mov BYTE PTR [eax + -320], 6
|
||||
mov BYTE PTR [eax + -319], 6
|
||||
mov BYTE PTR [eax + -318], 6
|
||||
mov BYTE PTR [eax + -317], 6
|
||||
mov BYTE PTR [eax + -316], 6
|
||||
mov BYTE PTR [eax + -315], 6
|
||||
mov BYTE PTR [eax + -6], 6
|
||||
mov BYTE PTR [eax + -5], 6
|
||||
mov BYTE PTR [eax + -4], 6
|
||||
mov BYTE PTR [eax + -3], 6
|
||||
mov BYTE PTR [eax + -2], 6
|
||||
mov BYTE PTR [eax + -1], 6
|
||||
mov BYTE PTR [eax + 0], 6
|
||||
mov BYTE PTR [eax + 1], 6
|
||||
mov BYTE PTR [eax + 2], 6
|
||||
mov BYTE PTR [eax + 3], 6
|
||||
mov BYTE PTR [eax + 4], 6
|
||||
mov BYTE PTR [eax + 5], 6
|
||||
mov BYTE PTR [eax + 314], 6
|
||||
mov BYTE PTR [eax + 315], 6
|
||||
mov BYTE PTR [eax + 316], 6
|
||||
mov BYTE PTR [eax + 317], 6
|
||||
mov BYTE PTR [eax + 318], 6
|
||||
mov BYTE PTR [eax + 319], 6
|
||||
mov BYTE PTR [eax + 320], 6
|
||||
mov BYTE PTR [eax + 321], 6
|
||||
mov BYTE PTR [eax + 322], 6
|
||||
mov BYTE PTR [eax + 323], 6
|
||||
mov BYTE PTR [eax + 324], 6
|
||||
mov BYTE PTR [eax + 325], 6
|
||||
mov BYTE PTR [eax + 634], 6
|
||||
mov BYTE PTR [eax + 635], 6
|
||||
mov BYTE PTR [eax + 636], 6
|
||||
mov BYTE PTR [eax + 637], 6
|
||||
mov BYTE PTR [eax + 638], 6
|
||||
mov BYTE PTR [eax + 639], 6
|
||||
mov BYTE PTR [eax + 640], 6
|
||||
mov BYTE PTR [eax + 641], 6
|
||||
mov BYTE PTR [eax + 642], 6
|
||||
mov BYTE PTR [eax + 643], 6
|
||||
mov BYTE PTR [eax + 644], 6
|
||||
mov BYTE PTR [eax + 645], 6
|
||||
mov BYTE PTR [eax + 954], 6
|
||||
mov BYTE PTR [eax + 955], 6
|
||||
mov BYTE PTR [eax + 956], 6
|
||||
mov BYTE PTR [eax + 957], 6
|
||||
mov BYTE PTR [eax + 958], 6
|
||||
mov BYTE PTR [eax + 959], 6
|
||||
mov BYTE PTR [eax + 960], 6
|
||||
mov BYTE PTR [eax + 961], 6
|
||||
mov BYTE PTR [eax + 962], 6
|
||||
mov BYTE PTR [eax + 963], 6
|
||||
mov BYTE PTR [eax + 964], 6
|
||||
mov BYTE PTR [eax + 965], 6
|
||||
mov BYTE PTR [eax + 1274], 6
|
||||
mov BYTE PTR [eax + 1275], 6
|
||||
mov BYTE PTR [eax + 1276], 6
|
||||
mov BYTE PTR [eax + 1277], 6
|
||||
mov BYTE PTR [eax + 1278], 6
|
||||
mov BYTE PTR [eax + 1279], 6
|
||||
mov BYTE PTR [eax + 1280], 6
|
||||
mov BYTE PTR [eax + 1281], 6
|
||||
mov BYTE PTR [eax + 1282], 6
|
||||
mov BYTE PTR [eax + 1283], 6
|
||||
mov BYTE PTR [eax + 1284], 6
|
||||
mov BYTE PTR [eax + 1285], 6
|
||||
mov BYTE PTR [eax + 1594], 6
|
||||
mov BYTE PTR [eax + 1595], 6
|
||||
mov BYTE PTR [eax + 1596], 6
|
||||
mov BYTE PTR [eax + 1597], 6
|
||||
mov BYTE PTR [eax + 1598], 6
|
||||
mov BYTE PTR [eax + 1599], 6
|
||||
mov BYTE PTR [eax + 1600], 6
|
||||
mov BYTE PTR [eax + 1601], 6
|
||||
mov BYTE PTR [eax + 1602], 6
|
||||
mov BYTE PTR [eax + 1603], 6
|
||||
mov BYTE PTR [eax + 1604], 6
|
||||
mov BYTE PTR [eax + 1605], 6
|
||||
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
|
||||
end
|
||||
|
11
sprites.h
11
sprites.h
@ -81,5 +81,16 @@ extern void sprite_enemy(byte *);
|
||||
#define SPRITE_ENEMY_OFFSET_Y (8)
|
||||
|
||||
|
||||
extern void sprite_shotgun(byte *);
|
||||
|
||||
#define SPRITE_SHOTGUN_WIDTH (12)
|
||||
|
||||
#define SPRITE_SHOTGUN_HEIGHT (12)
|
||||
|
||||
#define SPRITE_SHOTGUN_OFFSET_X (6)
|
||||
|
||||
#define SPRITE_SHOTGUN_OFFSET_Y (6)
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
BIN
spritesheet.xcf
BIN
spritesheet.xcf
Binary file not shown.
@ -33,3 +33,7 @@ files:
|
||||
position: [0, 20]
|
||||
dimensions: [16, 16]
|
||||
offset: [8, 8]
|
||||
shotgun:
|
||||
position: [32, 20]
|
||||
dimensions: [12, 12]
|
||||
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
Block a user