- checking files for potential divide by 0 errors, due to random floating point errors
still have floating point errors
- restarted work on real shading (GLSL stuffs)
+
+12/17/2015:
+===========
+
+ - continued work on player sprite
+ - continued work on GLSL shaders
+ - fixed NPC spawning world location stuff
+ - messed with threads/forks
+ - re-fixed/added indoor environment; fixed indoor background
FOUNTAIN
};
+class World;
+
class Particles{
public:
vec2 loc;
class Structures : public Entity{
public:
- void *inWorld;
- void *inside;
+ World *inWorld;
+ World *inside;
BUILD_SUB bsubtype;
Structures();
~Structures();
- unsigned int spawn(_TYPE, BUILD_SUB, float, float);
+ unsigned int spawn(_TYPE, BUILD_SUB, float, float, World *);
};
class Mob : public Entity{
std::vector<Object *> object;
std::vector<Particles *> particles;
- void addStructure(_TYPE t,BUILD_SUB sub,float x,float y,World *outside,World *inside);
- void addVillage(int bCount, int npcMin, int npcMax,_TYPE t,float x,float y,World *outside,World *inside);
+ void addStructure(_TYPE t,BUILD_SUB sub,float x,float y,World *inside);
+ void addVillage(int bCount, int npcMin, int npcMax,_TYPE t,float x,float y,World *outside);
void addMob(int t,float x,float y);
void addMob(int t,float x,float y,void (*hey)(Mob *));
void addNPC(float x,float y);
*/
#include <cstdio> // fopen
+#include <thread>
#include <common.h>
#include <world.h>
if(!currentTime){ // Initialize currentTime if it hasn't been
currentTime=millis();
- prevPrevTime=currentTime;
+ //prevPrevTime=currentTime;
}
/*
Player::Player(){ //sets all of the player specific traits on object creation
width = HLINE * 10;
- height = HLINE * 16;
+ height = HLINE * 15;
type = PLAYERT; //set type to player
subtype = 0;
* point to have non-normal traits so it could be invisible or invincible...
*/
-unsigned int Structures::spawn(_TYPE t, BUILD_SUB sub, float x, float y){
+unsigned int Structures::spawn(_TYPE t, BUILD_SUB sub, float x, float y, World *oi){
loc.x = x;
loc.y = y;
type = t;
height = 40 * HLINE;
bsubtype = sub;
+ inWorld = oi;
+
/*
* tempN is the amount of entities that will be spawned in the village. Currently the village
* will spawn bewteen 2 and 7 villagers for the starting hut.
* with type NPC.
*/
- currentWorld->addNPC(loc.x + i * HLINE ,100);
+ inWorld->addNPC(loc.x + i * HLINE ,100);
}
static World *worldSpawnHill2;
static World *worldSpawnHill3;
+static IndoorWorld *worldSpawnHill2_Building1;
+
/*
* initEverything() start
*/
worldSpawnHill3->addMob(MS_TRIGGER,-500,0,worldSpawnHill3_itemGet);
worldSpawnHill3->addMob(MS_TRIGGER,0,0,worldSpawnHill3_itemSee);
worldSpawnHill3->addObject(TEST_ITEM,false,"",-200,300);
- worldSpawnHill3->addMob(MS_TRIGGER,400,0,worldSpawnHill3_leave);
+ worldSpawnHill3->addMob(MS_TRIGGER,650,0,worldSpawnHill3_leave);
worldSpawnHill3->addHole(800,1000);
worldSpawnHill1->toRight = worldSpawnHill2;
//playerSpawnHill->addMob(MS_TRIGGER,-1300,0,CUTSCENEEE);*/
- currentWorld = worldSpawnHill1;
- worldSpawnHill2->addStructure(STRUCTURET,HOUSE,(rand()%120*HLINE),100,worldSpawnHill1,worldSpawnHill2);
+ worldSpawnHill2_Building1 = new IndoorWorld();
+ worldSpawnHill2_Building1->generate(300);
+ worldSpawnHill2_Building1->setBackground(BG_WOODHOUSE);
+ worldSpawnHill2_Building1->setBGM("assets/music/theme_jazz.wav");
+
+ worldSpawnHill2->addStructure(STRUCTURET,HOUSE,(rand()%120*HLINE),100,worldSpawnHill2_Building1);
player = new Player();
player->spawn(200,100);
-
+
+ currentWorld = worldSpawnHill1;
currentWorld->bgmPlay(NULL);
-
atexit(destroyEverything);
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); //for the s direction
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); //for the t direction
glBegin(GL_QUADS);
- std::cout<<shade<<std::endl;
for(i=is;i<(unsigned)ie-GEN_INC;i++){
cline[i].y+=(yoff-DRAW_Y_OFFSET); // Add the y offset
if(!cline[i].y){
goto LOOOOP;
}
}
-void World::addStructure(_TYPE t,BUILD_SUB sub, float x,float y,World *outside,World *inside){
+void World::addStructure(_TYPE t,BUILD_SUB sub, float x,float y,World *inside){
build.push_back(new Structures());
- build.back()->spawn(t,sub,x,y);
- build.back()->inWorld=outside;
- build.back()->inside=(void *)inside;
+ build.back()->spawn(t,sub,x,y,this);
+ build.back()->inWorld=this;
+ build.back()->inside = (World *)inside;
+ ((IndoorWorld *)inside)->outside = this;
entity.push_back(build.back());
}
-void World::addVillage(int bCount, int npcMin, int npcMax,_TYPE t,float x,float y,World *outside,World *inside){
+void World::addVillage(int bCount, int npcMin, int npcMax,_TYPE t,float x,float y,World *outside){
std::cout << npcMin << ", " << npcMax << std::endl;
int xwasd;
for(int i = 0; i < bCount; i++){
for(auto &bu : build){
if(xwasd > bu->loc.x && xwasd < bu->loc.x+bu->width)goto HERE;
}
- addStructure(t,HOUSE,xwasd,y,outside,inside);
+ addStructure(t,HOUSE,xwasd,y,outside);
}
}
void World::addMob(int t,float x,float y){
void IndoorWorld::draw(Player *p){
unsigned int i,ie;
- int j,x,v_offset;
+ //int j,x,v_offset;
+ int x;
/*
* Draw the background.
glEnable(GL_TEXTURE_2D);
bgTex->bind(0);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); //for the s direction
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); //for the t direction
glColor4ub(255,255,255,255);
glBegin(GL_QUADS);
- for(j = x_start - SCREEN_WIDTH / 2;j < -x_start + SCREEN_WIDTH / 2; j += 512){
- glTexCoord2i(1,1);glVertex2i(j ,0);
- glTexCoord2i(0,1);glVertex2i(j+512,0);
- glTexCoord2i(0,0);glVertex2i(j+512,512);
- glTexCoord2i(1,0);glVertex2i(j ,512);
- }
+ //for(j = x_start - SCREEN_WIDTH / 2;j < -x_start + SCREEN_WIDTH / 2; j += 512){
+ glTexCoord2i(0,1); glVertex2i( x_start - SCREEN_WIDTH / 2,0);
+ glTexCoord2i((-x_start*2+SCREEN_WIDTH)/512,1);glVertex2i(-x_start + SCREEN_WIDTH / 2,0);
+ glTexCoord2i((-x_start*2+SCREEN_WIDTH)/512,0);glVertex2i(-x_start + SCREEN_WIDTH / 2,SCREEN_HEIGHT);
+ glTexCoord2i(0,0); glVertex2i( x_start - SCREEN_WIDTH / 2,SCREEN_HEIGHT);
+ //}
glEnd();
glDisable(GL_TEXTURE_2D);
* Calculate the starting and ending points to draw the ground from.
*/
- v_offset = (p->loc.x - x_start) / HLINE;
+ /*v_offset = (p->loc.x - x_start) / HLINE;
j = v_offset - (SCREEN_WIDTH / 2 / HLINE) - GEN_INC;
if(j < 0)j = 0;
i = j;
ie = v_offset + (SCREEN_WIDTH / 2 / HLINE) - GEN_INC;
- if(ie > lineCount)ie = lineCount;
+ if(ie > lineCount)ie = lineCount;*/
+
+ i = 0;
+ ie = lineCount;
/*
* Draw the ground.