aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/Texture.h3
-rw-r--r--include/entities.h2
-rw-r--r--main.cpp18
-rw-r--r--src/Texture.cpp11
-rw-r--r--src/entities.cpp36
-rw-r--r--src/gameplay.cpp5
6 files changed, 42 insertions, 33 deletions
diff --git a/include/Texture.h b/include/Texture.h
index 45c8df1..5a08348 100644
--- a/include/Texture.h
+++ b/include/Texture.h
@@ -12,10 +12,11 @@ public:
Texturec(uint amt, ...);
void bindNext();
void bindPrev();
+ void bind(int);
GLuint *image;
-private:
int texState;
+private:
};
diff --git a/include/entities.h b/include/entities.h
index 43e744e..47f7f55 100644
--- a/include/entities.h
+++ b/include/entities.h
@@ -94,7 +94,7 @@ public:
};
class Mob : public Entity{
public:
- Mob();
+ Mob(int);
void wander(int, vec2*);
};
diff --git a/main.cpp b/main.cpp
index a04cd01..979a0bb 100644
--- a/main.cpp
+++ b/main.cpp
@@ -305,19 +305,18 @@ int main(int argc, char *argv[]){
/*
* TODO - Initialize shaders n' stuff
*/
-
- /*
+ /*
GLuint fragShader;
- GLuint shaderProgram;
+ GLuint shaderProgram;6da
const GLchar *shaderSource = "shader.frag";
GLint bufferln = GL_FALSE;
shaderProgram = glCreateProgram();
fragShader = glCreateShader(GL_FRAGMENT_SHADER);
-
- glShaderSource(fragShader, 1, &shaderSource, NULL);
+
+ glShaderSource(fragShader, 1, shaderSource, NULL);
glCompileShader(fragShader);
glGetShaderiv(fragShader, GL_COMPILE_STATUS, &bufferln);
@@ -328,11 +327,9 @@ int main(int argc, char *argv[]){
glAttachShader(shaderProgram, fragShader);
glLinkProgram(shaderProgram);
glValidateProgram(shaderProgram);
-
+ */
//glEnable(GL_DEPTH_TEST);
//glEnable(GL_MULTISAMPLE);
-
- */
/*
* Open the names file containing potential names for NPCs and store it in the names file
@@ -583,7 +580,7 @@ void render(){
ui::putText(player->loc.x-SCREEN_WIDTH/2,
SCREEN_HEIGHT-ui::fontSize,
- "FPS: %d\nG:%d\nRes: %ux%u\nE: %d\nPOS: (x)%+.2f\n (y)%+.2f\nQc: %u",
+ "FPS: %d\nG:%d\nRes: %ux%u\nE: %d\nPOS: (x)%+.2f\n (y)%+.2f\nQc: %u\nTS:%d\n",
fps,
player->ground,
SCREEN_WIDTH, // Window dimensions
@@ -591,7 +588,8 @@ void render(){
entity.size(), // Size of entity array
player->loc.x, // The player's x coordinate
debugY, // The player's y coordinate
- player->qh.current.size() // Active quest count
+ player->qh.current.size(), // Active quest count
+ player->tex->texState
);
}
diff --git a/src/Texture.cpp b/src/Texture.cpp
index 93a3792..0d67701 100644
--- a/src/Texture.cpp
+++ b/src/Texture.cpp
@@ -35,6 +35,15 @@ Texturec::Texturec(uint amt, ...){
va_end(fNames);
}
+void Texturec::bind(int bn){
+ texState = bn;
+ glBindTexture(GL_TEXTURE_2D, image[texState]);
+}
+
void Texturec::bindNext(){
- //glBindTexture(GL_TEXTURE_2D);
+ bind(++texState);
+}
+
+void Texturec::bindPrev(){
+ bind(--texState);
} \ No newline at end of file
diff --git a/src/entities.cpp b/src/entities.cpp
index 0bc9fe7..ae8b4c8 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -35,12 +35,10 @@ Player::Player(){ //sets all of the player specific traits on object creation
height = HLINE * 16;
type = PLAYERT; //set type to player
- subtype = 0;
-
+ subtype = 0;
health = maxHealth = 100;
speed = 1;
-
- tex = new Texturec(3, "assets/player.png", "assets/player1.png", "assets/player2.png");
+ tex = new Texturec(3, "assets/player1.png", "assets/player.png", "assets/player2.png");
inv = new Inventory(PLAYER_INV_SIZE);
}
@@ -64,14 +62,16 @@ Structures::Structures(){ //sets the structure type
tex = new Texturec(1,"assets/house1.png");
}
-Mob::Mob(){
+Mob::Mob(int sub){
width = HLINE * 10;
height = HLINE * 8;
-
type = MOBT; //sets type to MOB
- subtype = 1; //SKIRL
-
- tex = new Texturec(2, "assets/rabbit.png", "assets/rabbit.png1");
+ subtype = sub; //SKIRL
+ if(subtype == 1){//RABBIT
+ tex = new Texturec(2, "assets/rabbit.png", "assets/rabbit1.png");
+ }else if(subtype == 2){//BIRD
+ //add bird textures and bird things
+ }
inv = new Inventory(NPC_INV_SIZE);
}
@@ -103,43 +103,45 @@ void Entity::draw(void){ //draws the entities
if(up){
texState+=1;
if(texState==2)up=false;
+ tex->bindNext();
}else if(!up){
texState-=1;
if(texState==0)up=true;
+ tex->bindPrev();
}
}
if(ground == 0){
- glBindTexture(GL_TEXTURE_2D, tex->image[0]);
+ tex->bind(0);
}else if(vel.x != 0){
switch(texState){
case 0:
- glBindTexture(GL_TEXTURE_2D,tex->image[1]);
+ tex->bind(0);
break;
case 1:
- glBindTexture(GL_TEXTURE_2D,tex->image[0]);
+ tex->bind(1);
break;
case 2:
- glBindTexture(GL_TEXTURE_2D,tex->image[2]);
+ tex->bind(2);
break;
}
}
else{
- glBindTexture(GL_TEXTURE_2D,tex->image[0]);
+ tex->bind(1);
}
}else if(type == MOBT){
switch(subtype){
case 1: //RABBIT
if(ground == 0){
- glBindTexture(GL_TEXTURE_2D, tex->image[1]);
+ tex->bind(1);
}else if(ground == 1){
- glBindTexture(GL_TEXTURE_2D, tex->image[0]);
+ tex->bind(0);
}
break;
default:
break;
}
}else{
- glBindTexture(GL_TEXTURE_2D,tex->image[0]);
+ tex->bind(0);
}
glColor3ub(255,255,255);
glBegin(GL_QUADS);
diff --git a/src/gameplay.cpp b/src/gameplay.cpp
index 8230e56..1f4b3fe 100644
--- a/src/gameplay.cpp
+++ b/src/gameplay.cpp
@@ -78,9 +78,8 @@ void initEverything(void){
/*
* Spawn a mob.
- */
-
- mob.push_back(new Mob());
+ */
+ mob.push_back(new Mob(1));
entity.push_back(mob.back());
mob.back()->spawn(200,100);