From 7b1908e2bc2531de0b7e5ec81ab09b50ae14263f Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Tue, 15 Dec 2015 21:20:01 -0500 Subject: music updates --- assets/music/ozone.wav | Bin 0 -> 13013036 bytes assets/music/theme.wav | Bin 0 -> 23175212 bytes assets/music/theme_jazz.wav | Bin 0 -> 13193260 bytes 3 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 assets/music/ozone.wav create mode 100644 assets/music/theme.wav create mode 100644 assets/music/theme_jazz.wav (limited to 'assets') diff --git a/assets/music/ozone.wav b/assets/music/ozone.wav new file mode 100644 index 0000000..6cc2416 Binary files /dev/null and b/assets/music/ozone.wav differ diff --git a/assets/music/theme.wav b/assets/music/theme.wav new file mode 100644 index 0000000..8b4ea47 Binary files /dev/null and b/assets/music/theme.wav differ diff --git a/assets/music/theme_jazz.wav b/assets/music/theme_jazz.wav new file mode 100644 index 0000000..1c62bbc Binary files /dev/null and b/assets/music/theme_jazz.wav differ -- cgit v1.2.3 From a83d037394f37403918b62fdc0083d4b84ea02db Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Wed, 16 Dec 2015 07:27:06 -0500 Subject: music/merge --- Changelog | 6 ++++++ assets/dirt.png | Bin 0 -> 578 bytes assets/door.png | Bin 255 -> 280 bytes assets/maybeplayer.png | Bin 0 -> 2898 bytes include/common.h | 13 +++++++++++++ include/ui.h | 11 ++++++++--- main.cpp | 20 -------------------- src/common.cpp | 10 +++++++++- src/entities.cpp | 7 ++++--- src/gameplay.cpp | 2 +- src/inventory.cpp | 5 +++-- src/ui.cpp | 6 ++++++ src/world.cpp | 25 ++++++++++++++++--------- xcf/dirt.xcf | Bin 0 -> 1239 bytes xcf/door.xcf | Bin 1404 -> 1628 bytes xcf/maybeplayer.xcf | Bin 3117 -> 7564 bytes 16 files changed, 66 insertions(+), 39 deletions(-) create mode 100644 assets/dirt.png create mode 100644 assets/maybeplayer.png create mode 100644 xcf/dirt.xcf (limited to 'assets') diff --git a/Changelog b/Changelog index c894c5c..d1fac71 100644 --- a/Changelog +++ b/Changelog @@ -420,3 +420,9 @@ - fixed fading bugs - continued fixing general game bugs - fixed structure spawn issues + +12/15/2015: +=========== + + - began/continued work on original player sprite + - began working on dirt textures diff --git a/assets/dirt.png b/assets/dirt.png new file mode 100644 index 0000000..04c87b6 Binary files /dev/null and b/assets/dirt.png differ diff --git a/assets/door.png b/assets/door.png index 2a8b0dd..582a52d 100644 Binary files a/assets/door.png and b/assets/door.png differ diff --git a/assets/maybeplayer.png b/assets/maybeplayer.png new file mode 100644 index 0000000..ee0e49d Binary files /dev/null and b/assets/maybeplayer.png differ diff --git a/include/common.h b/include/common.h index 31126d7..08ec73f 100644 --- a/include/common.h +++ b/include/common.h @@ -160,4 +160,17 @@ void safeSetColor(int r,int g,int b); void safeSetColorA(int r,int g,int b,int a); +/** + * We've encountered many problems when attempting to create delays for triggering + * the logic function. As a result, we decided on using the timing libraries given + * by in the standard C++ library. This function simply returns the amount + * of milliseconds that have passed sine the epoch. + */ + +#ifdef __WIN32__ +#define millis() SDL_GetTicks() +#else +unsigned int millis(void); +#endif // __WIN32__ + #endif // COMMON_H diff --git a/include/ui.h b/include/ui.h index 5d17c47..6a81dab 100644 --- a/include/ui.h +++ b/include/ui.h @@ -1,3 +1,7 @@ +/** @file ui.h + * @brief Contains functions for handling the user interface. + */ + #ifndef UI_H #define UI_H @@ -12,9 +16,9 @@ namespace ui { - /* - * Contains the coordinates of the mouse in the window. - */ + /** + * Contains the coordinates of the mouse inside the window. + */ extern vec2 mouse; @@ -90,6 +94,7 @@ namespace ui { void toggleWhiteFast(void); void waitForCover(void); + void waitForNothing(unsigned int); } #endif // UI_H diff --git a/main.cpp b/main.cpp index 5b9b1b6..a9cc2fa 100644 --- a/main.cpp +++ b/main.cpp @@ -4,7 +4,6 @@ */ #include // fopen -#include // see millis() #include #include @@ -188,25 +187,6 @@ std::string readFile(const char *filePath) { vec2 offset; /* OFFSET!!!!!!!!!!!!!!!!!!!! */ -/** - * millis - * - * We've encountered many problems when attempting to create delays for triggering - * the logic function. As a result, we decided on using the timing libraries given - * by in the standard C++ library. This function simply returns the amount - * of milliseconds that have passed sine the epoch. - * -**/ - -#ifdef __WIN32__ -#define millis() SDL_GetTicks() -#else -unsigned int millis(void){ - std::chrono::system_clock::time_point now=std::chrono::system_clock::now(); - return std::chrono::duration_cast(now.time_since_epoch()).count(); -} -#endif - extern WEATHER weather; extern bool fadeEnable; diff --git a/src/common.cpp b/src/common.cpp index a8a964e..7449a35 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -1,7 +1,15 @@ #include #include +#include -#define DEBUG +#ifndef __WIN32__ + +unsigned int millis(void){ + std::chrono::system_clock::time_point now=std::chrono::system_clock::now(); + return std::chrono::duration_cast(now.time_since_epoch()).count(); +} + +#endif // __WIN32__ void DEBUG_prints(const char* file, int line, const char *s,...){ va_list args; diff --git a/src/entities.cpp b/src/entities.cpp index 24c0d01..7ebe744 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -83,7 +83,8 @@ Player::Player(){ //sets all of the player specific traits on object creation subtype = 0; health = maxHealth = 100; speed = 1; - tex = new Texturec(3, "assets/player1.png", "assets/player.png", "assets/player2.png"); + //tex = new Texturec(3, "assets/player1.png", "assets/player.png", "assets/player2.png"); + tex = new Texturec(3, "assets/maybeplayer.png", "assets/maybeplayer.png", "assets/maybeplayer.png"); inv = new Inventory(PLAYER_INV_SIZE); } Player::~Player(){ @@ -155,8 +156,8 @@ Mob::Mob(int sub){ height = 2000; tex = new Texturec(0); case MS_DOOR: - width = HLINE * 10; - height = HLINE * 16; + width = HLINE * 12; + height = HLINE * 19; tex = new Texturec(1,"assets/door.png"); break; } diff --git a/src/gameplay.cpp b/src/gameplay.cpp index 0ee6055..d3dd03a 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -133,7 +133,6 @@ void initEverything(void){ //playerSpawnHill->addMob(MS_TRIGGER,player->loc.x,0,story); - //worldSpawnHill2->addStructure(STRUCTURET,HOUSE,(rand()%120*HLINE),100,worldSpawnHill1,worldSpawnHill2); //playerSpawnHill->addStructure(STRUCTURET,FOUNTAIN,(rand()%120*HLINE)+100*HLINE,100,test,iw); //playerSpawnHill->addStructure(STRUCTURET,HOUSE2,(rand()%120*HLINE)+300*HLINE,100,test,iw); @@ -142,6 +141,7 @@ void initEverything(void){ currentWorld = worldSpawnHill1; + worldSpawnHill2->addStructure(STRUCTURET,HOUSE,(rand()%120*HLINE),100,worldSpawnHill1,worldSpawnHill2); player = new Player(); player->spawn(200,100); diff --git a/src/inventory.cpp b/src/inventory.cpp index 5ae97b4..52ae02c 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -299,10 +299,10 @@ void itemDraw(Player *p,ITEM_ID id,ITEM_TYPE type){ glBindTexture(GL_TEXTURE_2D,itemtex[id]); glColor4ub(255,255,255,255); glBegin(GL_QUADS); - glTexCoord2i(0,1);glVertex2f(itemLoc.x, itemLoc.y); + glTexCoord2i(0,1);glVertex2f(itemLoc.x, itemLoc.y); glTexCoord2i(1,1);glVertex2f(itemLoc.x+item[id].width,itemLoc.y); glTexCoord2i(1,0);glVertex2f(itemLoc.x+item[id].width,itemLoc.y+item[id].height); - glTexCoord2i(0,0);glVertex2f(itemLoc.x, itemLoc.y+item[id].height); + glTexCoord2i(0,0);glVertex2f(itemLoc.x, itemLoc.y+item[id].height); glEnd(); glDisable(GL_TEXTURE_2D); glTranslatef(player->loc.x*2,0,0); @@ -341,6 +341,7 @@ int Inventory::useItem(void){ } break; default: + //hangle++; break; } } diff --git a/src/ui.cpp b/src/ui.cpp index 11bc195..08f503f 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -464,6 +464,12 @@ namespace ui { }while(fadeIntensity < 255); fadeIntensity = 255; } + void waitForNothing(unsigned int ms){ + unsigned int target = millis() + ms; + do{ + mainLoop(); + }while(millis() < target); + } void importantText(const char *text,...){ va_list textArgs; diff --git a/src/world.cpp b/src/world.cpp index b964c9a..9a2b6d3 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -17,13 +17,14 @@ bool worldInside = false; // True if player is inside a structure WEATHER weather = SUNNY; -const char *bgPaths[2][6]={ +const char *bgPaths[2][7]={ {"assets/bg.png", // Daytime background "assets/bgn.png", // Nighttime background "assets/bgFarMountain.png", // Furthest layer "assets/forestTileBack.png", // Closer layer "assets/forestTileMid.png", // Near layer - "assets/forestTileFront.png"}, // Closest layer + "assets/forestTileFront.png", // Closest layer + "assets/dirt.png"}, // Dirt {"assets/bgWoodTile.png", NULL, NULL, @@ -51,7 +52,7 @@ float worldGetYBase(World *w){ void World::setBackground(WORLD_BG_TYPE bgt){ switch(bgt){ case BG_FOREST: - bgTex = new Texturec(6,bgPaths[0]); + bgTex = new Texturec(7,bgPaths[0]); break; case BG_WOODHOUSE: bgTex = new Texturec(1,bgPaths[1]); @@ -549,20 +550,25 @@ LOOP2: */ bool hey=false; + glEnable(GL_TEXTURE_2D); + 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 + bgTex->bindNext(); glBegin(GL_QUADS); for(i=is;i<(unsigned)ie-GEN_INC;i++){ cline[i].y+=(yoff-DRAW_Y_OFFSET); // Add the y offset if(!cline[i].y){ cline[i].y=base; hey=true; - safeSetColor(cline[i].color-100+shade,cline[i].color-150+shade,cline[i].color-200+shade); + //safeSetColor(cline[i].color-100+shade,cline[i].color-150+shade,cline[i].color-200+shade); }else{ - safeSetColor(cline[i].color+shade,cline[i].color-50+shade,cline[i].color-100+shade); // Set the shaded dirt color + //safeSetColor(cline[i].color+shade,cline[i].color-50+shade,cline[i].color-100+shade); // Set the shaded dirt color } - glVertex2i(cx_start+i*HLINE ,cline[i].y-GRASS_HEIGHT); - glVertex2i(cx_start+i*HLINE+HLINE,cline[i].y-GRASS_HEIGHT); - glVertex2i(cx_start+i*HLINE+HLINE,0); - glVertex2i(cx_start+i*HLINE ,0); + glColor4ub(255,255,255,255); + glTexCoord2i(0,1);glVertex2i(cx_start+i*HLINE ,cline[i].y-GRASS_HEIGHT); + glTexCoord2i(1,1);glVertex2i(cx_start+i*HLINE+HLINE,cline[i].y-GRASS_HEIGHT); + glTexCoord2i(1,0);glVertex2i(cx_start+i*HLINE+HLINE,0); + glTexCoord2i(0,0);glVertex2i(cx_start+i*HLINE ,0); cline[i].y-=(yoff-DRAW_Y_OFFSET); // Restore the line's y value if(hey){ hey=false; @@ -570,6 +576,7 @@ LOOP2: } } glEnd(); + glDisable(GL_TEXTURE_2D); /* * Draw grass on every line. diff --git a/xcf/dirt.xcf b/xcf/dirt.xcf new file mode 100644 index 0000000..6b50981 Binary files /dev/null and b/xcf/dirt.xcf differ diff --git a/xcf/door.xcf b/xcf/door.xcf index 7965018..ab8e078 100644 Binary files a/xcf/door.xcf and b/xcf/door.xcf differ diff --git a/xcf/maybeplayer.xcf b/xcf/maybeplayer.xcf index 5520815..fb885fc 100644 Binary files a/xcf/maybeplayer.xcf and b/xcf/maybeplayer.xcf differ -- cgit v1.2.3 From 15889a45b8ee37d43e248cec351e9f6882c21ff3 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Wed, 16 Dec 2015 08:48:51 -0500 Subject: new dirt --- Changelog | 9 +++++++++ assets/dirt.png | Bin 578 -> 228 bytes assets/sounds/ozone.wav | Bin 0 -> 12739644 bytes main.cpp | 3 ++- src/entities.cpp | 7 ++++--- src/gameplay.cpp | 4 ++-- src/inventory.cpp | 8 ++++---- src/world.cpp | 23 +++++++++++------------ xcf/dirt.xcf | Bin 1239 -> 757 bytes 9 files changed, 32 insertions(+), 22 deletions(-) create mode 100644 assets/sounds/ozone.wav (limited to 'assets') diff --git a/Changelog b/Changelog index d1fac71..f6f3ca0 100644 --- a/Changelog +++ b/Changelog @@ -426,3 +426,12 @@ - began/continued work on original player sprite - began working on dirt textures + +12/16/2015: +=========== + + - added more soundtracks + - completed dirt texturizing, improved ground shading + - 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) diff --git a/assets/dirt.png b/assets/dirt.png index 04c87b6..11252ac 100644 Binary files a/assets/dirt.png and b/assets/dirt.png differ diff --git a/assets/sounds/ozone.wav b/assets/sounds/ozone.wav new file mode 100644 index 0000000..60354e5 Binary files /dev/null and b/assets/sounds/ozone.wav differ diff --git a/main.cpp b/main.cpp index a9cc2fa..8e154fb 100644 --- a/main.cpp +++ b/main.cpp @@ -494,7 +494,8 @@ void mainLoop(void){ if(++debugDiv==20){ debugDiv=0; - fps=1000/deltaTime; + if(deltaTime) + fps=1000/deltaTime; }else if(!(debugDiv%10)){ debugY = player->loc.y; } diff --git a/src/entities.cpp b/src/entities.cpp index 7ebe744..ba0f8ef 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -107,7 +107,7 @@ NPC::NPC(){ //sets all of the NPC specific traits on object creation tex = new Texturec(1,"assets/NPC.png"); inv = new Inventory(NPC_INV_SIZE); - randDialog = rand() % 10 - 1; + randDialog = rand() % 12 - 1; } NPC::~NPC(){ while(!aiFunc.empty()){ @@ -218,7 +218,7 @@ void Entity::draw(void){ //draws the entities case PLAYERT: static int texState = 0; static bool up = true; - if(loops % (int)((float)4/(float)speed) == 0){ + if(speed && !(loops % (int)(4.0f/(float)speed))){ //currentWorld->addParticle(loc.x,loc.y-HLINE,HLINE,HLINE,0,0,{0.0f,.17f,0.0f},1000); if(up){ if(++texState==2)up=false; @@ -343,7 +343,8 @@ const char *randomDialog[] = { "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." + "Frig.", + "The sine of theta equals the opposite over the hypotenuese." }; void NPC::interact(){ //have the npc's interact back to the player diff --git a/src/gameplay.cpp b/src/gameplay.cpp index 6cfc91e..35abca4 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -109,13 +109,13 @@ void initEverything(void){ worldSpawnHill2 = new World(); worldSpawnHill2->generate(700); worldSpawnHill2->setBackground(BG_FOREST); - worldSpawnHill2->setBGM("assets/music/embark.wav"); + worldSpawnHill2->setBGM("assets/music/ozone.wav"); worldSpawnHill2->addMob(MS_TRIGGER,-400,0,worldSpawnHill2_infoSprint); worldSpawnHill3 = new World(); worldSpawnHill3->generateFunc(1000,gen_worldSpawnHill3); worldSpawnHill3->setBackground(BG_FOREST); - worldSpawnHill3->setBGM("assets/music/embark.wav"); + worldSpawnHill3->setBGM("assets/music/ozone.wav"); worldSpawnHill3->addMob(MS_TRIGGER,-500,0,worldSpawnHill3_itemGet); worldSpawnHill3->addMob(MS_TRIGGER,0,0,worldSpawnHill3_itemSee); worldSpawnHill3->addObject(TEST_ITEM,false,"",-200,300); diff --git a/src/inventory.cpp b/src/inventory.cpp index 52ae02c..c0f4163 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -107,7 +107,7 @@ int Inventory::takeItem(ITEM_ID id,unsigned char count){ void Inventory::draw(void){ static unsigned int lop = 0; - static unsigned int numSlot = 7; + const unsigned int numSlot = 7; static std::vectordfp(numSlot); static std::vectoriray(numSlot); static std::vectorcurCoord(numSlot); @@ -153,7 +153,7 @@ void Inventory::draw(void){ curCoord[a].y += float((dfp[a]) * sin(angle*PI/180)); r.end = curCoord[a]; - glColor4f(0.0f, 0.0f, 0.0f, ((float)dfp[a]/(float)range)*0.5f); + glColor4f(0.0f, 0.0f, 0.0f, ((float)dfp[a]/(float)(range?range:1))*0.5f); glBegin(GL_QUADS); glVertex2i(r.end.x-(itemWide/2), r.end.y-(itemWide/2)); glVertex2i(r.end.x-(itemWide/2)+itemWide, r.end.y-(itemWide/2)); @@ -164,7 +164,7 @@ void Inventory::draw(void){ if(inv[a].count > 0){ glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, itemtex[inv[a].id]); - glColor4f(1.0f, 1.0f, 1.0f, ((float)dfp[a]/(float)range)*0.8f); + glColor4f(1.0f, 1.0f, 1.0f, ((float)dfp[a]/(float)(range?range:1))*0.8f); glBegin(GL_QUADS); if(item[inv[a].id].height > item[inv[a].id].width){ glTexCoord2i(0,1);glVertex2i(r.end.x-((itemWide/2)*((float)item[inv[a].id].width/(float)item[inv[a].id].height)), r.end.y-(itemWide/2)); @@ -203,7 +203,7 @@ void Inventory::draw(void){ mouseSel=true; }else{ if((ui::mouse.x - offset.x) >= mouseStart.x){ - thing = ((ui::mouse.x - offset.x) - mouseStart.x)/80; + thing = (ui::mouse.x - offset.x - mouseStart.x)/80; highlight=sel+thing; if(highlight>numSlot-1)highlight=numSlot-1; if(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT)){ diff --git a/src/world.cpp b/src/world.cpp index 9a2b6d3..d542f2a 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -207,7 +207,7 @@ void World::generate(unsigned int width){ // Generates the world and sets all va * by setting an RGB value of color (red), color - 50 (green), color - 100 (blue). */ - line[i].color = rand() % 20 + 100; // 100 to 120 + line[i].color = rand() % 32 / 8; // 100 to 120 /* * Each line has two 'blades' of grass, here we generate random heights for them. @@ -551,24 +551,23 @@ LOOP2: bool hey=false; glEnable(GL_TEXTURE_2D); + bgTex->bindNext(); 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 - bgTex->bindNext(); glBegin(GL_QUADS); + std::cout< Date: Thu, 17 Dec 2015 09:25:22 -0500 Subject: indoors, fixed npcs --- Changelog | 9 +++++++++ assets/bgWoodTile.png | Bin 65078 -> 75181 bytes assets/maybeplayer.png | Bin 2898 -> 4146 bytes assets/sounds/ozone.wav | Bin 12739644 -> 0 bytes include/entities.h | 8 +++++--- include/world.h | 4 ++-- main.cpp | 3 ++- src/entities.cpp | 8 +++++--- src/gameplay.cpp | 16 +++++++++++----- src/world.cpp | 38 ++++++++++++++++++++++---------------- xcf/bgWoodTile.xcf | Bin 511093 -> 511349 bytes xcf/maybeplayer.xcf | Bin 7564 -> 3468 bytes 12 files changed, 56 insertions(+), 30 deletions(-) delete mode 100644 assets/sounds/ozone.wav (limited to 'assets') diff --git a/Changelog b/Changelog index f6f3ca0..6d5fa3b 100644 --- a/Changelog +++ b/Changelog @@ -435,3 +435,12 @@ - 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 diff --git a/assets/bgWoodTile.png b/assets/bgWoodTile.png index 0c7c64b..5b631bf 100644 Binary files a/assets/bgWoodTile.png and b/assets/bgWoodTile.png differ diff --git a/assets/maybeplayer.png b/assets/maybeplayer.png index ee0e49d..c580ff7 100644 Binary files a/assets/maybeplayer.png and b/assets/maybeplayer.png differ diff --git a/assets/sounds/ozone.wav b/assets/sounds/ozone.wav deleted file mode 100644 index 60354e5..0000000 Binary files a/assets/sounds/ozone.wav and /dev/null differ diff --git a/include/entities.h b/include/entities.h index 1abe886..6d192fe 100644 --- a/include/entities.h +++ b/include/entities.h @@ -44,6 +44,8 @@ enum BUILD_SUB{ FOUNTAIN }; +class World; + class Particles{ public: vec2 loc; @@ -162,14 +164,14 @@ public: 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{ diff --git a/include/world.h b/include/world.h index 0a23965..4b3a891 100644 --- a/include/world.h +++ b/include/world.h @@ -166,8 +166,8 @@ public: std::vector object; std::vector 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); diff --git a/main.cpp b/main.cpp index 8e154fb..0651077 100644 --- a/main.cpp +++ b/main.cpp @@ -4,6 +4,7 @@ */ #include // fopen +#include #include #include @@ -453,7 +454,7 @@ void mainLoop(void){ if(!currentTime){ // Initialize currentTime if it hasn't been currentTime=millis(); - prevPrevTime=currentTime; + //prevPrevTime=currentTime; } /* diff --git a/src/entities.cpp b/src/entities.cpp index ba0f8ef..7cd413c 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -77,7 +77,7 @@ void Entity::spawn(float x, float y){ //spawns the entity you pass to it based o 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; @@ -393,7 +393,7 @@ void Object::interact(void){ * 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; @@ -404,6 +404,8 @@ unsigned int Structures::spawn(_TYPE t, BUILD_SUB sub, float x, float y){ 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. @@ -418,7 +420,7 @@ unsigned int Structures::spawn(_TYPE t, BUILD_SUB sub, float x, float y){ * with type NPC. */ - currentWorld->addNPC(loc.x + i * HLINE ,100); + inWorld->addNPC(loc.x + i * HLINE ,100); } diff --git a/src/gameplay.cpp b/src/gameplay.cpp index 35abca4..2361029 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -93,6 +93,8 @@ static World *worldSpawnHill1; static World *worldSpawnHill2; static World *worldSpawnHill3; +static IndoorWorld *worldSpawnHill2_Building1; + /* * initEverything() start */ @@ -119,7 +121,7 @@ void initEverything(void){ 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; @@ -140,14 +142,18 @@ void initEverything(void){ //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); } diff --git a/src/world.cpp b/src/world.cpp index d542f2a..7f9b1c0 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -555,7 +555,6 @@ LOOP2: 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<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++){ @@ -922,7 +922,7 @@ void World::addVillage(int bCount, int npcMin, int npcMax,_TYPE t,float x,float 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){ @@ -1095,7 +1095,8 @@ void IndoorWorld::generate(unsigned int width){ // Generates a flat area of wid void IndoorWorld::draw(Player *p){ unsigned int i,ie; - int j,x,v_offset; + //int j,x,v_offset; + int x; /* * Draw the background. @@ -1104,15 +1105,17 @@ void IndoorWorld::draw(Player *p){ 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); @@ -1121,13 +1124,16 @@ void IndoorWorld::draw(Player *p){ * 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. diff --git a/xcf/bgWoodTile.xcf b/xcf/bgWoodTile.xcf index 9aa0005..867e556 100644 Binary files a/xcf/bgWoodTile.xcf and b/xcf/bgWoodTile.xcf differ diff --git a/xcf/maybeplayer.xcf b/xcf/maybeplayer.xcf index fb885fc..c16b7c6 100644 Binary files a/xcf/maybeplayer.xcf and b/xcf/maybeplayer.xcf differ -- cgit v1.2.3 From 1b2510a427cea42e6381d60f434b5fdec2b181b0 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Thu, 17 Dec 2015 20:33:50 -0500 Subject: fork tests, revised song --- Makefile | 2 +- assets/music/theme_jazz.wav | Bin 13193260 -> 13193260 bytes main.cpp | 5 +++++ src/entities.cpp | 8 +++++++- src/gameplay.cpp | 1 + src/ui.cpp | 2 +- 6 files changed, 15 insertions(+), 3 deletions(-) (limited to 'assets') diff --git a/Makefile b/Makefile index e48afa6..6eeca1a 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ all: @rm -f out64/*.o @cd src; $(MAKE) $(MFLAGS64) @echo " CXX main.cpp" - @g++ $(FLAGS) -m64 -o main main.cpp out64/*.o $(LIBS) + @g++ $(FLAGS) -m64 -o main main.cpp out64/*.o $(LIBS) -lX11 win32: @g++ $(FLAGS) -o main main.cpp src/*.cpp $(WIN_LIBS) diff --git a/assets/music/theme_jazz.wav b/assets/music/theme_jazz.wav index 1c62bbc..94f888e 100644 Binary files a/assets/music/theme_jazz.wav and b/assets/music/theme_jazz.wav differ diff --git a/main.cpp b/main.cpp index 0651077..7eaaa84 100644 --- a/main.cpp +++ b/main.cpp @@ -199,9 +199,14 @@ extern int fadeIntensity; * MAIN ************************************************************************ *******************************************************************************/ +#include + int main(/*int argc, char *argv[]*/){ //*argv = (char *)argc; gameRunning=false; + + XInitThreads(); + /*! * (Attempt to) Initialize SDL libraries so that we can use SDL facilities and eventually * make openGL calls. Exit if there was an error. diff --git a/src/entities.cpp b/src/entities.cpp index 7cd413c..c307a31 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -1,6 +1,8 @@ #include #include +#include + extern FILE* names; extern unsigned int loops; @@ -462,7 +464,11 @@ void Mob::wander(int timeRun){ case MS_TRIGGER: if(player->loc.x + player->width / 2 > loc.x && player->loc.x + player->width / 2 < loc.x + width ){ - hey(this); + //if(!vfork()){ + hey(this); + /*_exit(0); + }*/ + } break; case MS_DOOR: diff --git a/src/gameplay.cpp b/src/gameplay.cpp index 2361029..ba2c8d9 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -42,6 +42,7 @@ float gen_worldSpawnHill3(float x){ */ void worldSpawnHill1_hillBlock(Mob *callee){ + std::cout<<"oi"; player->vel.x = 0; player->loc.x = callee->loc.x + callee->width; ui::dialogBox(player->name,NULL,false,"This hill seems to steep to climb up..."); diff --git a/src/ui.cpp b/src/ui.cpp index 08f503f..6069ef9 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -512,7 +512,7 @@ namespace ui { glVertex2f(x+1+SCREEN_WIDTH-HLINE*16,y+1); glVertex2f(x+1+SCREEN_WIDTH-HLINE*16,y-1-SCREEN_HEIGHT/4); glVertex2f(x-1 ,y-1-SCREEN_HEIGHT/4); - glVertex2f(x-1 ,y+2); + glVertex2f(x ,y+1); glEnd(); glColor3ub(0,0,0); -- cgit v1.2.3 From 0b9561febb7677de8792ba0feb056139ba7c94ea Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Fri, 18 Dec 2015 08:45:29 -0500 Subject: pages --- Changelog | 8 ++++++++ Makefile | 5 +++-- assets/items/ITEM_PAGE.png | Bin 0 -> 331 bytes include/entities.h | 3 ++- main.cpp | 7 ++----- src/entities.cpp | 22 ++++++++++++++++++++-- src/gameplay.cpp | 31 ++++++++++++++++++++++--------- xcf/page.xcf | Bin 0 -> 1059 bytes 8 files changed, 57 insertions(+), 19 deletions(-) create mode 100644 assets/items/ITEM_PAGE.png create mode 100644 xcf/page.xcf (limited to 'assets') diff --git a/Changelog b/Changelog index 6d5fa3b..44ff8a4 100644 --- a/Changelog +++ b/Changelog @@ -444,3 +444,11 @@ - fixed NPC spawning world location stuff - messed with threads/forks - re-fixed/added indoor environment; fixed indoor background + +12/18/2015: +=========== + + - upgraded development utilities + - began working on pages, made sprite and handler + - GLSL shaders are better + - redid theme_jazz diff --git a/Makefile b/Makefile index 6eeca1a..81862c0 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,7 @@ WIN_LIBS = -lopengl32 -lglew32 -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_m FLAGS = -std=c++11 -Iinclude -Iinclude/freetype2 -Wall -Wextra -Werror MFLAGS64 = 64 + all: @echo "Building for 32-bit target" @rm -f out/*.o @@ -17,11 +18,11 @@ all: @rm -f out64/*.o @cd src; $(MAKE) $(MFLAGS64) @echo " CXX main.cpp" - @g++ $(FLAGS) -m64 -o main main.cpp out64/*.o $(LIBS) -lX11 + @g++ $(FLAGS) -m64 -o main main.cpp out64/*.o $(LIBS) win32: @g++ $(FLAGS) -o main main.cpp src/*.cpp $(WIN_LIBS) - + clean: @echo " RM main" @-rm -f main diff --git a/assets/items/ITEM_PAGE.png b/assets/items/ITEM_PAGE.png new file mode 100644 index 0000000..ac132c6 Binary files /dev/null and b/assets/items/ITEM_PAGE.png differ diff --git a/include/entities.h b/include/entities.h index 6d192fe..6b8cc32 100644 --- a/include/entities.h +++ b/include/entities.h @@ -32,7 +32,8 @@ enum MOB_SUB { MS_RABBIT = 1, MS_BIRD, MS_TRIGGER, - MS_DOOR + MS_DOOR, + MS_PAGE }; enum BUILD_SUB{ diff --git a/main.cpp b/main.cpp index 7eaaa84..e5aba88 100644 --- a/main.cpp +++ b/main.cpp @@ -198,15 +198,11 @@ extern int fadeIntensity; /******************************************************************************* * MAIN ************************************************************************ *******************************************************************************/ - -#include - + int main(/*int argc, char *argv[]*/){ //*argv = (char *)argc; gameRunning=false; - XInitThreads(); - /*! * (Attempt to) Initialize SDL libraries so that we can use SDL facilities and eventually * make openGL calls. Exit if there was an error. @@ -905,6 +901,7 @@ void logic(){ m->wander((rand()%240 + 15)); // Make the mob wander :) break; case MS_TRIGGER: + case MS_PAGE: m->wander(0); break; case MS_DOOR: diff --git a/src/entities.cpp b/src/entities.cpp index c307a31..23a4ae6 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -1,7 +1,7 @@ #include #include -#include +//#include extern FILE* names; extern unsigned int loops; @@ -153,15 +153,22 @@ Mob::Mob(int sub){ width = HLINE * 8; height = HLINE * 8; tex = new Texturec(1, "assets/robin.png"); + break; case MS_TRIGGER: width = HLINE * 20; height = 2000; tex = new Texturec(0); + break; case MS_DOOR: width = HLINE * 12; height = HLINE * 19; tex = new Texturec(1,"assets/door.png"); break; + case MS_PAGE: + width = HLINE * 6; + height = HLINE * 4; + tex = new Texturec(1,"assets/items/ITEM_PAGE.png"); + break; } inv = new Inventory(NPC_INV_SIZE); @@ -248,6 +255,7 @@ void Entity::draw(void){ //draws the entities break; case MS_BIRD: case MS_DOOR: + case MS_PAGE: default: tex->bind(0); break; @@ -471,7 +479,17 @@ void Mob::wander(int timeRun){ } break; - case MS_DOOR: + case MS_PAGE: + if(ui::mouse.x > loc.x && + ui::mouse.x < loc.x + width && + SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_RIGHT)){ + if(speed != 666){ + speed = 666; + hey(this); + speed = 0; + } + } + break; default: break; } diff --git a/src/gameplay.cpp b/src/gameplay.cpp index ba2c8d9..1670929 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -51,14 +51,27 @@ void worldSpawnHill1_hillBlock(Mob *callee){ static Arena *a; void worldSpawnHill2_infoSprint(Mob *callee){ - callee->alive = false; - a = new Arena(currentWorld,player); - a->setBackground(BG_FOREST); - a->setBGM("assets/music/embark.wav"); - ui::toggleWhiteFast(); - ui::waitForCover(); - currentWorld = a; - ui::toggleWhiteFast(); + + ui::dialogBox(player->name,":Nah:Sure",false,"This page would like to take you somewhere."); + ui::waitForDialog(); + switch(ui::dialogOptChosen){ + case 1: + ui::dialogBox(player->name,NULL,true,"Cool."); + callee->alive = false; + a = new Arena(currentWorld,player); + a->setBackground(BG_FOREST); + a->setBGM("assets/music/embark.wav"); + ui::toggleWhiteFast(); + ui::waitForCover(); + currentWorld = a; + ui::toggleWhiteFast(); + break; + case 2: + default: + ui::dialogBox(player->name,NULL,false,"Okay then."); + break; + } + //ui::dialogBox("B-) ",NULL,true,"Press \'Shift\' to run!"); } @@ -113,7 +126,7 @@ void initEverything(void){ worldSpawnHill2->generate(700); worldSpawnHill2->setBackground(BG_FOREST); worldSpawnHill2->setBGM("assets/music/ozone.wav"); - worldSpawnHill2->addMob(MS_TRIGGER,-400,0,worldSpawnHill2_infoSprint); + worldSpawnHill2->addMob(MS_PAGE,-400,0,worldSpawnHill2_infoSprint); worldSpawnHill3 = new World(); worldSpawnHill3->generateFunc(1000,gen_worldSpawnHill3); diff --git a/xcf/page.xcf b/xcf/page.xcf new file mode 100644 index 0000000..bf39c18 Binary files /dev/null and b/xcf/page.xcf differ -- cgit v1.2.3 From 272a152b54a198a84f122ab8bedb1019708b7008 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Mon, 21 Dec 2015 08:46:35 -0500 Subject: pages, quests --- Changelog | 8 ++++++++ assets/items/ITEM_PAGE.png | Bin 331 -> 349 bytes include/common.h | 17 +++++++++++++++++ include/world.h | 6 ++++++ main.cpp | 12 ++++++++---- src/common.cpp | 17 +++++++++++++++++ src/entities.cpp | 44 ++++++++++++++++++++------------------------ src/gameplay.cpp | 37 ++++++++++++++++++++----------------- src/ui.cpp | 15 ++++++++------- src/world.cpp | 8 ++++++++ xcf/page.xcf | Bin 1059 -> 1059 bytes 11 files changed, 112 insertions(+), 52 deletions(-) (limited to 'assets') diff --git a/Changelog b/Changelog index 44ff8a4..c0d2b9e 100644 --- a/Changelog +++ b/Changelog @@ -452,3 +452,11 @@ - began working on pages, made sprite and handler - GLSL shaders are better - redid theme_jazz + +12/21/2015: +=========== + + - fixed dialog options issues, finished basic pages + - added World::getAvailableNPC() for easy quest assigner assigning + - added the Condition class, so that events and actions can be remembered by NPCs + - added functionality for multiple lights (GLSL) diff --git a/assets/items/ITEM_PAGE.png b/assets/items/ITEM_PAGE.png index ac132c6..4602afe 100644 Binary files a/assets/items/ITEM_PAGE.png and b/assets/items/ITEM_PAGE.png differ diff --git a/include/common.h b/include/common.h index 08ec73f..038bf42 100644 --- a/include/common.h +++ b/include/common.h @@ -141,6 +141,23 @@ extern vec2 offset; */ extern unsigned int loops; +/** + * This class contains a string for identification and a value. It can be used to + * save certain events for and decisions so that they can be recalled later. + */ + +class Condition { +private: + char *id; + void *value; +public: + Condition(const char *_id,void *val); + ~Condition(); + + bool sameID(const char *s); + void *getValue(void); +}; + /** * Prints a formatted debug message to the console, along with the callee's file and line * number. diff --git a/include/world.h b/include/world.h index 4b3a891..98ca54a 100644 --- a/include/world.h +++ b/include/world.h @@ -173,6 +173,12 @@ public: void addNPC(float x,float y); void addObject(ITEM_ID, bool, const char *, float, float); void addParticle(float, float, float, float, float, float, Color color, int); + + NPC *getAvailableNPC(void); + + /* + * Update coordinates of all entities. + */ void update(Player *p,unsigned int delta); diff --git a/main.cpp b/main.cpp index e5aba88..e6ff2eb 100644 --- a/main.cpp +++ b/main.cpp @@ -3,7 +3,8 @@ The main game loop contains all of the global variables the game uses, and it runs the main game loop, the render loop, and the logic loop that control all of the entities. */ -#include // fopen +#include +#include #include #include @@ -123,7 +124,7 @@ Mix_Chunk *crickets; * referenced in src/entities.cpp for getting random names. */ -FILE *names; +std::istream *names; /* * loops is used for texture animation. It is believed to be passed to entity @@ -387,7 +388,10 @@ int main(/*int argc, char *argv[]*/){ * */ - names = fopen("assets/names_en-us", "r+"); + static std::filebuf fb; + fb.open("assets/names_en-us",std::ios::in); + names = new std::istream(&fb); + crickets=Mix_LoadWAV("assets/sounds/crickets.wav"); //Mix_Volume(2,25); @@ -427,7 +431,7 @@ int main(/*int argc, char *argv[]*/){ Mix_HaltMusic(); - fclose(names); + fb.close(); SDL_GL_DeleteContext(mainGLContext); SDL_DestroyWindow(window); diff --git a/src/common.cpp b/src/common.cpp index 7449a35..dbcef0b 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -1,4 +1,5 @@ #include +#include #include #include @@ -11,6 +12,22 @@ unsigned int millis(void){ #endif // __WIN32__ +Condition::Condition(const char *_id,void *val){ + id = new char[strlen(_id)+1]; + strcpy(id,_id); + value = val; +} +Condition::~Condition(){ + delete[] id; +} + +bool Condition::sameID(const char *s){ + return !strcmp(id,s); +} +void *Condition::getValue(void){ + return value; +} + void DEBUG_prints(const char* file, int line, const char *s,...){ va_list args; printf("%s:%d: ",file,line); diff --git a/src/entities.cpp b/src/entities.cpp index 23a4ae6..3849040 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -1,9 +1,10 @@ #include #include +#include //#include -extern FILE* names; +extern std::istream *names; extern unsigned int loops; extern World *currentWorld; @@ -12,39 +13,30 @@ extern Player *player; extern const char *itemName; -extern - void getRandomName(Entity *e){ - int tempNum,max=0; + unsigned int tempNum,max=0; char *bufs; - rewind(names); + names->seekg(0,names->beg); - bufs = new char[16]; //(char *)malloc(16); + bufs = new char[32]; - for(;!feof(names);max++){ - fgets(bufs,16,(FILE*)names); - } + for(;!names->eof();max++) + names->getline(bufs,32); tempNum = rand() % max; - rewind(names); + names->seekg(0,names->beg); - for(int i=0;igetline(bufs,32); - switch(fgetc(names)){ + switch(bufs[0]){ + default : case 'm': e->gender = MALE; break; case 'f': e->gender = FEMALE;break; - default : break; } - if((fgets(bufs,16,(FILE*)names)) != NULL){ - bufs[strlen(bufs)] = '\0'; - strcpy(e->name,bufs); - if(e->name[strlen(e->name)-1] == '\n') - e->name[strlen(e->name)-1] = '\0'; - } + strcpy(e->name,bufs+1); delete[] bufs; } @@ -73,7 +65,7 @@ void Entity::spawn(float x, float y){ //spawns the entity you pass to it based o } } - name = new char[16]; + name = new char[32]; getRandomName(this); } @@ -480,8 +472,12 @@ void Mob::wander(int timeRun){ } break; case MS_PAGE: - if(ui::mouse.x > loc.x && - ui::mouse.x < loc.x + width && + if(player->loc.x > loc.x - 100 && + player->loc.x < loc.x + 100 && + ui::mouse.x > loc.x && + ui::mouse.x < loc.x + width && + ui::mouse.y > loc.y - width / 2 && + ui::mouse.y < loc.y + width * 1.5 && SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_RIGHT)){ if(speed != 666){ speed = 666; diff --git a/src/gameplay.cpp b/src/gameplay.cpp index 1670929..7dbe98e 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -28,6 +28,10 @@ void story(Mob *callee){ callee->alive = false; } +/* + * Gens + */ + float gen_worldSpawnHill1(float x){ return (float)(pow(2,(-x+200)/5) + GEN_MIN); } @@ -42,7 +46,6 @@ float gen_worldSpawnHill3(float x){ */ void worldSpawnHill1_hillBlock(Mob *callee){ - std::cout<<"oi"; player->vel.x = 0; player->loc.x = callee->loc.x + callee->width; ui::dialogBox(player->name,NULL,false,"This hill seems to steep to climb up..."); @@ -52,7 +55,7 @@ void worldSpawnHill1_hillBlock(Mob *callee){ static Arena *a; void worldSpawnHill2_infoSprint(Mob *callee){ - ui::dialogBox(player->name,":Nah:Sure",false,"This page would like to take you somewhere."); + ui::dialogBox(player->name,":Sure:Nah",false,"This page would like to take you somewhere."); ui::waitForDialog(); switch(ui::dialogOptChosen){ case 1: @@ -75,19 +78,22 @@ void worldSpawnHill2_infoSprint(Mob *callee){ //ui::dialogBox("B-) ",NULL,true,"Press \'Shift\' to run!"); } -void worldSpawnHill3_itemGet(Mob *callee){ - ui::dialogBox("B-) ",NULL,true,"Right click to pick up items!"); - callee->alive = false; -} - -void worldSpawnHill3_itemSee(Mob *callee){ - ui::dialogBox("B-) ",NULL,true,"Press \'e\' to open your inventory!"); - callee->alive = false; +int worldSpawnHill2_Quest2(NPC *callee){ + ui::dialogBox(callee->name,NULL,false,"Yo."); + ui::waitForDialog(); + return 0; } -void worldSpawnHill3_leave(Mob *callee){ - ui::dialogBox("B-) ",NULL,true,"Now jump in this hole, and let your journey begin :)"); - callee->alive = false; +int worldSpawnHill2_Quest1(NPC *callee){ + ui::dialogBox(callee->name,":Cool.",false,"Did you know that I\'m the coolest NPC in the world?"); + ui::waitForDialog(); + if(ui::dialogOptChosen == 1){ + ui::dialogBox(callee->name,NULL,false,"Yeah, it is."); + currentWorld->getAvailableNPC()->addAIFunc(worldSpawnHill2_Quest2,true); + ui::waitForDialog(); + return 0; + } + return 1; } /* @@ -132,10 +138,6 @@ void initEverything(void){ worldSpawnHill3->generateFunc(1000,gen_worldSpawnHill3); worldSpawnHill3->setBackground(BG_FOREST); worldSpawnHill3->setBGM("assets/music/ozone.wav"); - 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,650,0,worldSpawnHill3_leave); worldSpawnHill3->addHole(800,1000); worldSpawnHill1->toRight = worldSpawnHill2; @@ -162,6 +164,7 @@ void initEverything(void){ worldSpawnHill2_Building1->setBGM("assets/music/theme_jazz.wav"); worldSpawnHill2->addStructure(STRUCTURET,HOUSE,(rand()%120*HLINE),100,worldSpawnHill2_Building1); + worldSpawnHill2->getAvailableNPC()->addAIFunc(worldSpawnHill2_Quest1,false); player = new Player(); player->spawn(200,100); diff --git a/src/ui.cpp b/src/ui.cpp index 6069ef9..f73f48a 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -300,7 +300,8 @@ namespace ui { } }while(s[++i]); - return putString(x-width/2,y,s); + putString(x-width/2,y,s); + return width; } /* @@ -487,7 +488,7 @@ namespace ui { } void draw(void){ unsigned char i; - float x,y; + float x,y,tmp; char *rtext; if(dialogBoxExists){ @@ -524,12 +525,12 @@ namespace ui { for(i=0;i dialogOptLoc[i][0] && - mouse.x < dialogOptLoc[i][0] + dialogOptLoc[i][2] && + mouse.x < dialogOptLoc[i][2] && mouse.y > dialogOptLoc[i][1] && mouse.y < dialogOptLoc[i][1] + 16 ){ // fontSize setFontColor(255,255,0); diff --git a/src/world.cpp b/src/world.cpp index 7f9b1c0..5663086 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -980,6 +980,14 @@ void World::addLayer(unsigned int width){ behind->bgTex=bgTex; } +NPC *World::getAvailableNPC(void){ + for(auto &n : npc){ + if(n->aiFunc.empty()) + return n; + } + return (NPC *)NULL; +} + World *World::goWorldLeft(Player *p){ if(toLeft&&p->loc.xloc.x=toLeft->x_start+getWidth(toLeft)-HLINE*10; diff --git a/xcf/page.xcf b/xcf/page.xcf index bf39c18..72a34cf 100644 Binary files a/xcf/page.xcf and b/xcf/page.xcf differ -- cgit v1.2.3