Permalink
Browse files

texturing & changing naming convention

  • Loading branch information...
1 parent d6afda5 commit 0f95e238d6c774b65ca4fe2b67cd3bb50e2a3121 @Detegr committed Mar 25, 2013
Showing with 83 additions and 76 deletions.
  1. +9 −9 ConnectionManager.cpp
  2. +6 −6 ConnectionManager.h
  3. +13 −13 client.cpp
  4. +1 −1 inputhandler.cpp
  5. +1 −1 inputhandler.h
  6. +3 −3 modelmanager.cpp
  7. +3 −3 modelmanager.h
  8. +3 −3 packetparser.cpp
  9. +1 −1 physicsmanager.cpp
  10. +3 −3 renderer.cpp
  11. +24 −24 server.cpp
  12. +2 −2 shadermanager.cpp
  13. +2 −2 shadermanager.h
  14. +6 −0 singleton.cpp
  15. +1 −0 singleton.h
  16. +3 −3 timer.cpp
  17. +2 −2 timer.h
View
@@ -42,7 +42,7 @@ void C_ConnectionPool::M_Remove(C_Connection* c)
c->m_Prev->m_Next=c->m_Next;
c->m_Next->m_Prev=c->m_Prev;
}
- C_Singleton::M_PhysicsManager()->M_DestroyEntity(c->M_GetEntity());
+ C_Singleton::M_PhysicsManager()->M_DestroyEntity(c->GetEntity());
delete c;
}
@@ -59,7 +59,7 @@ void C_ConnectionPool::M_SendToAll(C_UdpSocket& sock, C_Packet& p) const
{
for(C_Connection* c=m_Head; c; c=c->m_Next)
{
- if(c->M_Pending()) continue;
+ if(c->Pending()) continue;
for(std::list<C_Bullet*>::iterator it=c->m_Bullets.begin(); it!=c->m_Bullets.end(); ++it)
{
@@ -73,9 +73,9 @@ void C_ConnectionPool::M_SendToAll(C_UdpSocket& sock, C_Packet& p) const
*(*it) >> p;
}
- C_Entity* e=c->M_GetEntity();
+ C_Entity* e=c->GetEntity();
b2Body* b=e->M_Body();
- unsigned char keyvec=c->M_GetKeys();
+ unsigned char keyvec=c->GetKeys();
if(keyvec & 0x1)
{
b->SetAngularVelocity(-3.0f);
@@ -87,20 +87,20 @@ void C_ConnectionPool::M_SendToAll(C_UdpSocket& sock, C_Packet& p) const
else b->SetAngularVelocity(0.0f);
if(keyvec & 0x8)
{
- float32 a = c->M_GetEntity()->M_Body()->GetAngle();
+ float32 a = c->GetEntity()->M_Body()->GetAngle();
b2Vec2 force = b2Vec2(-sin(a), cos(a));
force *= 6.0f;
b->ApplyForceToCenter(force);
}
if(keyvec & 0x20)
{
- if(c->m_ShootTimer.M_Get() > .25f)
+ if(c->m_ShootTimer.Get() > .25f)
{
- c->m_ShootTimer.M_Reset();
+ c->m_ShootTimer.Reset();
C_PhysicsManager* pm=C_Singleton::M_PhysicsManager();
C_ModelManager* m=C_Singleton::M_ModelManager();
- C_Bullet* b=pm->M_CreateBullet(m->M_Get("bullet"), 0.05f);
- b2Body* body=c->M_GetEntity()->M_Body();
+ C_Bullet* b=pm->M_CreateBullet(m->Get("bullet"), 0.05f);
+ b2Body* body=c->GetEntity()->M_Body();
b2Vec2 pos=body->GetPosition();
float angle=body->GetAngle();
float speed=20.0f;
View
@@ -22,12 +22,12 @@ class C_Connection
ushort m_Port;
C_Connection(const C_IpAddress& ip, ushort port) :
m_Next(NULL), m_Prev(NULL), m_Entity(NULL), m_KeyVec(0), m_Pending(true), m_Ip(ip), m_Port(port) {}
- void M_SetEntity(C_Entity* e) {m_Entity=e;}
- C_Entity* M_GetEntity() const { return m_Entity; }
- void M_SetKeys(unsigned char keyvec) { m_KeyVec=keyvec; }
- unsigned char M_GetKeys() const { return m_KeyVec; }
- void M_Pending(bool p) {m_Pending=p;}
- bool M_Pending() const {return m_Pending;}
+ void SetEntity(C_Entity* e) {m_Entity=e;}
+ C_Entity* GetEntity() const { return m_Entity; }
+ void SetKeys(unsigned char keyvec) { m_KeyVec=keyvec; }
+ unsigned char GetKeys() const { return m_KeyVec; }
+ void Pending(bool p) {m_Pending=p;}
+ bool Pending() const {return m_Pending;}
};
class C_ConnectionPool
View
@@ -49,11 +49,11 @@ unsigned char getkeys()
{
unsigned char keyvec=0x10;
C_InputHandler* i = C_Singleton::M_InputHandler();
- if(i->M_Get(Key::SPACE)) keyvec|=0x20;
- if(i->M_Get(Key::UP)) keyvec |= 0x8;
- else if(i->M_Get(Key::DOWN)) keyvec |=0x4;
- if(i->M_Get(Key::LEFT)) keyvec |= 0x2;
- else if(i->M_Get(Key::RIGHT)) keyvec |= 0x1;
+ if(i->Get(Key::SPACE)) keyvec|=0x20;
+ if(i->Get(Key::UP)) keyvec |= 0x8;
+ else if(i->Get(Key::DOWN)) keyvec |=0x4;
+ if(i->Get(Key::LEFT)) keyvec |= 0x2;
+ else if(i->Get(Key::RIGHT)) keyvec |= 0x1;
return keyvec;
}
@@ -76,22 +76,22 @@ int main()
C_Renderer* r = C_Singleton::M_Renderer();
C_ShaderManager* s = C_Singleton::M_ShaderManager();
- s->M_Load("minimal");
- s->M_Load("green");
- r->UseShader(s->M_Get("minimal"));
+ s->Load("minimal");
+ s->Load("green");
+ //r->UseShader(s->Get("minimal"));
bool running=true;
p.M_Clear();
unsigned char keyvec=0;
unsigned char prevkeyvec=0;
C_Timer idt;
- idt.M_Reset();
+ idt.Reset();
while(running)
{
if(sock.M_Receive(p, 0, NULL, NULL))
{
- idt.M_Reset();
+ idt.Reset();
C_Packet keys;
keyvec=getkeys();
if(prevkeyvec != 0xF0)
@@ -107,15 +107,15 @@ int main()
const std::vector<C_GfxEntity*>& entities = r->Entities();
for(std::vector<C_GfxEntity*>::const_iterator it=entities.begin(); it!=entities.end(); ++it)
{
- (*it)->M_ExtrapolatePosition(idt.M_Get());
- (*it)->M_ExtrapolateRotation(idt.M_Get());
+ (*it)->M_ExtrapolatePosition(idt.Get());
+ (*it)->M_ExtrapolateRotation(idt.Get());
}
}
g_Sleep(1);
p.M_Clear();
r->Draw();
- running=!(C_Singleton::M_InputHandler()->M_Get(ESC));
+ running=!(C_Singleton::M_InputHandler()->Get(ESC));
}
p.M_Clear();
p << (unsigned char)NET::Disconnect;
View
@@ -19,7 +19,7 @@ void C_InputHandler::M_HandleKey(int key, int state)
if(k!=-1) m_KeysDown[k]=state==GLFW_PRESS?true:false;
}
-bool C_InputHandler::M_Get(Key k)
+bool C_InputHandler::Get(Key k)
{
return m_KeysDown[k];
}
View
@@ -20,6 +20,6 @@ class C_InputHandler
static unsigned char m_KeysDown[12];
public:
- static bool M_Get(Key k);
+ static bool Get(Key k);
};
View
@@ -14,7 +14,7 @@ C_ModelManager::~C_ModelManager()
std::cout << "OK!" << std::endl;
}
-bool C_ModelManager::M_Load(const std::string& name, const std::string& path)
+bool C_ModelManager::Load(const std::string& name, const std::string& path)
{
std::vector<std::string> f=C_FileReader::M_ReadToArray(path);
if(!f.size())
@@ -55,14 +55,14 @@ bool C_ModelManager::M_Load(const std::string& name, const std::string& path)
return true;
}
-const C_Model* C_ModelManager::M_Create(const std::string& name, const std::vector<float>& verts, float width, float height)
+const C_Model* C_ModelManager::Create(const std::string& name, const std::vector<float>& verts, float width, float height)
{
C_Model* newmodel=new C_Model(name,verts,width,height);
m_Models.push_back(newmodel);
return newmodel;
}
-const C_Model& C_ModelManager::M_Get(const std::string& name) const
+const C_Model& C_ModelManager::Get(const std::string& name) const
{
for(std::vector<C_Model*>::const_iterator it=m_Models.begin(); it!=m_Models.end(); ++it)
{
View
@@ -13,7 +13,7 @@ class C_ModelManager
~C_ModelManager();
std::vector<C_Model*> m_Models;
public:
- bool M_Load(const std::string& name, const std::string& path);
- const C_Model& M_Get(const std::string& model) const;
- const C_Model* M_Create(const std::string& name, const std::vector<float>& verts, float width, float height);
+ bool Load(const std::string& name, const std::string& path);
+ const C_Model& Get(const std::string& model) const;
+ const C_Model* Create(const std::string& name, const std::vector<float>& verts, float width, float height);
};
View
@@ -75,11 +75,11 @@ void C_PacketParser::M_GfxEntity(C_Packet& p, bool full)
C_GfxEntity* e;
if(name == "triangle")
{
- e=C_GfxEntity::M_Create(id, C_Singleton::M_ModelManager()->M_Get(name), "ulle.tga", scale);
+ e=C_GfxEntity::M_Create(id, C_Singleton::M_ModelManager()->Get(name), "ulle.tga", scale);
}
else
{
- e=C_GfxEntity::M_Create(id, C_Singleton::M_ModelManager()->M_Get(name), scale);
+ e=C_GfxEntity::M_Create(id, C_Singleton::M_ModelManager()->Get(name), scale);
}
e->M_SetPosition(x,y);
e->M_SetRotation(angle);
@@ -107,5 +107,5 @@ void C_PacketParser::M_Model(C_Packet& p)
p >> w;
p >> h;
- C_Singleton::M_ModelManager()->M_Create(name, verts, w, h);
+ C_Singleton::M_ModelManager()->Create(name, verts, w, h);
}
View
@@ -37,7 +37,7 @@ C_Entity* C_PhysicsManager::M_CreateStaticEntity(const C_Model& m, float scale)
void C_PhysicsManager::M_Simulate()
{
- double dt=C_Singleton::M_Timer()->M_Get()/0.030;
+ double dt=C_Singleton::M_Timer()->Get()/0.030;
m_World.Step(m_TimeStep*dt, m_VelocityIterations, m_PositionIterations);
}
View
@@ -31,7 +31,7 @@ C_Renderer::C_Renderer(unsigned width, unsigned height) :
glfwTerminate();
throw std::runtime_error("OpenGL 3.3 is not supported.");
}
- glClearColor(0.0f, 0.0f, 0.2f, 0.0f);
+ glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glGenVertexArrays(1,&m_VertexArray);
glBindVertexArray(m_VertexArray);
@@ -60,8 +60,8 @@ void C_Renderer::Draw()
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
for(std::vector<C_GfxEntity*>::iterator it=m_Entities.begin(); it!=m_Entities.end(); ++it)
{
- if((*it)->M_ModelName() == "triangle" || (*it)->M_ModelName() == "bullet") UseShader(C_Singleton::M_ShaderManager()->M_Get("green"));
- else UseShader(C_Singleton::M_ShaderManager()->M_Get("minimal"));
+ if((*it)->M_ModelName() == "triangle" || (*it)->M_ModelName() == "bullet") UseShader(C_Singleton::M_ShaderManager()->Get("green"));
+ else UseShader(C_Singleton::M_ShaderManager()->Get("minimal"));
if((*it)->IsPlayer())
{
SetView((*it)->GetPosition());
View
@@ -37,16 +37,16 @@ int main()
C_Timer* t = C_Singleton::M_Timer();
C_ModelManager* m = C_Singleton::M_ModelManager();
- if(!m->M_Load("triangle", "test.2dmodel")) exit(1);
- if(!m->M_Load("horizwall", "horizwall.2dmodel")) exit(1);
- if(!m->M_Load("vertwall", "vertwall.2dmodel")) exit(1);
- if(!m->M_Load("box", "box.2dmodel")) exit(1);
- if(!m->M_Load("bullet", "bullet.2dmodel")) exit(1);
+ if(!m->Load("triangle", "test.2dmodel")) exit(1);
+ if(!m->Load("horizwall", "horizwall.2dmodel")) exit(1);
+ if(!m->Load("vertwall", "vertwall.2dmodel")) exit(1);
+ if(!m->Load("box", "box.2dmodel")) exit(1);
+ if(!m->Load("bullet", "bullet.2dmodel")) exit(1);
- C_Entity* top=p->M_CreateStaticEntity(m->M_Get("horizwall"), 2.0f);
- C_Entity* bottom=p->M_CreateStaticEntity(m->M_Get("horizwall"), 2.0f);
- C_Entity* left=p->M_CreateStaticEntity(m->M_Get("vertwall"), 2.0f);
- C_Entity* right=p->M_CreateStaticEntity(m->M_Get("vertwall"), 2.0f);
+ C_Entity* top=p->M_CreateStaticEntity(m->Get("horizwall"), 2.0f);
+ C_Entity* bottom=p->M_CreateStaticEntity(m->Get("horizwall"), 2.0f);
+ C_Entity* left=p->M_CreateStaticEntity(m->Get("vertwall"), 2.0f);
+ C_Entity* right=p->M_CreateStaticEntity(m->Get("vertwall"), 2.0f);
std::vector<C_Entity*> boxes;
std::vector<C_Entity*> players;
@@ -59,7 +59,7 @@ int main()
{
x=-1.0f;
for(int i=0; i<4; ++i) {
- C_Entity* b=p->M_CreateDynamicEntity(m->M_Get("box"), size);
+ C_Entity* b=p->M_CreateDynamicEntity(m->Get("box"), size);
b->M_SetPosition(x, y);
x+=0.15f;
boxes.push_back(b);
@@ -79,19 +79,19 @@ int main()
while(run)
{
- t->M_Reset();
+ t->Reset();
while(sock.M_Receive(packet, 1, &ip, &port))
{
C_Connection* c = pool.M_Exists(ip,port);
if(c)
{
unsigned char header=0;
packet >> header;
- if(c->M_Pending())
+ if(c->Pending())
{
if(header == NET::Connect)
{
- c->M_Pending(false);
+ c->Pending(false);
}
}
else
@@ -101,33 +101,33 @@ int main()
packet.M_Clear();
for(std::vector<C_Entity*>::iterator it=players.begin(); it!=players.end(); ++it)
{
- if((*it) == c->M_GetEntity())
+ if((*it) == c->GetEntity())
{
players.erase(it);
break;
}
}
- packet << (unsigned char)NET::EntityDeleted << c->M_GetEntity()->M_Id();
+ packet << (unsigned char)NET::EntityDeleted << c->GetEntity()->M_Id();
pool.M_Remove(c);
}
else if(header & 0x10)
{
- c->M_SetKeys(header);
+ c->SetKeys(header);
}
}
}
else
{
packet.M_Clear();
c=pool.M_Add(new C_Connection(ip,port));
- C_Entity* e=p->M_CreateDynamicEntity(m->M_Get("triangle"), 0.08f);
+ C_Entity* e=p->M_CreateDynamicEntity(m->Get("triangle"), 0.08f);
e->M_SetPosition(0,0);
- c->M_SetEntity(e);
- m->M_Get("triangle") >> packet;
- m->M_Get("horizwall") >> packet;
- m->M_Get("vertwall") >> packet;
- m->M_Get("box") >> packet;
- m->M_Get("bullet") >> packet;
+ c->SetEntity(e);
+ m->Get("triangle") >> packet;
+ m->Get("horizwall") >> packet;
+ m->Get("vertwall") >> packet;
+ m->Get("box") >> packet;
+ m->Get("bullet") >> packet;
top->M_DumpFullInstance(packet);
bottom->M_DumpFullInstance(packet);
@@ -164,7 +164,7 @@ int main()
newplayers.M_Clear();
}
packet.M_Clear();
- g_Sleep(30-((int)t->M_Get()*1000));
+ g_Sleep(30-((int)t->Get()*1000));
p->M_Simulate();
}
C_Singleton::M_DestroySingletons();
View
@@ -23,7 +23,7 @@ bool C_ShaderManager::M_CheckResult(GLuint id, GLuint status)
return true;
}
-bool C_ShaderManager::M_Load(const std::string& name)
+bool C_ShaderManager::Load(const std::string& name)
{
GLuint vertid = glCreateShader(GL_VERTEX_SHADER);
GLuint fragid = glCreateShader(GL_FRAGMENT_SHADER);
@@ -59,7 +59,7 @@ bool C_ShaderManager::M_Load(const std::string& name)
return true;
}
-const C_Shader& C_ShaderManager::M_Get(const std::string& name) const
+const C_Shader& C_ShaderManager::Get(const std::string& name) const
{
for(std::vector<C_Shader>::const_iterator it=m_Shaders.begin(); it!=m_Shaders.end(); ++it)
{
View
@@ -40,6 +40,6 @@ class C_ShaderManager
std::vector<C_Shader> m_Shaders;
bool M_CheckResult(GLuint id, GLuint status);
public:
- bool M_Load(const std::string& name);
- const C_Shader& M_Get(const std::string& name) const;
+ bool Load(const std::string& name);
+ const C_Shader& Get(const std::string& name) const;
};
View
@@ -11,6 +11,12 @@ C_Renderer* C_Singleton::M_Renderer()
if(!m_Renderer) m_Renderer = new C_Renderer(PWSKOAG_WINDOW_WIDTH, PWSKOAG_WINDOW_HEIGHT);
return m_Renderer;
}
+C_Renderer* C_Singleton::M_Renderer(unsigned int w, unsigned int h)
+{
+ if(!m_Renderer) m_Renderer = new C_Renderer(w,h);
+ return m_Renderer;
+}
+
C_InputHandler* C_Singleton::M_InputHandler()
{
if(!m_InputHandler) m_InputHandler = new C_InputHandler;
Oops, something went wrong.

0 comments on commit 0f95e23

Please sign in to comment.