Skip to content

Commit

Permalink
Added some sounds.
Browse files Browse the repository at this point in the history
  • Loading branch information
kvisle committed Apr 21, 2012
1 parent 3a34caf commit cfec4fe
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 0 deletions.
Binary file added assets/gotjetpack.wav
Binary file not shown.
Binary file added assets/gotkey.wav
Binary file not shown.
Binary file added assets/jump.wav
Binary file not shown.
Binary file added assets/opendoor.wav
Binary file not shown.
5 changes: 5 additions & 0 deletions src/door.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#include "door.h"
#include "game.h"
#include "resourcemanager.h"
#include "sound.h"

door::door(game *g, int x, int y, int z)
: sprite(g, x, y, z, "gfx.png")
{
loadJson(std::string("door.json"));
setAnimation(0);
opensound = g->rm->getSound("opendoor.wav");
}

void
Expand All @@ -14,5 +18,6 @@ door::unLock(drawable *d)
return;

setAnimation(1);
opensound->play();
}

3 changes: 3 additions & 0 deletions src/door.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@

#include "sprite.h"

class sound;

class door : public sprite {
public:
door(game *g, int x, int y, int z);

virtual void unLock(drawable *d);
sound *opensound;
};

#endif /* __DOOR_H__ */
7 changes: 7 additions & 0 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,12 @@ item::item(game *g, int x, int y, int z)
int
item::identify()
{
playGot();
return animation;
}

void
item::playGot()
{

}
1 change: 1 addition & 0 deletions src/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class item : public sprite {
item(game *g, int x, int y, int z);

virtual int identify();
virtual void playGot();

};

Expand Down
11 changes: 11 additions & 0 deletions src/key.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
#include "key.h"
#include "game.h"
#include "resourcemanager.h"
#include "sound.h"

key::key(game *g, int x, int y, int z)
: item(g, x, y, z)
{
setAnimation(0);

getsound = g->rm->getSound("gotkey.wav");
}

void
key::playGot()
{
getsound->play();
}
5 changes: 5 additions & 0 deletions src/key.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@
#include "item.h"

class game;
class sound;

class key : public item {
public:
key(game *g, int x, int y, int z);

virtual void playGot();

sound *getsound;
};
#endif /* __KEY_H__ */
4 changes: 4 additions & 0 deletions src/player.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include <cstdio>
#include "player.h"
#include "game.h"
#include "resourcemanager.h"
#include "input.h"
#include "sound.h"
#include "bits.h"

#define ANIMATION_IDLE 0
Expand All @@ -13,6 +15,7 @@ player::player(game *g, int x, int y, int z)
{
loadJson(std::string("player.json"));
g->in->subscribe(this);
jumpsound = g->rm->getSound("jump.wav");

walking = 0;
falling = 0;
Expand Down Expand Up @@ -94,6 +97,7 @@ player::moveJump()
{
jump_progress = 0;
jump_start = 0;
jumpsound->play();
}

if ( jump_progress >= 20 )
Expand Down
4 changes: 4 additions & 0 deletions src/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "sprite.h"
#include "input.h"

class sound;

class player : public sprite {
public:
player(game *g, int x, int y, int z);
Expand All @@ -29,6 +31,8 @@ class player : public sprite {
int moveGravity();
int moveLeftRight();
int moveJump();

sound *jumpsound;
};

#endif /* __PLAYER_H__ */

0 comments on commit cfec4fe

Please sign in to comment.