New sounds for health and keys (#219)

Fix health pickup timer logic (#219)
This commit is contained in:
Cong
2014-03-18 00:41:35 +11:00
parent 457c768d6c
commit d29732e100
10 changed files with 42 additions and 14 deletions

View File

@@ -2,4 +2,5 @@ All .px files are freeware, copyright Ronny Wester. See doc/README_DATA
Unless otherwise specified, all artwork is licensed CC0 "Public Domain Dedication", copyright Cong Xu.
But please let me know if you like or use this artwork :)
https://creativecommons.org/publicdomain/zero/1.0/

5
graphics/health.png.txt Normal file
View File

@@ -0,0 +1,5 @@
Adapted from Various inventory 24 pixel icon set
By OceansDream
http://opengameart.org/content/various-inventory-24-pixel-icon-set
http://creativecommons.org/licenses/by/3.0/

4
sounds/health.txt Normal file
View File

@@ -0,0 +1,4 @@
Derived from beeps-5.wav by Greencouch
http://freesound.org/people/Greencouch/sounds/124905/
http://creativecommons.org/licenses/by/3.0/

BIN
sounds/health.wav Normal file

Binary file not shown.

4
sounds/key.txt Normal file
View File

@@ -0,0 +1,4 @@
Derived from Keys 06.wav by LG
http://freesound.org/people/LG/sounds/73093/
http://creativecommons.org/licenses/by/3.0/

BIN
sounds/key.wav Normal file

Binary file not shown.

View File

@@ -481,6 +481,7 @@ static void CheckTrigger(TActor *actor, Vec2i pos)
static void PickupObject(TActor * actor, TObject * object)
{
bool isKey = false;
switch (object->Type)
{
case OBJ_JEWEL:
@@ -490,6 +491,10 @@ static void PickupObject(TActor * actor, TObject * object)
e.u.Score.PlayerIndex = actor->pData->playerIndex;
e.u.Score.Score = PICKUP_SCORE;
GameEventsEnqueue(&gGameEvents, e);
SoundPlayAt(
&gSoundDevice,
SND_PICKUP,
Vec2iNew(actor->tileItem.x, actor->tileItem.y));
}
break;
@@ -499,32 +504,38 @@ static void PickupObject(TActor * actor, TObject * object)
e.Type = GAME_EVENT_TAKE_HEALTH_PICKUP;
e.u.PickupPlayer = actor->pData->playerIndex;
GameEventsEnqueue(&gGameEvents, e);
SoundPlayAt(
&gSoundDevice, SND_HEALTH,
Vec2iNew(actor->tileItem.x, actor->tileItem.y));
}
break;
case OBJ_KEYCARD_RED:
gMission.flags |= FLAGS_KEYCARD_RED;
isKey = true;
break;
case OBJ_KEYCARD_BLUE:
gMission.flags |= FLAGS_KEYCARD_BLUE;
isKey = true;
break;
case OBJ_KEYCARD_GREEN:
gMission.flags |= FLAGS_KEYCARD_GREEN;
isKey = true;
break;
case OBJ_KEYCARD_YELLOW:
gMission.flags |= FLAGS_KEYCARD_YELLOW;
isKey = true;
break;
}
if (isKey)
{
SoundPlayAt(
&gSoundDevice, SND_KEY,
Vec2iNew(actor->tileItem.x, actor->tileItem.y));
}
CheckMissionObjective(
&gMission, object->tileItem.flags, OBJECTIVE_COLLECT);
RemoveObject(object);
SoundPlayAt(
&gSoundDevice,
SND_PICKUP,
Vec2iNew(actor->tileItem.x, actor->tileItem.y));
}
bool TryMoveActor(TActor *actor, Vec2i pos)
@@ -688,7 +699,6 @@ void ActorHeal(TActor *actor, int health)
{
actor->health += health;
actor->health = MIN(actor->health, 200 * gConfig.Game.PlayerHP / 100);
// TODO: play heal sound
}
void InjureActor(TActor * actor, int injury)

View File

@@ -30,8 +30,8 @@
#include "ai_utils.h"
#define SPAWN_TIME (30 * FPS_FRAMELIMIT)
#define TIME_DECAY_EXPONENT 0.97
#define SPAWN_TIME (20 * FPS_FRAMELIMIT)
#define TIME_DECAY_EXPONENT 1.04
#define HEALTH_W 6
#define HEALTH_H 6
#define MAX_TILES_PER_PICKUP 625
@@ -71,7 +71,7 @@ void HealthPickupsUpdate(HealthPickups *h, int ticks)
}
}
// Double spawn rate if near 0 health
scalar *= maxHealth * 2.0 / (minHealth + maxHealth);
scalar *= (minHealth + maxHealth) / (maxHealth * 2.0);
// Scale down over time
scalar *= pow(TIME_DECAY_EXPONENT, h->pickupsSpawned);

View File

@@ -22,7 +22,7 @@
This file incorporates work covered by the following copyright and
permission notice:
Copyright (c) 2013, Cong Xu
Copyright (c) 2013-2014, Cong Xu
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -100,7 +100,9 @@ SoundDevice gSoundDevice =
{"sounds/hit_hard.wav", 0, NULL},
{"sounds/hit_petrify.wav", 0, NULL},
{"sounds/footstep.wav", 0, NULL},
{"sounds/slide.wav", 0, NULL}
{"sounds/slide.wav", 0, NULL},
{"sounds/health.wav", 0, NULL},
{"sounds/key.wav", 0, NULL}
}
};

View File

@@ -22,7 +22,7 @@
This file incorporates work covered by the following copyright and
permission notice:
Copyright (c) 2013, Cong Xu
Copyright (c) 2013-2014, Cong Xu
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -87,6 +87,8 @@ typedef enum
SND_HIT_PETRIFY,
SND_FOOTSTEP,
SND_SLIDE,
SND_HEALTH,
SND_KEY,
SND_COUNT
} sound_e;