aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2016-04-11 08:46:43 -0400
committerClyne Sullivan <tullivan99@gmail.com>2016-04-11 08:46:43 -0400
commit5c48f10a46e470493328978d6ccee8722c743f31 (patch)
treefc01f93915327d1136b698d5e995c01c538828bd /include
parent75a344b842d534830d7d420c7fd6fda6ad33e625 (diff)
merchant revision
Diffstat (limited to 'include')
-rw-r--r--include/common.hpp13
-rw-r--r--include/entities.hpp47
-rw-r--r--include/ui.hpp4
-rw-r--r--include/world.hpp6
4 files changed, 46 insertions, 24 deletions
diff --git a/include/common.hpp b/include/common.hpp
index c9837dd..a62d75a 100644
--- a/include/common.hpp
+++ b/include/common.hpp
@@ -35,6 +35,19 @@ typedef unsigned int uint;
#undef near
#endif
+/**
+ * Defines how many game ticks should occur in one second, affecting how often
+ * game logic is handled.
+ */
+
+#define TICKS_PER_SEC 20
+
+/**
+ * Defines how many milliseconds each game tick will take.
+ */
+
+#define MSEC_PER_TICK ( 1000 / TICKS_PER_SEC )
+
//#define SEGFAULT
/**
diff --git a/include/entities.hpp b/include/entities.hpp
index 3bc2f98..5ab4066 100644
--- a/include/entities.hpp
+++ b/include/entities.hpp
@@ -56,15 +56,7 @@ class Trade{
public:
std::string item[2];
int quantity[2];
- Trade(int qo, const char* o, int qt, const char* t){
- item[0] = o;
- item[1] = t;
-
- quantity[0] = qo;
- quantity[1] = qt;
-
- std::cout << "Trading: " << quantity[0] << " " << item[0] << " for " << quantity[1] << " " << item[1] << std::endl;
- }
+ Trade(int qo, std::string o, int qt, std::string t);
Trade(){}
};
@@ -75,8 +67,7 @@ public:
vec2 loc;
float width;
float height;
- float velx;
- float vely;
+ vec2 vel;
Color color;
vec2 index;
float duration;
@@ -84,25 +75,25 @@ public:
bool fountain;
bool gravity;
bool behind;
+ bool bounce;
Particles(float x, float y, float w, float h, float vx, float vy, Color c, float d){
loc.x = x;
loc.y = y;
+ vel.x = vx;
+ vel.y = vy;
width = w;
height = h;
- velx = vx;
- vely = vy;
color = c;
duration = d;
fountain = false;
gravity = true;
behind = false;
+ bounce = false;
index = Texture::getIndex(c);
}
~Particles(){
-
}
void draw(){
- //glEnable(GL_TEXTURE_2D);
glColor3ub(255,255,255);
glBegin(GL_QUADS);
glTexCoord2f(.25*index.x, .125*index.y); glVertex2i(loc.x, loc.y);
@@ -110,15 +101,23 @@ public:
glTexCoord2f(.25*index.x, .125*index.y); glVertex2i(loc.x + width, loc.y + height);
glTexCoord2f(.25*index.x, .125*index.y); glVertex2i(loc.x, loc.y + width);
glEnd();
- //glDisable(GL_TEXTURE_2D);
- //glUseProgram(0);
+ }
+ void update( float _gravity, float ground_y ) {
+ // handle ground collision
+ if ( loc.y < ground_y ) {
+ loc.y = ground_y;
+ if ( bounce ) {
+ vel.y *= -0.2f;
+ vel.x /= 4;
+ } else {
+ vel.x = vel.y = 0;
+ canMove = false;
+ }
+ } else if ( gravity && vel.y > -1 )
+ vel.y -= _gravity * deltaTime;
}
bool kill(float delta){
- duration -= delta;
- if(duration <= 0.0f){
- return true;
- }
- else return false;
+ return (duration -= delta) <= 0;
}
};
@@ -141,6 +140,8 @@ public:
float speed; // A speed factor for X movement
+ unsigned int hitCooldown;
+
/*
* Movement flags
*/
@@ -229,7 +230,7 @@ public:
virtual void wander(int);
};
-class Merchant : public NPC{
+class Merchant : public NPC {
public:
std::vector<Trade>trade;
uint currTrade;
diff --git a/include/ui.hpp b/include/ui.hpp
index 0142f6f..a9a7f05 100644
--- a/include/ui.hpp
+++ b/include/ui.hpp
@@ -154,9 +154,11 @@ namespace ui {
void merchantBox();
void closeBox();
void waitForDialog(void);
- bool pageExists( void );
+ bool pageExists( void );
void drawPage( std::string path );
+
+ void dontTypeOut( void );
/*
* Draws a larger string in the center of the screen. Drawing is done inside this function.
*/
diff --git a/include/world.hpp b/include/world.hpp
index 40e4a38..cae3808 100644
--- a/include/world.hpp
+++ b/include/world.hpp
@@ -20,6 +20,12 @@
#define PLAYER_SPEED_CONSTANT 0.15f
/**
+ * Gravity thing
+ */
+
+#define GRAVITY_CONSTANT 0.001f
+
+/**
* Defines how many game ticks it takes for a day to elapse.
*/