ignore the sound for now. event mechanism is working good with renderer.

This commit is contained in:
Andreas Ortmann 2016-10-03 18:56:49 +02:00
parent 550556e0e4
commit 5e8a04c54f
4 changed files with 151 additions and 10 deletions

View file

@ -19,6 +19,8 @@ set(GAME_SRC
network/session.cpp network/session.cpp
sound/sound_effects.cpp
util.cpp util.cpp
game.cpp game.cpp
@ -36,10 +38,9 @@ set(GAME_SRC
set(SOUND_LIBRARIES "") set(SOUND_LIBRARIES "")
# TODO: make optional! # TODO: make optional!
set(GAME_SRC ${GAME_SRC} sound/sound.cpp sound/sound_effects.cpp) #set(GAME_SRC ${GAME_SRC} sound/sound.cpp)
#set(SOUND_LIBRARIES -lportaudio -lsndfile)
set(SOUND_LIBRARIES -lportaudio -lsndfile) set(GAME_SRC ${GAME_SRC} sound/dummy_sound.cpp)
#set(GAME_SRC "${GAME_SRC} sound/dummy_sound.cpp sound/dummy_sound_effects.cpp")
include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR})

130
game/sound/dummy_sound.cpp Normal file
View file

@ -0,0 +1,130 @@
#include "sound.hpp"
namespace sound {
bool initSound(void)
{
return false;
}
void deleteOldSounds()
{
}
SoundHandle *playSound(enum Sound type, float amplitude)
{
(void) type;
(void) amplitude;
return NULL;
}
SoundHandle *playFrequency(float freq, float amplitude)
{
(void) freq;
(void) amplitude;
return NULL;
}
bool configureEnvelope(SoundHandle *handle, float rise, float hold, float decay)
{
(void) handle;
(void) rise;
(void) hold;
(void) decay;
return false;
}
bool configureOvershoot(SoundHandle *handle, float relativeOvershootTime)
{
(void) handle;
(void) relativeOvershootTime;
return false;
}
bool configureEnvelopeWait(SoundHandle *handle, float rise, float hold, float decay, float wait)
{
(void) handle;
(void) rise;
(void) hold;
(void) decay;
(void) wait;
return false;
}
bool configureEnvelopeLooping(SoundHandle *handle, float rise, float hold, float decay, float wait)
{
(void) handle;
(void) rise;
(void) hold;
(void) decay;
(void) wait;
return false;
}
float getRiseDuration(SoundHandle *handle)
{
(void) handle;
return 0.0f;
}
float getHoldDuration(SoundHandle *handle)
{
(void) handle;
return 0.0f;
}
float getDecayDuration(SoundHandle *handle)
{
(void) handle;
return 0.0f;
}
float getWaitTime(SoundHandle *handle)
{
(void) handle;
return 0.0f;
}
void configureWaitTime(SoundHandle *handle, float waitTime)
{
(void) handle;
(void) waitTime;
}
void setLoopCount(SoundHandle *handle, int numRepetitions)
{
(void) handle;
(void) numRepetitions;
}
bool stopSound(SoundHandle *handle)
{
(void) handle;
return true;
}
void stopAllSounds(void)
{
}
void teardownSound(void)
{
}
bool startDumpingWav(const char *filename)
{
(void) filename;
return false;
}
void stopDumpingWav(void)
{
}
int numActiveSounds(void)
{
}
void deleteSound(SoundHandle *handle)
{
(void) handle;
}
}

View file

@ -528,8 +528,8 @@ namespace game {
case EventType::Explosion: case EventType::Explosion:
{ {
ExplosionEvent *ee = static_cast<ExplosionEvent*>(evt); ExplosionEvent *ee = static_cast<ExplosionEvent*>(evt);
std::cout<<"got explosion delete event, finally deleting explosion #" //std::cout<<"got explosion delete event, finally deleting explosion #"
<< ee->object()->id << std::endl; // << ee->object()->id << std::endl;
delete(ee->object()); delete(ee->object());
} }
@ -538,8 +538,8 @@ namespace game {
case EventType::Missile: case EventType::Missile:
{ {
auto *me = static_cast<MissileEvent*>(evt); auto *me = static_cast<MissileEvent*>(evt);
std::cout<<"got missile delete event, finally deleting missile #" //std::cout<<"got missile delete event, finally deleting missile #"
<< me->object()->id << std::endl; // << me->object()->id << std::endl;
delete(me->object()); delete(me->object());
} }

View file

@ -3,13 +3,23 @@ import os
import random import random
import time import time
import socket import socket
import sys
delay = 0.1
if len(sys.argv) <= 1:
print("usage: ./prog $NUM_SHOOTS [$FLOAT_DELAY_BETWEEN_SHOTS]")
exit(1)
if len(sys.argv) > 2:
delay = float(sys.argv[2])
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("192.168.0.191", 3490)) s.connect(("192.168.0.191", 3490))
for i in range(100): for i in range(int(sys.argv[1])):
a = random.randint(0, 360) a = random.randint(0, 360)
msg = str(a) + " \r\n" msg = str(a) + " \r\n"
s.send(msg.encode()) s.send(msg.encode())
time.sleep(0.1) time.sleep(delay)