]> code.bitgloo.com Git - clyne/gamedev.git/commitdiff
music/merge
authorClyne Sullivan <tullivan99@gmail.com>
Wed, 16 Dec 2015 12:27:06 +0000 (07:27 -0500)
committerClyne Sullivan <tullivan99@gmail.com>
Wed, 16 Dec 2015 12:27:06 +0000 (07:27 -0500)
16 files changed:
Changelog
assets/dirt.png [new file with mode: 0644]
assets/door.png
assets/maybeplayer.png [new file with mode: 0644]
include/common.h
include/ui.h
main.cpp
src/common.cpp
src/entities.cpp
src/gameplay.cpp
src/inventory.cpp
src/ui.cpp
src/world.cpp
xcf/dirt.xcf [new file with mode: 0644]
xcf/door.xcf
xcf/maybeplayer.xcf

index c894c5c788d2224795e7c6b62cd734a6dfcc512a..d1fac717a36c823fb98f548a7168259c6867f533 100644 (file)
--- a/Changelog
+++ b/Changelog
        - 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 (file)
index 0000000..04c87b6
Binary files /dev/null and b/assets/dirt.png differ
index 2a8b0dd975859b9424580d4c205b3b1707b65f7d..582a52db08636df48a49a0b33591e742f658ead5 100644 (file)
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 (file)
index 0000000..ee0e49d
Binary files /dev/null and b/assets/maybeplayer.png differ
index 31126d7a70503dfb38a3cada9ff31e081315713a..08ec73f625cf758d2a3efa1577d22c08680b881d 100644 (file)
@@ -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 <chrono> 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
index 5d17c47edcede3914bce228d6538659a7e16189c..6a81dab5627e21f7ce0b8c3118d3cbf37c7d1717 100644 (file)
@@ -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
index 5b9b1b60238ba4234e00431dd9c2fcd928618f54..a9cc2fa969f484dfc37332da7ea7d4f84ee4e3a6 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -4,7 +4,6 @@
 */
 
 #include <cstdio> // fopen
-#include <chrono> // see millis()
 
 #include <common.h>
 #include <world.h>
@@ -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 <chrono> 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<std::chrono::milliseconds>(now.time_since_epoch()).count();
-}
-#endif
-
 extern WEATHER weather;
 
 extern bool fadeEnable;
index a8a964e2301af30defecbf6809573473d289072e..7449a35ddccc3cdb153472671bf72f07c1bcad1e 100644 (file)
@@ -1,7 +1,15 @@
 #include <common.h>
 #include <cstdio>
+#include <chrono>
 
-#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<std::chrono::milliseconds>(now.time_since_epoch()).count();
+}
+
+#endif // __WIN32__
 
 void DEBUG_prints(const char* file, int line, const char *s,...){
        va_list args;
index 24c0d01054fe7b9ba1139f8f708b5adc5ee4c83a..7ebe7447f1387260014d1500ff1fe759aa948dd7 100644 (file)
@@ -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;
        }
index 0ee6055f3a97574877fd25d182d86ee4c19d2727..d3dd03a4131c66a3343988a0471b1be3d0cc8a83 100644 (file)
@@ -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);
index 5ae97b41610080b499de0e18b808bd99283c8188..52ae02cb739d28a597799c957e546da21c7e3b2a 100644 (file)
@@ -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;
                }
        }
index 11bc1950aab23b76d7e0f2324bb6b979d5929247..08f503f1f5baf64016639cb67b03ca34e960b83b 100644 (file)
@@ -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;
                
index b964c9a54ba1b2c66a6d11e822034c4c6d56073b..9a2b6d376d1f9bbe404a74298eae5ea22a8d0d74 100644 (file)
@@ -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 (file)
index 0000000..6b50981
Binary files /dev/null and b/xcf/dirt.xcf differ
index 796501889b1b7676a7b1372dc28304477eda465c..ab8e07806394070e38971abaccd36c1178e224f4 100644 (file)
Binary files a/xcf/door.xcf and b/xcf/door.xcf differ
index 55208156a2f7e558cf7e7a837265e1c635ab4ec0..fb885fc1f914471fcfe966b23f9a05986bb979ec 100644 (file)
Binary files a/xcf/maybeplayer.xcf and b/xcf/maybeplayer.xcf differ