};
enum BUILD_SUB{
- TOWN_HALL = 1,
- HOUSE,
- HOUSE2,
- HOUSE3,
- HOUSE4,
- FOUNTAIN
+ TOWN_HALL = 0,
+ HOUSE = 1,
+ HOUSE2 = 2,
+ HOUSE3 = 3,
+ HOUSE4 = 4,
+ FOUNTAIN = 5,
+ LAMP_POST = 6
};
typedef struct {
Structures();
~Structures();
- unsigned int spawn(_TYPE, BUILD_SUB, float, float, World *);
+ unsigned int spawn(BUILD_SUB, float, float, World *);
char *save(void);
void load(char *s);
std::vector<Particles *> particles;
std::vector<Light > light;
- void addStructure(_TYPE t,BUILD_SUB sub,float x,float y,World *inside);
- void addVillage(int bCount, int npcMin, int npcMax,_TYPE t,World *inside);
+ void addStructure(BUILD_SUB sub,float x,float y,World *inside);
+ void addVillage(int bCount, int npcMin, int npcMax,World *inside);
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);
extern const char *itemName;
+std::string sTexLoc[] = { "assets/townhall.png",
+ "assets/house1.png",
+ "assets/house2.png",
+ "assets/house1.png",
+ "assets/house1.png",
+ "assets/fountain1.png",
+ "assets/lampPost1.png"};
+
void getRandomName(Entity *e){
unsigned int tempNum,max=0;
char *bufs;
alive = false;
near = false;
- tex = new Texturec(3,"assets/house1.png", "assets/house2.png", "assets/fountain1.png");
- ntex = new Texturec(1, "assets/house1N.png");
-
inWorld = NULL;
name = NULL;
case MS_DOOR:
case MS_PAGE:
default:
- glActiveTexture(GL_TEXTURE0 + 0);
+ glActiveTexture(GL_TEXTURE0);
tex->bind(0);
break;
}
case STRUCTURET:
for(auto &strt : currentWorld->build){
if(this == strt){
- if(strt->bsubtype == HOUSE){
- glActiveTexture(GL_TEXTURE1);
- ntex->bind(0);
- //When rendering an objectwith this program.
- glActiveTexture(GL_TEXTURE0 + 0);
- tex->bind(0);
- //glBindSampler(0, linearFiltering);
-
-
- }else if(strt->bsubtype == HOUSE2){
- glActiveTexture(GL_TEXTURE0 + 0);
- tex->bind(1);
- }else if(strt->bsubtype == FOUNTAIN){
- glActiveTexture(GL_TEXTURE0 + 0);
- tex->bind(2);
+ switch(strt->bsubtype){
+ /*case HOUSE:
+ glActiveTexture(GL_TEXTURE1);
+ ntex->bind(0);
+ //When rendering an objectwith this program.
+ glActiveTexture(GL_TEXTURE0);
+ tex->bind(0);
+ //glBindSampler(0, linearFiltering);
+ break;*/
+ default:
+ glActiveTexture(GL_TEXTURE0);
+ tex->bind(0);
+ break;
}
}
}
break;
default:
- glActiveTexture(GL_TEXTURE0 + 0);
+ glActiveTexture(GL_TEXTURE0);
tex->bind(0);
break;
}
* 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, World *oi){
+unsigned int Structures::spawn(BUILD_SUB sub, float x, float y, World *oi){
loc.x = x;
loc.y = y;
- type = t;
-
+ type = STRUCTURET;
+
alive = true;
- width = 50 * HLINE;
- height = 40 * HLINE;
bsubtype = sub;
+ int s = -1;
+ s = 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.
*/
-
+ /* tex = new Texturec(7,"assets/townhall.png",
+ "assets/house1.png",
+ "assets/house2.png",
+ "assets/house1.png",
+ "assets/house1.png",
+ "assets/fountain1.png",
+ "assets/lampPost1.png")*/;
+
unsigned int tempN = (getRand() % 5 + 2);
-
- for(unsigned int i = 0;i < tempN;i++){
-
- /*
- * This is where the entities actually spawn. A new entity is created
- * with type NPC.
- */
-
- inWorld->addNPC(loc.x + i * HLINE ,100);
-
+ switch(s){
+ case HOUSE:
+ tex = new Texturec(1, sTexLoc[s].c_str());
+ width = 50 * HLINE;
+ height = 40 * HLINE;
+ for(unsigned int i = 0;i < tempN;i++){
+
+ /*
+ * This is where the entities actually spawn. A new entity is created
+ * with type NPC.
+ */
+
+ oi->addNPC(loc.x + i * HLINE ,100);
+
+ }
+ break;
+ case FOUNTAIN:
+ tex = new Texturec(1, sTexLoc[s].c_str());
+ width = 50 * HLINE;
+ height = 40 * HLINE;
+ break;
+ case LAMP_POST:
+ tex = new Texturec(1, sTexLoc[s].c_str());
+ width = 10 * HLINE;
+ height = 40 * HLINE;
+ oi->addLight({x+SCREEN_WIDTH/2,y+30*HLINE},{1.0f,1.0f,1.0f});
+ break;
+ default:
+ break;
}
-
return 0;
}
case SDLK_f:
currentWorld->addLight({player->loc.x + SCREEN_WIDTH/2, player->loc.y},{1.0f,1.0f,1.0f});
break;
+ case SDLK_g:
+ currentWorld->addStructure(LAMP_POST, player->loc.x, player->loc.y, currentWorld);
+ break;
default:
break;
}
goto LOOOOP;
}
}
-void World::addStructure(_TYPE t,BUILD_SUB sub, float x,float y,World *inside){
+void World::addStructure(BUILD_SUB sub, float x,float y,World *inside){
build.push_back(new Structures());
- build.back()->spawn(t,sub,x,y,this);
+ build.back()->spawn(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,World *inside){
+void World::addVillage(int bCount, int npcMin, int npcMax,World *inside){
std::cout << npcMin << ", " << npcMax << std::endl;
//int xwasd;
for(int i = 0; i < bCount; i++){
- addStructure(t,HOUSE,x_start + (i * 300),100,inside);
+ addStructure(HOUSE,x_start + (i * 300),100,inside);
/*std::cout<<"1\n";
HERE:
xwasd = (rand()%(int)x+1000*HLINE);
-#version 130\r
+#version 120\r
uniform sampler2D sampler;\r
\r
uniform int numLight;\r
-uniform vec2 lightLocation[255];\r
+uniform vec2 lightLocation[1024];\r
uniform vec3 lightColor;\r
uniform float amb;\r
\r
+float b = .0005;\r
+float minLight = .05;\r
+float radius = sqrt(1.0 / (b * minLight));\r
+\r
void main(){\r
vec4 color = vec4(0.0f,0.0f,0.0f,0.0f);\r
for(int i = 0; i < numLight; i++){\r
vec2 loc = lightLocation[i];\r
float dist = length(loc - gl_FragCoord.xy);\r
- float attenuation=1.0/(1.0+0.01*dist+0.00000000001*dist*dist);\r
+ //float attenuation=1.0/(1.0+0.01*dist+0.00000000001*dist*dist);\r
+ float attenuation = clamp(1.0 - dist*dist/(radius*radius), 0.0, 1.0); attenuation *= attenuation;\r
\r
color += vec4(attenuation, attenuation, attenuation, 1.0f) * vec4(lightColor, 1.0f);\r
}\r
\r
color += vec4(amb,amb,amb,1.0f+amb);\r
gl_FragColor = tex * vec4(color)*tex.a;\r
-}
\ No newline at end of file
+}\r
+\r
+/*b values\r
+ .002 10\r
+ .008 50\r
+ .0005 200\r
+ .00008 500\r
+ .00002 1000\r
+ .00005 2000\r
+*/
\ No newline at end of file
<npc name="Ralph" hasDialog="true" />
<npc name="Johnny" hasDialog="true" />
+ <structure type="6"/>
</World>