stuff to test

This commit is contained in:
j3d1 2016-09-28 05:52:23 +02:00
parent 8f41d89a3c
commit 78b9b2436c
3 changed files with 32 additions and 2 deletions

View file

@ -15,12 +15,11 @@ Game::Game()
m_state = new game::State();
m_state->init();
m_state->addPlayer();
}
bool Game::cycle(float dt)
{
#if 1
#if 0
// XXX the following is just testing code to do things
static float total = 0.0;
@ -34,6 +33,7 @@ bool Game::cycle(float dt)
// m_state->players[0]->addCommand(new game::ShootCommand(a));
// }
//}
m_state->addPlayer();
acc += dt;
total += dt;

View file

@ -18,6 +18,8 @@
#include "util.hpp"
using namespace std;
namespace game {
void State::init()
{
@ -76,6 +78,30 @@ namespace game {
void State::quitPlayer(int playerId)
{
(void) playerId;
cout << playerId << " quit" << endl;
}
void State::clear(int playerId)
{
cout << playerId << " clear" << endl;
}
void State::setName(int playerId, std::string name)
{
// discard if not unique
for (const Player *other : players) {
if (name == other->name) {
std::cout << "name '" << name << "' already given to player #" << other->id << std::endl;
return;
}
}
playerForId(playerId)->name = name;
}
void State::setSpeed(int playerId, double speed)
{
playerForId(playerId)->speed = speed;
}
void State::advancePlayerShipSpawns(float dt)

View file

@ -2,6 +2,7 @@
#include <vector>
#include <queue>
#include <string>
#include <iostream>
@ -51,6 +52,9 @@ namespace game {
// The upper layer (network/renderer) calling these three functions
// should keep id's unique and give one (network) input an id.
int addPlayer();
void clear(int playerId);
void setName(int playerId, std::string name);
void setSpeed(int playerId, double speed);
void quitPlayer(int playerId);
void commandForPlayer(int playerId, Command *cmd);