aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--assets/cloud1.pngbin0 -> 1152 bytes
-rw-r--r--assets/rabbit.pngbin0 -> 296 bytes
-rw-r--r--assets/rabbit1.pngbin0 -> 341 bytes
-rw-r--r--assets/skirl.pngbin0 -> 436 bytes
-rw-r--r--include/entities.h8
-rw-r--r--main.cpp1
-rw-r--r--src/entities.cpp27
-rw-r--r--src/ui.cpp1
8 files changed, 33 insertions, 4 deletions
diff --git a/assets/cloud1.png b/assets/cloud1.png
new file mode 100644
index 0000000..0a683e6
--- /dev/null
+++ b/assets/cloud1.png
Binary files differ
diff --git a/assets/rabbit.png b/assets/rabbit.png
new file mode 100644
index 0000000..6f35e9d
--- /dev/null
+++ b/assets/rabbit.png
Binary files differ
diff --git a/assets/rabbit1.png b/assets/rabbit1.png
new file mode 100644
index 0000000..6f32c96
--- /dev/null
+++ b/assets/rabbit1.png
Binary files differ
diff --git a/assets/skirl.png b/assets/skirl.png
new file mode 100644
index 0000000..263607b
--- /dev/null
+++ b/assets/skirl.png
Binary files differ
diff --git a/include/entities.h b/include/entities.h
index 537ed49..fc2f35c 100644
--- a/include/entities.h
+++ b/include/entities.h
@@ -20,6 +20,9 @@ public:
float width; //width and height of the player
float height;
float speed; //speed of the play
+
+ int health;
+ int maxHealth;
int subtype;
_TYPE type;
@@ -94,5 +97,10 @@ ENTITY TYPES
|->1 Merchant
|
2 MOBS
+<<<<<<< HEAD
+|->1 Rabbit
+**/
+=======
|->1 Skirl
**/
+>>>>>>> 58716d5e4f20eb5a30025c88fe5119a0e40c4187
diff --git a/main.cpp b/main.cpp
index 6e10420..5595c7e 100644
--- a/main.cpp
+++ b/main.cpp
@@ -201,7 +201,6 @@ void render(){
player->near=true; // Ensure the player's name is always drawn
currentWorld->draw(player); // Draw the world & the player
- glColor3ub(255,255,255); // Draw the player's inventory
player->inv->draw(); //
ui::draw(); // Draw any UI elements if they need to be
diff --git a/src/entities.cpp b/src/entities.cpp
index a7bbff5..0457ba1 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -25,7 +25,9 @@ Player::Player(){ //sets all of the player specific traits on object creation
height = HLINE * 16;
speed = 1;
type = PLAYERT; //set type to player
- subtype = 5;
+ subtype = 0;
+ maxHealth = 100;
+ health = maxHealth;
alive = true;
ground = false;
near = true;
@@ -69,8 +71,8 @@ Mob::Mob(){
alive = true;
canMove = true;
near = false;
- texture[0] = loadTexture("assets/NPC.png");
- texture[1] = 0;
+ texture[0] = loadTexture("assets/rabbit.png");
+ texture[1] = loadTexture("assets/rabbit1.png");
texture[2] = 0;
inv = new Inventory(NPC_INV_SIZE);
}
@@ -125,9 +127,22 @@ void Entity::draw(void){ //draws the entities
}else{
glBindTexture(GL_TEXTURE_2D,texture[0]);
}
+ }else if(type == MOBT){
+ switch(subtype){
+ case 1: //RABBIT
+ if(ground == 0){
+ glBindTexture(GL_TEXTURE_2D, texture[1]);
+ }else if(ground == 1){
+ glBindTexture(GL_TEXTURE_2D, texture[0]);
+ }
+ break;
+ default:
+ break;
+ }
}else{
glBindTexture(GL_TEXTURE_2D,texture[0]);
}
+ glColor3ub(255,255,255);
glBegin(GL_QUADS);
glTexCoord2i(0,1);glVertex2i(loc.x, loc.y);
glTexCoord2i(1,1);glVertex2i(loc.x + width, loc.y);
@@ -137,6 +152,12 @@ void Entity::draw(void){ //draws the entities
glDisable(GL_TEXTURE_2D);
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
+ if(type == PLAYERT){
+ ui::setFontSize(16);
+ ui::putText(((SCREEN_WIDTH / 2 ) + loc.x) - 125, SCREEN_HEIGHT - ui::fontSize, "Health: %d/%d",health,maxHealth);
+ glColor3ub(255,0,0);
+ glRectf((SCREEN_WIDTH / 2 + loc.x) - 125, SCREEN_HEIGHT - 32, ((SCREEN_WIDTH / 2 + loc.x) - 125) + (int)((int)(health / maxHealth) * 100), SCREEN_HEIGHT - 32 + 12);
+ }
if(near){
ui::setFontSize(14);
ui::putText(loc.x,loc.y-ui::fontSize-HLINE/2,"%s",name);
diff --git a/src/ui.cpp b/src/ui.cpp
index 25b792b..fe5414c 100644
--- a/src/ui.cpp
+++ b/src/ui.cpp
@@ -236,6 +236,7 @@ namespace ui {
if(!left&&!right)player->vel.x=0;
if(SDL_KEY==SDLK_LSHIFT)player->speed = 1;
if(SDL_KEY==SDLK_LCTRL)player->speed = 1;
+ if(SDL_KEY==SDLK_h)player->health-=5;
break;
default:
break;