\r
#include <common.h>\r
\r
+#define MAX_ENTITIES 8\r
+\r
#define goWorldLeft(w) if(w->toLeft){w=w->toLeft;}\r
#define goWorldRight(w) if(w->toRight){w=w->toRight;}\r
\r
double start; // Where to change to dirt, going down (y)\r
} __attribute__ ((packed)) *line;\r
unsigned int lineCount;\r
+ unsigned int entCount;\r
+ void *entity[MAX_ENTITIES];\r
public:\r
World *behind,*infront;\r
World *toLeft,*toRight;\r
void saveToFile(FILE *f,World *parent);\r
void loadFromFile(FILE *f,World *parent);\r
void addLayer(const float width);\r
+ void addEntity(void *e);\r
};\r
\r
#endif // WORLD_H
#include <common.h>
-class Entities{
+class Entity{
public:
float width;
float height;
bool right,left;
void spawn(float, float);
+ void draw(void);
};
-class Player : public Entities{
+class Player : public Entity{
public:
Player();
~Player();
};
-class NPC : public Entities{
+class NPC : public Entity{
public:
NPC();
};
\r
World::World(void){\r
line=NULL;\r
- lineCount=0;\r
+ lineCount=entCount=0;\r
toLeft=toRight=behind=infront=NULL;\r
}\r
World::World(const float width,World *l,World *r){\r
toLeft=l;\r
toRight=r;\r
behind=infront=NULL;\r
+ entCount=0;\r
if(toLeft){\r
if(toLeft->toRight){\r
std::cout<<"There's already a world to the left!"<<std::endl;\r
goto LOOP2;\r
}else{\r
drawOffsetX=drawOffsetY=0;\r
+ for(i=0;i<entCount;i++){\r
+ ((Entity **)entity)[i]->draw();\r
+ }\r
}\r
}\r
void World::detect(vec2 *v,const float width){\r
behind->infront=this;\r
}\r
}\r
+void World::addEntity(void *e){\r
+ entity[entCount++]=e;\r
+}\r
#include <entities.h>
-void Entities::spawn(float x, float y){
+void Entity::spawn(float x, float y){
loc.x = x;
loc.y = y;
vel.x = 0;
right = false;
left = false;
}
+void Entity::draw(void){
+ glColor3ub(0,0,100);
+ glRectf(loc.x,loc.y,loc.x+width,loc.y+height);
+}
Player::Player(){
width = HLINE * 8;
currentTime = 0,
deltaTime = 0;
-Entities *entPlay; //The player base
-Entities *entnpc; //The NPC base
+Entity *entPlay; //The player base
+Entity *entnpc; //The NPC base
Player player; //The actual player object
NPC npc;
UIClass ui; //Yep
entPlay->spawn(0, 0);
entnpc = &npc;
npc.type = -1; //this will make the NPC spawn the start of a village
- entnpc->spawn( (grand()%20)-10 ,0); //this will spawn the start of a village
+ entnpc->spawn(.5,0);// (grand()%20)-10 ,0); //this will spawn the start of a village
// Generate the world
World *w=NULL,*w2=NULL;
currentWorld=w;
currentWorld->addLayer(3);
+ currentWorld->addEntity((void *)entnpc);
//currentWorld->addLayer();
// Save the world if necessary
fread(&fSave,sizeof(unsigned int),1,f);
fclose(f);
}*/
-
+
float gw;
while(gameRunning){
glRectf(player.loc.x, player.loc.y, player.loc.x + player.width, player.loc.y + player.height);
///TEMP NPC RENDER!!!!!!
- glColor3ub(98, 78, 44); //render the NPC(s)
+ /*glColor3ub(98, 78, 44); //render the NPC(s)
glRectf(npc.loc.x, npc.loc.y, npc.loc.x + .25, npc.loc.y + .25);
glColor3ub(83, 49, 24);
glBegin(GL_TRIANGLES);
glVertex2f(npc.loc.x, npc.loc.y + .25);
glVertex2f(npc.loc.x + .25, npc.loc.y + .25);
glVertex2f(npc.loc.x + .125, npc.loc.y + .35);
- glEnd();
+ glEnd();*/
///BWAHHHHHHHHHHHH
/**************************