Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added some sounds.

  • Loading branch information...
commit cfec4fe03dff9b2be9247c7058ab4eb7b4f074b5 1 parent 3a34caf
@kvisle authored
View
BIN  assets/gotjetpack.wav
Binary file not shown
View
BIN  assets/gotkey.wav
Binary file not shown
View
BIN  assets/jump.wav
Binary file not shown
View
BIN  assets/opendoor.wav
Binary file not shown
View
5 src/door.cpp
@@ -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
@@ -14,5 +18,6 @@ door::unLock(drawable *d)
return;
setAnimation(1);
+ opensound->play();
}
View
3  src/door.h
@@ -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__ */
View
7 src/item.cpp
@@ -10,5 +10,12 @@ item::item(game *g, int x, int y, int z)
int
item::identify()
{
+ playGot();
return animation;
}
+
+void
+item::playGot()
+{
+
+}
View
1  src/item.h
@@ -10,6 +10,7 @@ class item : public sprite {
item(game *g, int x, int y, int z);
virtual int identify();
+ virtual void playGot();
};
View
11 src/key.cpp
@@ -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();
}
View
5 src/key.h
@@ -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__ */
View
4 src/player.cpp
@@ -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
@@ -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;
@@ -94,6 +97,7 @@ player::moveJump()
{
jump_progress = 0;
jump_start = 0;
+ jumpsound->play();
}
if ( jump_progress >= 20 )
View
4 src/player.h
@@ -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);
@@ -29,6 +31,8 @@ class player : public sprite {
int moveGravity();
int moveLeftRight();
int moveJump();
+
+ sound *jumpsound;
};
#endif /* __PLAYER_H__ */
Please sign in to comment.
Something went wrong with that request. Please try again.