aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Changelog11
-rw-r--r--Makefile9
-rw-r--r--include/common.h7
-rw-r--r--include/entities.h3
-rw-r--r--main.cpp46
-rw-r--r--src/Quest.cpp5
-rw-r--r--src/Texture.cpp8
-rw-r--r--src/common.cpp40
-rw-r--r--src/entities.cpp131
-rw-r--r--src/gameplay.cpp34
-rw-r--r--src/inventory.cpp7
-rw-r--r--src/ui.cpp7
-rw-r--r--src/world.cpp81
-rw-r--r--xml/playerSpawnHill1.xml2
14 files changed, 183 insertions, 208 deletions
diff --git a/Changelog b/Changelog
index f6309bf..624281e 100644
--- a/Changelog
+++ b/Changelog
@@ -722,3 +722,14 @@
- added StrAttribute() to TinyXML2
- more merchant stuff, trading????
- improved village XML loading
+
+3/4/2016:
+=========
+
+ - added following functionality to entities
+ - fixed some world shading issues
+ - re-added stars, but stars draw midday
+ - restarted work on arenas
+ - began implementing currency system
+ - made the moon!
+ - merchants are a-o-kay
diff --git a/Makefile b/Makefile
index 1df683c..db92260 100644
--- a/Makefile
+++ b/Makefile
@@ -12,9 +12,9 @@ ifeq ($(TARGET_OS),win32)
-lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer -lfreetype
endif
-CXXFLAGS = -m$(TARGET_BITS) -std=c++11
+CXXFLAGS = -m$(TARGET_BITS) -std=c++14
CXXINC = -Iinclude -Iinclude/freetype2
-CXXWARN = -Wall -Wextra -Werror
+CXXWARN = -Wall -Wextra -Werror -pedantic-errors
CXXSRCDIR = src
CXXOUTDIR = out
@@ -32,7 +32,10 @@ clean:
rm -f $(EXEC)
rm -f out/*.o
-$(EXEC): $(CXXOUTDIR)/$(CXXOBJ)
+cleandata:
+ rm -rf xml/*.dat
+
+$(EXEC): $(CXXOUTDIR)/$(CXXOBJ) main.cpp
@echo " CXX/LD main"
@$(CXX) $(CXXFLAGS) $(CXXINC) $(CXXWARN) -o $(EXEC) main.cpp out/*.o $(LIBS)
diff --git a/include/common.h b/include/common.h
index 9650f49..58d561f 100644
--- a/include/common.h
+++ b/include/common.h
@@ -8,16 +8,17 @@
#ifndef COMMON_H
#define COMMON_H
+// holy moly
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
-#include <math.h>
#include <string>
#include <fstream>
#include <thread>
#include <mutex>
#include <future>
+#include <math.h>
#include <threadpool.h>
#define GLEW_STATIC
@@ -47,7 +48,7 @@ N abso(N v){
return v;
}
-extern GLuint colorIndex;
+extern GLuint colorIndex; // Texture.cpp?
/**
* This structure contains a set of coordinates for ease of coding.
@@ -104,7 +105,7 @@ typedef col Color;
* Define the game's name (displayed in the window title).
*/
-#define GAME_NAME "Independent Study v.0.5 alpha - NOW WITH SOUND!"
+#define GAME_NAME "Independent Study v.0.6 alpha - NOW WITH more c++"
/**
* The desired width of the game window.
diff --git a/include/entities.h b/include/entities.h
index b39923b..ef421f5 100644
--- a/include/entities.h
+++ b/include/entities.h
@@ -130,6 +130,7 @@ void initEntity();
class Entity{
public:
+ Entity *followee;
Inventory *inv;
/*
@@ -184,6 +185,8 @@ public:
virtual void wander(int){}
virtual void interact(){}
+
+ void follow(Entity *e);
virtual ~Entity(){}
};
diff --git a/main.cpp b/main.cpp
index e96a555..a9b172b 100644
--- a/main.cpp
+++ b/main.cpp
@@ -164,10 +164,10 @@ Menu pauseMenu;
extern WorldWeather weather;
-extern int fadeIntensity;
-extern bool fadeEnable;
-extern bool fadeWhite;
-extern bool fadeFast;
+extern int fadeIntensity; // ui.cpp
+extern bool fadeEnable; // ui.cpp
+extern bool fadeWhite; // ui.cpp
+extern bool fadeFast; // ui.cpp
unsigned int SCREEN_WIDTH;
unsigned int SCREEN_HEIGHT;
@@ -216,7 +216,7 @@ int main(int argc, char *argv[]){
static SDL_GLContext mainGLContext = NULL;
- gameRunning=false;
+ gameRunning = false;
/**
* (Attempt to) Initialize SDL libraries so that we can use SDL facilities and eventually
@@ -420,6 +420,8 @@ int main(int argc, char *argv[]){
**** GAMELOOP ****
**************************/
+ //currentWorld->mob.back()->followee = player;
+
gameRunning = true;
while(gameRunning){
mainLoop();
@@ -482,6 +484,7 @@ void mainLoop(void){
*/
prev = currentWorld;
+
//pool.Enqueue(ui::handleEvents);
ui::handleEvents();
@@ -490,13 +493,13 @@ void mainLoop(void){
currentWorld->bgmPlay(prev);
ui::dialogBoxExists = false;
}
-
+
if(prevPrevTime + MSEC_PER_TICK <= currentTime){
//pool.Enqueue(logic);
logic();
prevPrevTime = currentTime;
}
-
+
/*
* Update player and entity coordinates.
*/
@@ -902,36 +905,11 @@ void logic(){
}
}
}
- /*for(auto &b : currentWorld->build){
- switch(b->bsubtype){
- case FOUNTAIN:
- for(int r = 0; r < (rand()%25)+10;r++){
- currentWorld->addParticle( rand()%HLINE*3 + b->loc.x + b->width/2,
- b->loc.y + b->height,
- HLINE*1.25,
- HLINE*1.25,
- rand()%2 == 0?-(rand()%7)*.01:(rand()%7)*.01,
- ((4+rand()%6)*.05),
- {0,0,255},
- 2500);
-
- currentWorld->particles.back()->fountain = true;
- }
- break;
- case FIRE_PIT:
- for(int r = 0; r < (rand()%20)+10;r++){
- currentWorld->addParticle(rand()%(int)(b->width/2) + b->loc.x+b->width/4, b->loc.y+3*HLINE, HLINE, HLINE, rand()%2 == 0?-(rand()%3)*.01:(rand()%3)*.01,((4+rand()%6)*.005), {255,0,0}, 400);
- currentWorld->particles.back()->gravity = false;
- currentWorld->particles.back()->behind = true;
- }
- break;
- default: break;
- }
- }*/
/*
* Switch between day and night (SUNNY and DARK) if necessary.
- */
+ */
+
if(!(tickCount%DAY_CYCLE)||!tickCount){
if ( weather == WorldWeather::Sunny )
weather = WorldWeather::Dark;
diff --git a/src/Quest.cpp b/src/Quest.cpp
index e59d79f..8f3c33b 100644
--- a/src/Quest.cpp
+++ b/src/Quest.cpp
@@ -1,5 +1,6 @@
-#include <Quest.h>
+#include <algorithm>
+#include <Quest.h>
#include <entities.h>
extern Player *player;
@@ -33,8 +34,6 @@ int QuestHandler::assign(std::string title,std::string desc,std::string req){
return 0;
}
-#include <algorithm>
-
int QuestHandler::drop(std::string title){
current.erase( std::remove_if( current.begin(),
current.end(),
diff --git a/src/Texture.cpp b/src/Texture.cpp
index 731a1d6..ed93af9 100644
--- a/src/Texture.cpp
+++ b/src/Texture.cpp
@@ -7,11 +7,11 @@
* A structure for keeping track of loaded textures.
*/
-struct texture_t {
+typedef struct {
std::string name; /**< The file path of the texture. */
GLuint tex; /**< The GLuint for the loaded texture. */
dim2 dim; /**< The dimensions of the texture. */
-};
+} texture_t;
struct index_t {
Color color;
@@ -26,7 +26,7 @@ struct index_t {
* this array and reuse GLuint's to save memory.
*/
-static std::vector<struct texture_t> LoadedTexture;
+static std::vector<texture_t> LoadedTexture;
namespace Texture{
Color pixels[8][4];
@@ -81,7 +81,7 @@ namespace Texture{
);
// add texture to LoadedTexture
- LoadedTexture.push_back((struct texture_t){fileName,object,{image->w,image->h}});
+ LoadedTexture.push_back(texture_t{fileName,object,{image->w,image->h}});
// free the SDL_Surface
SDL_FreeSurface(image);
diff --git a/src/common.cpp b/src/common.cpp
index 6dc2c46..1c9c2b5 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -1,15 +1,16 @@
-#include <common.h>
#include <cstring>
#include <cstdio>
#include <chrono>
#ifndef __WIN32__
-#include <sys/types.h>
-#include <dirent.h>
-#include <errno.h>
-#include <vector>
+# include <sys/types.h>
+# include <dirent.h>
+# include <errno.h>
+# include <vector>
#endif // __WIN32__
+#include <common.h>
+
#ifndef __WIN32__
unsigned int millis(void){
@@ -79,7 +80,7 @@ const char *readFile(const char *path){
std::ifstream in (path,std::ios::in);
unsigned int size;
GLchar *buf;
-
+
if(!in.is_open()){
std::cout<<"Error reading file "<<path<<"!"<<std::endl;
abort();
@@ -101,30 +102,3 @@ UserError( std::string reason )
std::cout << "User error: " << reason << "!" << std::endl;
abort();
}
-
-/*int strCreateFunc(const char *equ){
- static unsigned int size;
- static char *filebuf;
- static FILE *file;
-
- size = 57 + strlen(equ) + 3;
-
- filebuf = new char[size];
- memset(filebuf,0,size);
-
- strcpy(filebuf,"#include <stdio.h>\n#include <math.h>\nint main(){return ");
- strcat(filebuf,equ);
- strcat(filebuf,";}");
-
- if(!(file = fopen("gen.tmp","w"))){
- abort();
- }
-
- fwrite(filebuf,size,sizeof(char),file);
- delete[] filebuf;
- fclose(file);
-
- system("
-
- return 0;
-}*/
diff --git a/src/entities.cpp b/src/entities.cpp
index cd534cd..329af63 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -1,20 +1,37 @@
-#include <entities.h>
-#include <ui.h>
-
#include <istream>
-#define RAND_DIALOG_COUNT 14
+#include <entities.h>
+#include <ui.h>
extern std::istream *names;
-extern unsigned int loops;
-extern World *currentWorld;
+extern Player *player; // main.cpp
+extern World *currentWorld; // main.cpp
+extern unsigned int loops; // main.cpp
-extern Player *player;
+GLuint waterTex;
-extern const char *itemName;
+std::vector<int (*)(NPC *)> AIpreload; // A dynamic array of AI functions that are being preloaded
+std::vector<NPC *> AIpreaddr; // A dynamic array of pointers to the NPC's that are being assigned the preloads
-GLuint waterTex;
+#define RAND_DIALOG_COUNT 14
+
+const char *randomDialog[RAND_DIALOG_COUNT] = {
+ "What a beautiful day it is.",
+ "Have you ever went fast? I have.",
+ "I heard if you complete a quest, you'll get a special reward.",
+ "How much wood could a woodchuck chuck if a woodchuck could chuck wood?",
+ "I don\'t think anyone has ever been able to climb up that hill.",
+ "If you ever see a hole in the ground, watch out; it could mean the end for you.",
+ "Did you know this game has over 5000 lines of code? I didn\'t. I didn't even know I was in a game until now...",
+ "HELP MY CAPS LOCK IS STUCK",
+ "You know, if anyone ever asked me who I wanted to be when I grow up, I would say Abby Ross.",
+ "I want to have the wallpaper in our house changed. It doesn\'t really fit the environment.",
+ "Frig.",
+ "The sine of theta equals the opposite over the hypotenuese.",
+ "Did you know the developers spelt brazier as brazzier.",
+ "My dad once said to me, \"Boy, you are in a game.\" I never knew what he meant by that."
+};
void initEntity(){
waterTex = Texture::loadTexture("assets/waterTex.png");
@@ -78,6 +95,8 @@ void Entity::spawn(float x, float y){ //spawns the entity you pass to it based o
name = new char[32];
getRandomName(this);
+
+ followee = NULL;
}
Player::Player(){ //sets all of the player specific traits on object creation
@@ -362,43 +381,39 @@ NOPE:
if(near)ui::putStringCentered(loc.x+width/2,loc.y-ui::fontSize-HLINE/2,name);
}
-/*
- * NPC::wander, this makes the npcs wander around the near area
- *
- * timeRun This variable is the amount of gameloop ticks the entity will wander for
-*/
+/**
+ * Handles NPC movement, usually just random walking.
+ */
-void NPC::wander(int timeRun){
-
- /*
- * Direction is the variable that decides what direction the entity will travel in
- * the value is either -1, 0, or 1. -1 being left, 0 means that the npc will stay still
- * and a value of 1 makes the entity move to the right
- */
-
+void NPC::
+wander( int timeRun )
+{
static int direction;
- /*
- * Ticks to use is a variable in the entity class that counts the total ticks that need to be used
- *
- * This loop only runs when ticksToUse is 0, this means that the speed, direction, etc... Will be
- * calculated only after the npc has finished his current walking state
- */
-
- if(ticksToUse == 0){
+ if ( followee ) {
+ if ( loc.x < followee->loc.x - 40 )
+ direction = 1;
+ else if ( loc.x > followee->loc.x + 40 )
+ direction = -1;
+ else
+ direction = 0;
+
+ vel.x = .018 * HLINE * direction;
+ } else if ( ticksToUse == 0 ) {
ticksToUse = timeRun;
- vel.x = .008*HLINE; //sets the inital velocity of the entity
- direction = (getRand() % 3 - 1); //sets the direction to either -1, 0, 1
- //this lets the entity move left, right, or stay still
- if(direction==0)ticksToUse*=2;
- vel.x *= direction; //changes the velocity based off of the direction
+
+ vel.x = .008 * HLINE;
+ direction = (getRand() % 3 - 1);
+
+ if ( direction == 0 )
+ ticksToUse *= 2;
+
+ vel.x *= direction;
}
- ticksToUse--; //removes one off of the entities timer
+
+ ticksToUse--;
}
-std::vector<int (*)(NPC *)> AIpreload; // A dynamic array of AI functions that are being preloaded
-std::vector<NPC *> AIpreaddr; // A dynamic array of pointers to the NPC's that are being assigned the preloads
-
void NPC::addAIFunc(int (*func)(NPC *),bool preload){
if(preload){ // Preload AI functions so that they're given after
// the current dialog box is closed
@@ -412,23 +427,6 @@ void NPC::clearAIFunc(void){
aiFunc.clear();
}
-const char *randomDialog[RAND_DIALOG_COUNT] = {
- "What a beautiful day it is.",
- "Have you ever went fast? I have.",
- "I heard if you complete a quest, you'll get a special reward.",
- "How much wood could a woodchuck chuck if a woodchuck could chuck wood?",
- "I don\'t think anyone has ever been able to climb up that hill.",
- "If you ever see a hole in the ground, watch out; it could mean the end for you.",
- "Did you know this game has over 5000 lines of code? I didn\'t. I didn't even know I was in a game until now...",
- "HELP MY CAPS LOCK IS STUCK",
- "You know, if anyone ever asked me who I wanted to be when I grow up, I would say Abby Ross.",
- "I want to have the wallpaper in our house changed. It doesn\'t really fit the environment.",
- "Frig.",
- "The sine of theta equals the opposite over the hypotenuese.",
- "Did you know the developers spelt brazier as brazzier.",
- "My dad once said to me, \"Boy, you are in a game.\" I never knew what he meant by that."
-};
-
void NPC::interact(){ //have the npc's interact back to the player
int (*func)(NPC *);
loc.y += 5;
@@ -476,6 +474,12 @@ void Object::interact(void){
}
}
+void Entity::
+follow( Entity *e )
+{
+ followee = e;
+}
+
/*
* This spawns the structures
*
@@ -538,12 +542,25 @@ void Mob::wander(int timeRun){
static unsigned int heya=0,hi=0;
static bool YAYA = false;
+ if ( followee ) {
+ if ( loc.x < followee->loc.x - 40 )
+ direction = 1;
+ else if ( loc.x > followee->loc.x + 40 )
+ direction = -1;
+ else
+ direction = 0;
+
+ vel.x = .018 * HLINE * direction;
+ return;
+ }
+
if(aggressive && !YAYA &&
player->loc.x + (width / 2) > loc.x && player->loc.x + (width / 2) < loc.x + width &&
player->loc.y + (height / 3) > loc.y && player->loc.y + (height / 3) < loc.y + height ){
Arena *a = new Arena(currentWorld,player,this);
a->setBackground( WorldBGType::Forest );
a->setBGM("assets/music/embark.wav");
+
ui::toggleWhiteFast();
YAYA = true;
ui::waitForCover();
@@ -654,7 +671,7 @@ void Player::sspawn(float x,float y){
std::getline(data,ddata);
count = std::stoi(ddata);
std::getline(data,ddata);
- inv->items.push_back((item_t){count,(uint)std::stoi(ddata)});
+ inv->items.push_back(item_t{count,(uint)std::stoi(ddata)});
}
std::getline(data,ddata);
diff --git a/src/gameplay.cpp b/src/gameplay.cpp
index a286db9..0624067 100644
--- a/src/gameplay.cpp
+++ b/src/gameplay.cpp
@@ -4,30 +4,28 @@
#include <ui.h>
#include <tinyxml2.h>
-
using namespace tinyxml2;
-extern World *currentWorld;
-extern Player *player;
+extern Player *player; // main.cpp
+extern World *currentWorld; // main.cpp
-extern float shit;
-extern Menu* currentMenu;
-extern Menu pauseMenu;
-extern Menu optionsMenu;
+extern float shit;
+extern Menu *currentMenu;
+extern Menu pauseMenu;
+extern Menu optionsMenu;
-extern void mainLoop(void);
+extern void mainLoop(void); // main.cpp
-void segFault(){
- (*((int *)NULL))++;
-}
+extern std::vector<NPC *> AIpreaddr; // entities.cpp
+extern std::vector<int (*)(NPC *)> AIpreload; // entities.cpp
+std::vector<XMLElement *> dopt;
-typedef struct {
- NPC *npc;
- unsigned int index;
-} NPCDialog;
+void destroyEverything(void);
-std::vector<XMLElement *> dopt;
+void segFault(){
+ (*((int *)NULL))++;
+}
int commonAIFunc(NPC *speaker){
XMLDocument xml;
@@ -252,7 +250,6 @@ void commonTriggerFunc(Mob *callee){
}
}
-void destroyEverything(void);
void initEverything(void){
std::vector<std::string> xmlFiles;
XMLDocument xml;
@@ -314,9 +311,6 @@ void initEverything(void){
atexit(destroyEverything);
}
-extern std::vector<int (*)(NPC *)> AIpreload;
-extern std::vector<NPC *> AIpreaddr;
-
void destroyEverything(void){
currentWorld->save();
delete currentWorld;
diff --git a/src/inventory.cpp b/src/inventory.cpp
index d75a1bf..e82d99e 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -14,6 +14,8 @@ static vec2 itemLoc;
Mix_Chunk* swordSwing;
static std::vector<Item *> itemMap;
+static GLuint *itemtex;
+void itemDraw(Player *p,uint id);
void items(void){
XMLDocument xml;
@@ -44,7 +46,7 @@ int Inventory::addItem(std::string name,uint count){
return 0;
}
}
- items.push_back((item_t){count,i});
+ items.push_back( item_t { count, i });
return 0;
}
}
@@ -108,9 +110,6 @@ int Inventory::hasItem(std::string name){
return 0;
}
-static GLuint *itemtex;
-void itemDraw(Player *p,uint id);
-
void initInventorySprites(void){
items();
diff --git a/src/ui.cpp b/src/ui.cpp
index 81098fc..f0cc507 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -191,7 +191,7 @@ namespace ui {
void setFontSize(unsigned int size){
unsigned int i,j;
- char *buf;
+ unsigned char *buf;
fontSize=size;
FT_Set_Pixel_Sizes(ftf,0,fontSize);
@@ -231,7 +231,7 @@ namespace ui {
* making it white-on-black.
*/
- buf = new char[ftf->glyph->bitmap.width * ftf->glyph->bitmap.rows * 4];
+ buf = new unsigned char[ftf->glyph->bitmap.width * ftf->glyph->bitmap.rows * 4];
for(j=0;j<ftf->glyph->bitmap.width*ftf->glyph->bitmap.rows;j++){
buf[j*4 ]=255;//fontColor[0];
@@ -1131,7 +1131,8 @@ namespace ui {
}
void takeScreenshot(GLubyte* pixels){
- GLubyte bgr[SCREEN_WIDTH*SCREEN_HEIGHT*3];
+ std::vector<GLubyte> bgr (SCREEN_WIDTH * SCREEN_HEIGHT * 3, 0);
+
for(uint x = 0; x < SCREEN_WIDTH*SCREEN_HEIGHT*3; x+=3){
bgr[x] = pixels[x+2];
bgr[x+1] = pixels[x+1];
diff --git a/src/world.cpp b/src/world.cpp
index 8283e8c..a0ae0f3 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -1,8 +1,12 @@
#include <algorithm>
+#include <sstream>
#include <world.h>
#include <ui.h>
+#include <tinyxml2.h>
+using namespace tinyxml2;
+
/**
* Defines how many HLINEs tall a blade of grass can be.
*/
@@ -16,8 +20,22 @@
#define INDOOR_FLOOR_HEIGHT 100
-extern Player *player;
+extern Player *player; // main.cpp?
+extern World *currentWorld; // main.cpp
+extern int commonAIFunc(NPC *); // entities.cpp
+extern void commonTriggerFunc(Mob *); // entities.cpp
+extern bool inBattle;
+
+extern unsigned int tickCount; // main.cpp
+
+int worldShade = 0;
+
+std::string currentXML;
+
+std::vector<std::string> inside; // tracks indoor worlds
+std::vector<World *> battleNest; // tracks arenas
+std::vector<vec2> battleNestLoc; // keeps arena locations
/**
* Contains the current weather, used in many other places/files.
@@ -230,7 +248,7 @@ generate( unsigned int width )
UserError("Invalid world dimensions");
// allocate space for world
- worldData = std::vector<WorldData> (width + GROUND_HILLINESS, (WorldData) { false, {0,0}, 0, 0 });
+ worldData = std::vector<WorldData> (width + GROUND_HILLINESS, WorldData { false, {0,0}, 0, 0 });
lineCount = worldData.size();
// prepare for generation
@@ -270,7 +288,11 @@ generate( unsigned int width )
worldStart = (width - GROUND_HILLINESS) * HLINE / 2 * -1;
// create empty star array, should be filled here as well...
- star = std::vector<vec2> (100, (vec2) { 0, 0 } );
+ star = std::vector<vec2> (100, vec2 { 0, 400 } );
+ for ( auto &s : star ) {
+ s.x = (getRand() % (-worldStart * 2)) + worldStart;
+ s.y = (getRand() % SCREEN_HEIGHT) + 100.0f;
+ }
}
/**
@@ -364,20 +386,6 @@ bgmPlay( World *prev ) const
}
/**
- * Variables used by World::draw().
- * @{
- */
-
-extern vec2 offset;
-extern unsigned int tickCount;
-
-int worldShade = 0;
-
-/**
- * @}
- */
-
-/**
* The world draw function.
*
* This function will draw the background layers, entities, and player to the
@@ -436,7 +444,7 @@ draw( Player *p )
if (tickCount % DAY_CYCLE) { // The above if statement doesn't check for exact midnight.
- safeSetColorA( 255, 255, 255, shadeBackground + getRand() % 30 - 15 );
+ safeSetColorA( 255, 255, 255, 255 - (getRand() % 30 - 15) );
for ( i = 0; i < 100; i++ ) {
glRectf(star[i].x + offset.x * .9,
@@ -446,7 +454,7 @@ draw( Player *p )
);
}
}
- }
+ }
// draw remaining background items
@@ -464,7 +472,7 @@ draw( Player *p )
}
glEnd();
- for (i = 0; i < 4; i++) {
+ for ( i = 0; i < 4; i++ ) {
bgTex->bindNext();
safeSetColorA( bgDraw[i][0] - shadeBackground, bgDraw[i][0] - shadeBackground, bgDraw[i][0] - shadeBackground, bgDraw[i][1] );
@@ -515,7 +523,11 @@ draw( Player *p )
glActiveTexture( GL_TEXTURE0 );
bgTex->bindNext();
- GLfloat pointArray[ light.size() + (int)p->light ][2];
+ // help me
+ std::unique_ptr<GLfloat[][2]> pointArrayBuf = std::make_unique<GLfloat[][2]> (light.size() + p->light);
+ auto pointArray = pointArrayBuf.get();
+
+ //GLfloat pointArray[ light.size() + (int)p->light ][2];
for ( i = 0; i < (int)light.size(); i++ ) {
pointArray[i][0] = light[i].loc.x - offset.x;
@@ -527,7 +539,7 @@ draw( Player *p )
glUseProgram( shaderProgram );
glUniform1i( glGetUniformLocation( shaderProgram, "sampler"), 0 );
- glUniform1f( glGetUniformLocation( shaderProgram, "amb" ), 1 );
+ glUniform1f( glGetUniformLocation( shaderProgram, "amb" ), 0.5f - worldShade / 50.0f );
if ( p->light ) {
pointArray[light.size() + 1][0] = (float)( p->loc.x + SCREEN_WIDTH / 2 );
@@ -984,8 +996,6 @@ World *World::goWorldRight(Player *p){
return this;
}
-std::vector<std::string> inside;
-
World *World::
goInsideStructure( Player *p )
{
@@ -1072,11 +1082,6 @@ void World::save(void){
out.close();
}
-#include <sstream>
-
-extern int commonAIFunc(NPC *);
-extern void commonTriggerFunc(Mob *);
-
void World::load(void){
std::string save,data,line;
const char *filedata;
@@ -1143,7 +1148,7 @@ void IndoorWorld::generate(unsigned int width){ // Generates a flat area of wid
lineCount=width+GROUND_HILLINESS; // Sets line count to the desired width plus GEN_INC to remove incorrect line calculations.
if(lineCount<=0)abort();
- worldData = std::vector<WorldData> (lineCount, (WorldData) { false, {0,0}, INDOOR_FLOOR_HEIGHT, 0 });
+ worldData = std::vector<WorldData> (lineCount, WorldData { false, {0,0}, INDOOR_FLOOR_HEIGHT, 0 });
worldStart = (width - GROUND_HILLINESS) * HLINE / 2 * -1;
}
@@ -1159,7 +1164,9 @@ void IndoorWorld::draw(Player *p){
glEnable(GL_TEXTURE_2D);
- GLfloat pointArray[light.size()][2];
+ std::unique_ptr<GLfloat[][2]> pointArrayBuf = std::make_unique<GLfloat[][2]> (light.size());
+ auto pointArray = pointArrayBuf.get();
+
for(uint w = 0; w < light.size(); w++){
pointArray[w][0] = light[w].loc.x - offset.x;
pointArray[w][1] = light[w].loc.y;
@@ -1240,11 +1247,6 @@ void IndoorWorld::draw(Player *p){
p->draw();
}
-extern bool inBattle;
-
-std::vector<World *> battleNest;
-std::vector<vec2> battleNestLoc;
-
Arena::Arena(World *leave,Player *p,Mob *m){
generate(800);
addMob(MS_DOOR,100,100);
@@ -1287,13 +1289,6 @@ World *Arena::exitArena(Player *p){
}
}
-#include <tinyxml2.h>
-using namespace tinyxml2;
-
-std::string currentXML;
-
-extern World *currentWorld;
-
World *loadWorldFromXML(std::string path){
if ( !currentXML.empty() )
currentWorld->save();
diff --git a/xml/playerSpawnHill1.xml b/xml/playerSpawnHill1.xml
index 2fa7512..2e8b2aa 100644
--- a/xml/playerSpawnHill1.xml
+++ b/xml/playerSpawnHill1.xml
@@ -4,7 +4,7 @@
<generation type="Random" width="500" />
<link left="playerSpawnHill2.xml" />
- <mob type="1" aggressive="false" />
+ <mob x="300" type="1" aggressive="true" />
<trigger x="-300" id="Test" />