From 1c0767766506407babdfefea9efe2b5627569244 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Tue, 6 Oct 2015 08:50:52 -0400 Subject: improvements ;) --- src/Makefile | 11 +++++++++++ src/entities.cpp | 6 +++--- src/world.cpp | 23 ++++++++++++++--------- 3 files changed, 28 insertions(+), 12 deletions(-) create mode 100644 src/Makefile (limited to 'src') diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..f75bee9 --- /dev/null +++ b/src/Makefile @@ -0,0 +1,11 @@ +LIBS = -lGL -lSDL2_image -lSDL2_mixer + +FLAGS = -m32 -std=c++11 -I../include -I../include/freetype2 -lSDL2main -lSDL2 -lfreetype + +OUT = `echo "" $$(ls -c $(wildcard *.cpp)) | sed s/.cpp/.o/g | sed 's/ / ..\/out\//g'` + +../out/%.o: + @echo " CXX " $(shell echo $@ | sed 's/..\/out\///g' | sed 's/\.o/\.cpp/') + @g++ $(FLAGS) -o $@ -c $(shell echo $@ | sed 's/..\/out\///g' | sed 's/\.o/\.cpp/') $(LIBS) + +all: $(shell echo $(OUT)) diff --git a/src/entities.cpp b/src/entities.cpp index 42f93c8..5dc743c 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -85,17 +85,17 @@ void Entity::getName(){ switch(fgetc(names)){ case 'm': gender = MALE; - std::puts("Male"); + //std::puts("Male"); break; case 'f': gender = FEMALE; - std::puts("Female"); + //std::puts("Female"); break; default: break; } if((fgets(bufs,16,(FILE*)names)) != NULL){ - std::puts(bufs); + //std::puts(bufs); bufs[strlen(bufs)-1] = '\0'; strcpy(name,bufs); } diff --git a/src/world.cpp b/src/world.cpp index d2cd380..ef11002 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -11,7 +11,7 @@ #define DRAW_Y_OFFSET 50 // Defines how many pixels each layer should be offset from each other on the y axis when drawn. -#define DRAW_SHADE 40 // Defines a shade increment for draw() +#define DRAW_SHADE 10 // Defines a shade increment for draw() #define INDOOR_FLOOR_HEIGHT 100 // Defines how high the base floor of an IndoorWorld should be @@ -50,8 +50,9 @@ void World::generate(unsigned int width){ // Generates the world and sets all va }else{ // If this line's y hasn't been set yet line[i].y=line[i-1].y+inc; // Set it by incrementing the previous line's y by 'inc'. } - line[i].color=rand()%20+130; // Generate a color for the dirt area of this line. This value will be used - // in the form (where n represents the color) glColor3ub(n,n-50,n-100) + line[i].color=rand()%20+90; // Generate a color for the dirt area of this line. This value will be used + // in the form (where n represents the color) glColor3ub(n,n-50,n-100) + line[i].gh=(getRand()%20)/3; // Create a random grass height so it looks cool } x_start=0-getWidth(this)/2+GEN_INC/2*HLINE; // Calculate x_start (explained in world.h) behind=infront=NULL; // Set pointers to other worlds to NULL @@ -69,6 +70,7 @@ void World::draw(vec2 *vec){ int i,ie,v_offset,cx_start; struct line_t *cline; current=this; // yeah + glClearColor(.1,.3,.6,0); LOOP1: // Check for worlds behind the current one and set 'current' to them if they exist if(current->behind){ // so that once LOOP1 is exited 'current' contains the furthest back world. yoff+=DRAW_Y_OFFSET; @@ -85,22 +87,24 @@ LOOP2: // Draw each world if(ie>current->lineCount)ie=current->lineCount; // If the player is past the end of that world 'ie' should contain the end of that world cline=current->line; // 'cline' and 'cx_start' only exist to make the for loop clear (and maybe make it faster) cx_start=current->x_start; + shade*=-1; glBegin(GL_QUADS); for(i=i;iplatform.size();i++){ glRectf(current->platform[i].p1.x,current->platform[i].p1.y+yoff-DRAW_Y_OFFSET, @@ -273,6 +277,7 @@ void IndoorWorld::draw(vec2 *vec){ // of the world ie=v_offset+SCREEN_WIDTH/2; // Set how many lines should be drawn (the drawing for loop loops from 'i' to 'ie') if(ie>lineCount)ie=lineCount; // If the player is past the end of that world 'ie' should contain the end of that world + glClearColor(.3,.1,0,0); glBegin(GL_QUADS); for(i=i;i