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 src/gameplay.cpp | 2 +- src/world.cpp | 9 ++++----- 5 files changed, 5 insertions(+), 6 deletions(-) create mode 100644 assets/music/ozone.wav create mode 100644 assets/music/theme.wav create mode 100644 assets/music/theme_jazz.wav 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 diff --git a/src/gameplay.cpp b/src/gameplay.cpp index 69ae2cc..0ee6055 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -109,7 +109,7 @@ 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(); diff --git a/src/world.cpp b/src/world.cpp index 1b460a2..b964c9a 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -344,13 +344,12 @@ void World::setBGM(const char *path){ } } -void World::bgmPlay(World *prev){ - if(!prev || strcmp(bgm,prev->bgm)){ +void World::bgmPlay(World *prev){ + if(prev && strcmp(bgm,prev->bgm)){ + Mix_FadeOutMusic(800); Mix_VolumeMusic(50); Mix_PlayMusic(bgmObj,-1); // Loop infinitely - }/*else{ - Mix_FadeOutMusic(800); - }*/ + } } int worldShade = 0; -- 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 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 2286361ea87b42e73ec2f544265c5fd5e1b5713b Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Wed, 16 Dec 2015 07:28:01 -0500 Subject: music --- src/gameplay.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gameplay.cpp b/src/gameplay.cpp index d3dd03a..6cfc91e 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -109,7 +109,7 @@ void initEverything(void){ worldSpawnHill2 = new World(); worldSpawnHill2->generate(700); worldSpawnHill2->setBackground(BG_FOREST); - worldSpawnHill2->setBGM("assets/music/ozone.wav"); + worldSpawnHill2->setBGM("assets/music/embark.wav"); worldSpawnHill2->addMob(MS_TRIGGER,-400,0,worldSpawnHill2_infoSprint); worldSpawnHill3 = new World(); -- cgit v1.2.3