diff --git a/src/combat/grenade.c b/src/combat/grenade.c index 510f65c..0f07296 100644 --- a/src/combat/grenade.c +++ b/src/combat/grenade.c @@ -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; diff --git a/src/combat/laser.c b/src/combat/laser.c index b108722..594e51d 100644 --- a/src/combat/laser.c +++ b/src/combat/laser.c @@ -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; diff --git a/src/combat/missile.c b/src/combat/missile.c index 99a4cec..18a43cf 100644 --- a/src/combat/missile.c +++ b/src/combat/missile.c @@ -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; diff --git a/src/combat/weapons.c b/src/combat/weapons.c index 5ac41cd..6220ab3 100644 --- a/src/combat/weapons.c +++ b/src/combat/weapons.c @@ -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]; +} diff --git a/src/entities/entity.c b/src/entities/entity.c index fd9cf0a..94ee22a 100644 --- a/src/entities/entity.c +++ b/src/entities/entity.c @@ -53,7 +53,7 @@ void initEntity(Entity *e) e->thinkTime = 0; - e->spriteFrame = -1; + e->spriteFrame = 0; e->spriteTime = 0; e->init = init; diff --git a/src/entities/items/weaponPickup.c b/src/entities/items/weaponPickup.c index 9ac915a..7c84f1c 100644 --- a/src/entities/items/weaponPickup.c +++ b/src/entities/items/weaponPickup.c @@ -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; } diff --git a/src/entities/items/weaponPickup.h b/src/entities/items/weaponPickup.h index 0be11af..47cd7c5 100644 --- a/src/entities/items/weaponPickup.h +++ b/src/entities/items/weaponPickup.h @@ -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; diff --git a/src/world/hud.c b/src/world/hud.c index 3a68dc5..9e2c168 100644 --- a/src/world/hud.c +++ b/src/world/hud.c @@ -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); diff --git a/src/world/hud.h b/src/world/hud.h index 9a7672d..6b56c2a 100644 --- a/src/world/hud.h +++ b/src/world/hud.h @@ -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; diff --git a/src/world/world.c b/src/world/world.c index d3445e1..7a9cc85 100644 --- a/src/world/world.c +++ b/src/world/world.c @@ -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(); diff --git a/src/world/world.h b/src/world/world.h index ed13fd4..c7eed8b 100644 --- a/src/world/world.h +++ b/src/world/world.h @@ -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;