Weapon fixes.
This commit is contained in:
parent
827a825c2d
commit
9841418d20
|
@ -29,7 +29,7 @@ static void explode(void);
|
|||
|
||||
void initGrenade(Bullet *b)
|
||||
{
|
||||
b->flags |= EF_BOUNCES | EF_IGNORE_BULLETS | EF_KILL_OFFSCREEN | EF_FRICTIONLESS | EF_NO_TELEPORT;
|
||||
b->flags = EF_BOUNCES | EF_IGNORE_BULLETS | EF_KILL_OFFSCREEN | EF_FRICTIONLESS | EF_NO_TELEPORT;
|
||||
|
||||
superBounce = b->bounce;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ static void touch(Entity *other);
|
|||
|
||||
void initLaser(Bullet *b)
|
||||
{
|
||||
b->flags |= EF_WEIGHTLESS | EF_BOUNCES | EF_FRICTIONLESS | EF_NO_ENVIRONMENT | EF_IGNORE_BULLETS | EF_KILL_OFFSCREEN | EF_NO_TELEPORT;
|
||||
b->flags = EF_WEIGHTLESS | EF_BOUNCES | EF_FRICTIONLESS | EF_NO_ENVIRONMENT | EF_IGNORE_BULLETS | EF_KILL_OFFSCREEN | EF_NO_TELEPORT;
|
||||
|
||||
b->tick = tick;
|
||||
b->touch = touch;
|
||||
|
|
|
@ -25,7 +25,7 @@ static void touch(Entity *other);
|
|||
|
||||
void initMissile(Bullet *b)
|
||||
{
|
||||
b->flags |= EF_WEIGHTLESS | EF_NO_ENVIRONMENT | EF_IGNORE_BULLETS | EF_KILL_OFFSCREEN | EF_NO_TELEPORT;
|
||||
b->flags = EF_WEIGHTLESS | EF_NO_ENVIRONMENT | EF_IGNORE_BULLETS | EF_KILL_OFFSCREEN | EF_NO_TELEPORT;
|
||||
|
||||
b->tick = tick;
|
||||
b->touch = touch;
|
||||
|
|
|
@ -21,6 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "weapons.h"
|
||||
|
||||
Bullet *createBaseBullet(Unit *owner);
|
||||
static void tick(void);
|
||||
static void touch(Entity *other);
|
||||
|
||||
static Sprite *bulletSprite[2];
|
||||
static Sprite *plasmaSprite[2];
|
||||
|
@ -33,8 +35,7 @@ static Sprite *alienGrenadeSprite;
|
|||
static Sprite *shotgunPelletSprite;
|
||||
static Sprite *missileSprite[2];
|
||||
|
||||
static void tick(void);
|
||||
static void touch(Entity *other);
|
||||
static char *weaponName[WPN_ANY];
|
||||
|
||||
void initWeapons(void)
|
||||
{
|
||||
|
@ -59,6 +60,12 @@ void initWeapons(void)
|
|||
|
||||
missileSprite[0] = getSprite("MissileRight");
|
||||
missileSprite[1] = getSprite("MissileLeft");
|
||||
|
||||
weaponName[WPN_PISTOL] = _("Pistol");
|
||||
weaponName[WPN_PLASMA] = _("Plasma Rifle");
|
||||
weaponName[WPN_SPREAD] = _("Spread Gun");
|
||||
weaponName[WPN_LASER] = _("Laser Cannon");
|
||||
weaponName[WPN_GRENADES] = _("Grenades");
|
||||
}
|
||||
|
||||
/* only used by Bob */
|
||||
|
@ -242,8 +249,6 @@ Bullet *createBaseBullet(Unit *owner)
|
|||
|
||||
bullet = malloc(sizeof(Bullet));
|
||||
memset(bullet, 0, sizeof(Bullet));
|
||||
world.entityTail->next = (Entity*)bullet;
|
||||
world.entityTail = (Entity*)bullet;
|
||||
|
||||
initEntity((Entity*)bullet);
|
||||
|
||||
|
@ -345,3 +350,8 @@ int getRandomPlayerWeapon(int excludeGrenades)
|
|||
|
||||
return rand() % WPN_ANY;
|
||||
}
|
||||
|
||||
const char *getWeaponName(int i)
|
||||
{
|
||||
return weaponName[i];
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ void initEntity(Entity *e)
|
|||
|
||||
e->thinkTime = 0;
|
||||
|
||||
e->spriteFrame = -1;
|
||||
e->spriteFrame = 0;
|
||||
e->spriteTime = 0;
|
||||
|
||||
e->init = init;
|
||||
|
|
|
@ -24,14 +24,6 @@ static void (*itemTick)(void);
|
|||
static void tick(void);
|
||||
static void touch(Entity *other);
|
||||
|
||||
static char *description[WPN_ANY] = {
|
||||
"Pistol",
|
||||
"Plasma Rifle",
|
||||
"Spread Gun",
|
||||
"Laser Cannon",
|
||||
"Grenades"
|
||||
};
|
||||
|
||||
void initWeaponPickup(Entity *e)
|
||||
{
|
||||
Item *i;
|
||||
|
@ -88,7 +80,7 @@ static void touch(Entity *other)
|
|||
break;
|
||||
|
||||
default:
|
||||
setGameplayMessage(MSG_STANDARD, _("Picked up a %s"), _(description[i->weaponType]));
|
||||
setGameplayMessage(MSG_STANDARD, _("Picked up a %s"), getWeaponName(i->weaponType));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ extern void initConsumable(Entity *e);
|
|||
extern Sprite *getSprite(char *name);
|
||||
extern void pickupItem(void);
|
||||
extern int touchedPlayer(Entity *e);
|
||||
extern const char *getWeaponName(int i);
|
||||
|
||||
extern Entity *self;
|
||||
extern World world;
|
||||
|
|
|
@ -51,6 +51,8 @@ void drawHud(void)
|
|||
{
|
||||
int x, y;
|
||||
|
||||
drawText(SCREEN_WIDTH - 5, 5, 16, TA_RIGHT, colors.white, "Weapon: %s", getWeaponName(world.bob->weaponType));
|
||||
|
||||
if (messageTime > 0)
|
||||
{
|
||||
drawRect(0, SCREEN_HEIGHT - 32, SCREEN_WIDTH, 32, 0, 0, 0, 200);
|
||||
|
|
|
@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
extern void showWidgetGroup(char *groupName);
|
||||
extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...);
|
||||
extern void drawRect(int x, int y, int w, int h, int r, int g, int b, int a);
|
||||
const char *getWeaponName(int i);
|
||||
|
||||
extern Dev dev;
|
||||
extern Camera camera;
|
||||
|
|
|
@ -41,9 +41,13 @@ void initWorld(void)
|
|||
{
|
||||
background = getTexture(world.background);
|
||||
|
||||
initQuadtree(&world.quadtree);
|
||||
|
||||
initObjectives();
|
||||
|
||||
initHud();
|
||||
|
||||
initWeapons();
|
||||
|
||||
world.enemySpawnTimer = (FPS * rrnd(world.minEnemySpawnTime, world.maxEnemySpawnTime));
|
||||
|
||||
|
@ -68,8 +72,10 @@ void initWorld(void)
|
|||
|
||||
startMission();
|
||||
|
||||
/*
|
||||
world.bob->x = 166 * MAP_TILE_SIZE;
|
||||
world.bob->y = 98 * MAP_TILE_SIZE;
|
||||
*/
|
||||
}
|
||||
|
||||
static void logic(void)
|
||||
|
@ -175,6 +181,7 @@ static void doWorldInProgress(void)
|
|||
game.config.control[CONTROL_UP] = app.keyboard[SDL_SCANCODE_W];
|
||||
game.config.control[CONTROL_DOWN] = app.keyboard[SDL_SCANCODE_S];
|
||||
game.config.control[CONTROL_JUMP] = app.keyboard[SDL_SCANCODE_I];
|
||||
game.config.control[CONTROL_FIRE] = app.keyboard[SDL_SCANCODE_J];
|
||||
|
||||
if (app.keyboard[SDL_SCANCODE_SPACE])
|
||||
{
|
||||
|
@ -183,6 +190,31 @@ static void doWorldInProgress(void)
|
|||
app.keyboard[SDL_SCANCODE_SPACE] = 0;
|
||||
}
|
||||
|
||||
if (app.keyboard[SDL_SCANCODE_1])
|
||||
{
|
||||
world.bob->weaponType = WPN_PISTOL;
|
||||
}
|
||||
|
||||
if (app.keyboard[SDL_SCANCODE_2])
|
||||
{
|
||||
world.bob->weaponType = WPN_PLASMA;
|
||||
}
|
||||
|
||||
if (app.keyboard[SDL_SCANCODE_3])
|
||||
{
|
||||
world.bob->weaponType = WPN_SPREAD;
|
||||
}
|
||||
|
||||
if (app.keyboard[SDL_SCANCODE_4])
|
||||
{
|
||||
world.bob->weaponType = WPN_LASER;
|
||||
}
|
||||
|
||||
if (app.keyboard[SDL_SCANCODE_5])
|
||||
{
|
||||
world.bob->weaponType = WPN_GRENADES;
|
||||
}
|
||||
|
||||
if (!world.showingInfoMessage)
|
||||
{
|
||||
doBob();
|
||||
|
|
|
@ -53,6 +53,8 @@ extern void blitScaled(SDL_Texture *texture, int x, int y, int w, int h, int cen
|
|||
extern void clearScreen(void);
|
||||
extern void drawHud(void);
|
||||
extern void initHud(void);
|
||||
extern void initWeapons(void);
|
||||
extern void initQuadtree(Quadtree *root);
|
||||
|
||||
extern App app;
|
||||
extern Dev dev;
|
||||
|
|
Loading…
Reference in New Issue