TESTTRAZE: added sounds and fixed grid size
parent
4fbfd2bc5f
commit
cbd4e7c6ee
|
@ -0,0 +1,4 @@
|
|||
Digital SFX set by Kenney Vleugels (www.kenney.nl)
|
||||
|
||||
You may use these sounds in personal and commercial projects.
|
||||
Credit (www.kenney.nl) would be nice but is not mandatory.
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -11,6 +11,12 @@ if (MOSQUITTO_FOUND)
|
|||
set(FILES
|
||||
shared/font.ttf
|
||||
testtraze/testtraze-keybindings.cfg
|
||||
testtraze/sound/frag.ogg
|
||||
testtraze/sound/suicide.ogg
|
||||
testtraze/sound/collision.ogg
|
||||
testtraze/sound/join.ogg
|
||||
testtraze/sound/you_lose.ogg
|
||||
testtraze/sound/you_win.ogg
|
||||
)
|
||||
engine_add_executable(TARGET ${PROJECT_NAME} SRCS ${SRCS} FILES ${FILES} WINDOWED NOINSTALL)
|
||||
engine_target_link_libraries(TARGET ${PROJECT_NAME} DEPENDENCIES testcore voxelrender voxelfont util audio ${MOSQUITTO_LIBRARIES})
|
||||
|
|
|
@ -18,7 +18,9 @@ TestTraze::TestTraze(const metric::MetricPtr& metric, const io::FilesystemPtr& f
|
|||
Super(metric, filesystem, eventBus, timeProvider), _protocol(eventBus), _voxelFontRender(FontSize, 4, voxel::VoxelFont::OriginUpperLeft), _soundMgr(filesystem) {
|
||||
init(ORGANISATION, "testtraze");
|
||||
setRenderAxis(false);
|
||||
setRelativeMouseMode(false);
|
||||
setFramesPerSecondsCap(60);
|
||||
_allowRelativeMouseMode = false;
|
||||
_eventBus->subscribe<traze::NewGridEvent>(*this);
|
||||
_eventBus->subscribe<traze::NewGamesEvent>(*this);
|
||||
_eventBus->subscribe<traze::PlayerListEvent>(*this);
|
||||
|
@ -142,19 +144,37 @@ void TestTraze::onEvent(const traze::BikeEvent& event) {
|
|||
|
||||
void TestTraze::onEvent(const traze::TickerEvent& event) {
|
||||
const traze::Ticker& ticker = event.get();
|
||||
const std::string& name = playerName(ticker.fragger);
|
||||
const std::string& fraggerName = playerName(ticker.fragger);
|
||||
const std::string& casualtyName = playerName(ticker.casualty);
|
||||
switch (ticker.type) {
|
||||
case traze::TickerType::Frag:
|
||||
sound("frag");
|
||||
_messageQueue.message("%s fragged another player", name.c_str());
|
||||
if (ticker.fragger == _protocol.playerId()) {
|
||||
sound("you_win");
|
||||
_messageQueue.message("You fragged %s", casualtyName.c_str());
|
||||
} else if (ticker.casualty == _protocol.playerId()) {
|
||||
sound("you_lose");
|
||||
_messageQueue.message("You were fragged by %s", fraggerName.c_str());
|
||||
} else {
|
||||
_messageQueue.message("%s fragged %s", fraggerName.c_str(), casualtyName.c_str());
|
||||
}
|
||||
break;
|
||||
case traze::TickerType::Suicide:
|
||||
sound("suicide");
|
||||
_messageQueue.message("%s committed suicide", name.c_str());
|
||||
if (ticker.casualty == (int)_protocol.playerId()) {
|
||||
sound("you_lose");
|
||||
} else {
|
||||
sound("suicide");
|
||||
}
|
||||
_messageQueue.message("%s committed suicide", fraggerName.c_str());
|
||||
break;
|
||||
case traze::TickerType::Collision:
|
||||
sound("collision");
|
||||
_messageQueue.message("%s - collision with another player", name.c_str());
|
||||
if (ticker.casualty == (int)_protocol.playerId()) {
|
||||
sound("you_lose");
|
||||
} else if (ticker.fragger == _protocol.playerId()) {
|
||||
sound("you_win");
|
||||
} else {
|
||||
sound("collision");
|
||||
}
|
||||
_messageQueue.message("%s - collision with another player", fraggerName.c_str());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -172,6 +192,7 @@ void TestTraze::onEvent(const traze::SpawnEvent& event) {
|
|||
if (spawn.own) {
|
||||
_spawnPosition = spawn.position;
|
||||
_spawnTime = _now;
|
||||
sound("join");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -283,7 +283,7 @@ void Protocol::parseGridAndUpdateVolume(const std::string& json) {
|
|||
const int height = j["height"].get<int>();
|
||||
const int width = j["width"].get<int>();
|
||||
// x and z and swapped here
|
||||
const voxel::Region region(glm::ivec3(-1), glm::ivec3(height + 1, 1, width + 1));
|
||||
const voxel::Region region(glm::ivec3(-1), glm::ivec3(height, 1, width));
|
||||
voxel::RawVolume* v = new voxel::RawVolume(region);
|
||||
const auto& grid = j["tiles"];
|
||||
int x = 0;
|
||||
|
|
|
@ -20,7 +20,7 @@ private:
|
|||
std::string _instanceName;
|
||||
std::string _playerToken;
|
||||
std::string _clientToken;
|
||||
uint32_t _playerId = 0u;
|
||||
PlayerId _playerId = 0u;
|
||||
struct mosquitto *_mosquitto = nullptr;
|
||||
bool _connected = false;
|
||||
bool _subscribed = false;
|
||||
|
@ -46,6 +46,8 @@ public:
|
|||
|
||||
bool connect();
|
||||
|
||||
PlayerId playerId() const;
|
||||
|
||||
bool joined() const;
|
||||
bool connected() const;
|
||||
|
||||
|
@ -208,6 +210,10 @@ public:
|
|||
bool bail();
|
||||
};
|
||||
|
||||
inline PlayerId Protocol::playerId() const {
|
||||
return _playerId;
|
||||
}
|
||||
|
||||
inline bool Protocol::joined() const {
|
||||
return _playerId != 0u;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue