-LIBS = -lGL -lGLEW -lSDL2main -lSDL2 -lfreetype -lSDL2_image -lSDL2_mixer\r
+LIBS = -lGL -lGLEW -lSDL2 -lfreetype -lSDL2_image -lSDL2_mixer\r
\r
WIN_LIBS = -lopengl32 -lglew32 -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer -lfreetype\r
\r
-FLAGS = -m32 -std=c++11 -Iinclude -Iinclude/freetype2\r
+FLAGS = -std=c++11 -Iinclude -Iinclude/freetype2\r
\r
all:\r
@rm -f out/*.o\r
#include <common.h> // For HLINE, vec2, OpenGL utilities, etc.
#include <entities.h>
+#define GEN_INC 10 // Defines at what interval y values should be calculated for the array 'line'.
+ // As explained in World(), the last few lines in the array 'line' are incorrectly calculated
+ // or not calculated at all, so GEN_INC is also used to decrease 'lineCount' in functions like draw()
+ // and detect().
+
struct line_t {
bool gs;
float y,gh[2];
*/
virtual void generate(unsigned int width);
- void generateFunc(unsigned int width,unsigned int (*func)(unsigned int));
+ void generateFunc(unsigned int width,float(*func)(float));
/*
* Looks for the furthest back layer in this world and adds a new layer of width `width` behind it.
-LIBS = -lGL -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer -lfreetype
+LIBS = -lGL -lSDL2 -lSDL2_image -lSDL2_mixer -lfreetype
-FLAGS = -m32 -std=c++11 -I../include -I../include/freetype2
+FLAGS = -std=c++11 -I../include -I../include/freetype2
OUT = `echo "" $$(ls -c $(wildcard *.cpp)) | sed s/.cpp/.o/g | sed 's/ / ..\/out\//g'`
return 0;
}
+float playerSpawnHillFunc(float x){
+ x=-x;
+ return (float)(pow(2,(x+200)/5) + 80);
+}
void initEverything(void){
unsigned int i;
*/
World *test=new World();
+ World *playerSpawnHill=new World();
/*
* Load the saved world if it exists, otherwise generate a new one.
fread(buf,1,size,worldLoad);
test->load(buf);
}else{*/
- test->generate(SCREEN_WIDTH * 2);
+ test->generate(SCREEN_WIDTH*2);
test->addHole(100,150);
//}
test->addLayer(400);
+ playerSpawnHill->generateFunc(1280,playerSpawnHillFunc);
+ //playerSpawnHill->generate(1920);
+
/*
* Setup the current world, making the player initially spawn in `test`.
*/
- currentWorld=test;
+ currentWorld=playerSpawnHill;
+ playerSpawnHill->toRight=test;
+ test->toLeft=playerSpawnHill;
/*
* Create the player.
*/
player=new Player();
- player->spawn(0,200);
+ player->spawn(-1000,200);
/*
* Create a structure (this will create villagers when spawned).
#define getWidth(w) ((w->lineCount-GEN_INC)*HLINE) // Calculates the width of world 'w'
-#define GEN_INC 10 // Defines at what interval y values should be calculated for the array 'line'.
- // As explained in World(), the last few lines in the array 'line' are incorrectly calculated
- // or not calculated at all, so GEN_INC is also used to decrease 'lineCount' in functions like draw()
- // and detect().
-
#define GEN_MIN 80
#define GEN_MAX 110
#define GEN_INIT 60
x_start=0 - getWidth(this) / 2;
}
-void World::generateFunc(unsigned int width,unsigned int (*func)(unsigned int)){
+void World::generateFunc(unsigned int width,float(*func)(float)){
unsigned int i;
if((lineCount = width) <= 0)
abort();
line=(struct line_t *)calloc(lineCount,sizeof(struct line_t));
for(i=0;i<lineCount;i++){
line[i].y=func(i);
+ if(line[i].y<0)line[i].y=0;
+ if(line[i].y>2000)line[i].y=2000;
line[i].color=rand() % 20 + 100;
line[i].gh[0]=(getRand() % 16) / 3.5 + 2;
line[i].gh[1]=(getRand() % 16) / 3.5 + 2;
}
World *World::goWorldLeft(Player *p){
- if(toLeft&&p->loc.x<x_start+HLINE*10){
+ if(toLeft&&p->loc.x<x_start+HLINE*15){
p->loc.x=toLeft->x_start+getWidth(toLeft)-HLINE*10;
p->loc.y=toLeft->line[0].y;
return toLeft;