Revert "adding camera to 3d render. angles not yet working."

This reverts commit 602d0bb342.
This commit is contained in:
end 2016-10-04 19:12:04 +02:00
parent 8dd2f2b292
commit 1fff1fbce2
12 changed files with 29 additions and 197 deletions

View file

@ -39,56 +39,12 @@ namespace game {
m_defaultEnergy = 10.0;
m_maxNumTraces = 10;
//setPlayingFieldCenter(0, 0);
setPlayingFieldCenter(0, 0);
// TODO: need aspect ratio or data!
//setPlayingFieldSize(1000, 300);
(void) numPlanets;
//setupPlanets(numPlanets);
setupTestPlanets();
m_needReInit = false;
}
void State::setupTestPlanets()
{
// XXX simple setup for testing
// TODO: spawn hmmm.m....
//float aspectRatio = 1.0;
float aspectRatio = m_playingFieldSize.x / m_playingFieldSize.y;
(void) aspectRatio;
float smallRadius = 0.05;
float sunRadius = 0.2;
int n = 10.0;
float nf = n-1;
std::cout<<"spawing planets..." << std::endl;
// distribute planets in an area equal width the same aspect ratio as the screen
planets.push_back(new Planet(generateId(), glm::vec2(0.0, 0.0), sunRadius, Planet::Material::Sun));
for (int y=0; y<2; y++) {
for (int x=0; x<n; x++) {
glm::vec2 pos = glm::vec2(x/nf, y);
pos = 2.0f*pos - 1.0f;
//pos.x /= aspectRatio;
planets.push_back(new Planet(generateId(), pos, smallRadius));
}
}
for (int x=0; x<2; x++) {
for (int y=0; y<n; y++) {
glm::vec2 pos = glm::vec2(x, y/nf);
pos = 2.0f*pos - 1.0f;
//pos.x /= aspectRatio;
planets.push_back(new Planet(generateId(), pos, smallRadius));
}
}
std::cout<<"planets spawned..." << std::endl;
setupPlanets(numPlanets);
}
bool State::findPlanetSpawnPosition(bool planetIsSun, float radius, glm::vec2 *pos)
@ -143,6 +99,7 @@ namespace game {
if (radius > 0.9) {
radius = 0.9;
}
}
glm::vec2 pos;
@ -396,11 +353,7 @@ namespace game {
void State::advance(float dt)
{
if (m_needReInit) {
m_needReInit = false;
std::cout<<"[state] need initialization of game, restarting." << std::endl;
init();
}
//std::cout<<"[state] (init) cycle: update events length is " << m_nextEvents.size() << std::endl;
m_time += dt;
@ -414,11 +367,19 @@ namespace game {
advancePlayerMissiles(dt);
//std::cout<<"[state] (before move) cycle: update events length is " << m_nextEvents.size() << std::endl;
// put collected events into that list.
//m_allEvents.push_back(std::move(m_nextEvents));
for (auto *evt : m_nextEvents) {
m_allEvents.push_back(evt);
}
m_nextEvents.clear();
//std::cout<<"[state] (after move) cycle: update events length is " << m_nextEvents.size() << std::endl;
// finally remove things.
//m_nextEvents.clear();
}
Player *State::playerForId(size_t playerId)
@ -546,13 +507,11 @@ namespace game {
void State::setPlayingFieldCenter(int center_x, int center_y)
{
m_playingFieldCenter = glm::vec2((float) center_x, (float) center_y);
m_needReInit = true;
}
void State::setPlayingFieldSize(int width, int height)
{
m_playingFieldSize = glm::vec2(width, height);
m_needReInit = true;
}
size_t State::generateId()

View file

@ -157,8 +157,6 @@ namespace game {
void addExplosionFromHit(const Missile::Event *evt);
bool findPlanetSpawnPosition(bool planetIsSun, float radius, glm::vec2 *pos);
void setupTestPlanets();
void advanceTraceAges(float dt);
void advanceExplosions(float dt);
void advancePlayerShipSpawns(float dt);
@ -183,7 +181,6 @@ namespace game {
IdGenerator m_ids;
float m_time;
bool m_developerMode;
bool m_needReInit;
glm::vec2 m_playingFieldCenter;
glm::vec2 m_playingFieldSize;