aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authordrumsetmonkey <abelleisle@roadrunner.com>2015-10-23 08:44:55 -0400
committerdrumsetmonkey <abelleisle@roadrunner.com>2015-10-23 08:44:55 -0400
commit0b5a24d5c3ea48c748cfa28ae258cd65187f9bf1 (patch)
tree5258af77ab83aac298229253fb011f1858962118 /src
parent19ba40a368b06c38365fe861b6de9403044096a7 (diff)
Worked on the new texture library
Diffstat (limited to 'src')
-rw-r--r--src/Texture.cpp11
-rw-r--r--src/entities.cpp30
-rw-r--r--src/gameplay.cpp4
3 files changed, 30 insertions, 15 deletions
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 6d2b58c..1f45e40 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -37,7 +37,7 @@ Player::Player(){ //sets all of the player specific traits on object creation
ground = false;
near = true;
inv = new Inventory(PLAYER_INV_SIZE);
- 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");
}
NPC::NPC(){ //sets all of the NPC specific traits on object creation
@@ -61,16 +61,20 @@ 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;
speed = 1;
type = MOBT; //sets type to MOB
- subtype = 1; //SKIRL
+ subtype = sub; //SKIRL
alive = true;
canMove = true;
near = false;
- tex = new Texturec(2, "assets/rabbit.png", "assets/rabbit.png1");
+ 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);
}
@@ -102,43 +106,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 3b9b819..f9d2578 100644
--- a/src/gameplay.cpp
+++ b/src/gameplay.cpp
@@ -51,8 +51,8 @@ void initEverything(void){
iw->generate(200);
build[0]->inside=iw;
- entity.push_back(new Mob()); //create a new entity of NPC type
- mob.push_back(Mob()); //create new NPC
+ entity.push_back(new Mob(1)); //create a new entity of NPC type
+ mob.push_back(Mob(1)); //create new NPC
entity[entity.size()] = &mob[mob.size()-1]; //set the new entity to have the same traits as an NPC
entity[entity.size()-1]->spawn(200,100); //sets the position of the villager around the village
entity.pop_back();