aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common.cpp2
-rw-r--r--src/entities.cpp40
-rw-r--r--src/ui.cpp3
3 files changed, 39 insertions, 6 deletions
diff --git a/src/common.cpp b/src/common.cpp
index 124d999..62dc6af 100644
--- a/src/common.cpp
+++ b/src/common.cpp
@@ -19,7 +19,7 @@ GLuint loadTexture(const char *fileName){
SDL_Surface *image = IMG_Load(fileName);
//SDL_DisplayFormatAlpha(image);
-
+
unsigned object(0);
glGenTextures(1, &object);
diff --git a/src/entities.cpp b/src/entities.cpp
index 46d445b..0ca2284 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -42,7 +42,33 @@ void Entity::draw(void){ //draws the entities
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glEnable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D,texture);
+ if(type == PLAYERT){
+ static int texState = 0;
+ static bool up = true;
+ if(loops % (int)((float)5 / (float)speed) == 0){
+ if(up){
+ texState+=1;
+ if(texState==2)up=false;
+ }else if(!up){
+ texState-=1;
+ if(texState==0)up=true;
+ }
+ }if(vel.x != 0){
+ switch(texState){
+ case 0:
+ glBindTexture(GL_TEXTURE_2D,texture[1]);
+ break;
+ case 1:
+ glBindTexture(GL_TEXTURE_2D,texture[0]);
+ break;
+ case 2:
+ glBindTexture(GL_TEXTURE_2D,texture[2]);
+ break;
+ }
+ }else glBindTexture(GL_TEXTURE_2D,texture[0]);
+ }else{
+ glBindTexture(GL_TEXTURE_2D,texture[0]);
+ }
glBegin(GL_QUADS);
glTexCoord2i(0,1);glVertex2i(loc.x, loc.y);
glTexCoord2i(1,1);glVertex2i(loc.x + width, loc.y);
@@ -111,7 +137,9 @@ Player::Player(){ //sets all of the player specific traits on object creation
alive = true;
ground = false;
near = true;
- texture = loadTexture("assets/player.png");
+ texture[0] = loadTexture("assets/player.png");
+ texture[1] = loadTexture("assets/player1.png");
+ texture[2] = loadTexture("assets/player2.png");
inv = new Inventory(PLAYER_INV_SIZE);
}
@@ -128,7 +156,9 @@ NPC::NPC(){ //sets all of the NPC specific traits on object creation
alive = true;
canMove = true;
near = false;
- texture = loadTexture("assets/NPC.png");
+ texture[0] = loadTexture("assets/NPC.png");
+ texture[1] = 0;
+ texture[2] = 0;
inv = new Inventory(NPC_INV_SIZE);
}
@@ -152,7 +182,9 @@ Structures::Structures(){ //sets the structure type
speed = 0;
alive = true;
near = false;
- texture = loadTexture("assets/house1.png");
+ texture[0] = loadTexture("assets/house1.png");
+ texture[1] = 0;
+ texture[2] = 0;
}
unsigned int Structures::spawn(_TYPE t, float x, float y){ //spawns a structure based off of type and coords
diff --git a/src/ui.cpp b/src/ui.cpp
index cd5de15..e4af3e2 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -214,6 +214,7 @@ namespace ui {
if(SDL_KEY==SDLK_i)currentWorld=currentWorld->goWorldBack(player); // Go back a layer if possible
if(SDL_KEY==SDLK_k)currentWorld=currentWorld->goWorldFront(player); // Go forward a layer if possible
if(SDL_KEY==SDLK_LSHIFT)player->speed = 3; // Sprint
+ if(SDL_KEY==SDLK_LCTRL)player->speed = .5;
}
if(SDL_KEY==SDLK_F3)debug^=true;
break;
@@ -225,7 +226,7 @@ namespace ui {
if(SDL_KEY==SDLK_d){right=false;}
if(!left&&!right)player->vel.x=0;
if(SDL_KEY==SDLK_LSHIFT)player->speed = 1;
-
+ if(SDL_KEY==SDLK_LCTRL)player->speed = 1;
break;
default:
break;