aboutsummaryrefslogtreecommitdiffstats
path: root/src/entities.cpp
diff options
context:
space:
mode:
authordrumsetmonkey <abelleisle@roadrunner.com>2015-11-30 08:49:20 -0500
committerdrumsetmonkey <abelleisle@roadrunner.com>2015-11-30 08:49:20 -0500
commitaf22d85f9a417a94ea75db1878219f8baeba8b73 (patch)
treec0564e39209b3e9acb8b65e98632b04c1828d55e /src/entities.cpp
parent0415b7f0a9305cd43e8fd8c77a8bafd3b8016dd0 (diff)
parent45bca98b792f8ced1a57ef8c5beed2a90a79d47f (diff)
Working on animations
Diffstat (limited to 'src/entities.cpp')
-rw-r--r--src/entities.cpp30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/entities.cpp b/src/entities.cpp
index c2c560a..1681efd 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -33,7 +33,7 @@ void Entity::spawn(float x, float y){ //spawns the entity you pass to it based o
}
}
- name = (char*)malloc(16);
+ name = new char[16]; //(char*)malloc(16);
getName();
}
@@ -100,21 +100,14 @@ Mob::Mob(int sub){
inv = new Inventory(NPC_INV_SIZE);
}
-Object::Object(int id):identifier(id){
- type = OBJECTT;
- alive = true;
- near = false;
- width = HLINE * 8;
- height = HLINE * 8;
-
- maxHealth = health = 1;
- tex = new Texturec(1, item[id].textureLoc);
-
- questObject = false;
- pickupDialog="\0";
-}
+Object::Object(ITEM_ID id, bool qo, const char *pd){
+ identifier = id;
+ questObject = qo;
+
+ pickupDialog = new char[strlen(pd)+1];
+ strcpy(pickupDialog,pd);
+
-Object::Object(int id, bool qo, char *pd):identifier(id),questObject(qo),pickupDialog(pd){
type = OBJECTT;
alive = true;
near = false;
@@ -122,7 +115,8 @@ Object::Object(int id, bool qo, char *pd):identifier(id),questObject(qo),pickupD
height = HLINE * 8;
maxHealth = health = 1;
- tex = new Texturec(1, item[id].textureLoc);
+ tex = new Texturec(1,getItemTexturePath(id));
+
}
@@ -218,7 +212,7 @@ NOPE:
void Entity::getName(){
rewind(names);
- char buf,*bufs = (char *)malloc(16);
+ char buf,*bufs = new char[16]; //(char *)malloc(16);
int tempNum,max = 0;
for(;!feof(names);max++){
fgets(bufs,16,(FILE*)names);
@@ -245,7 +239,7 @@ void Entity::getName(){
bufs[strlen(bufs)-1] = '\0';
strcpy(name,bufs);
}
- free(bufs);
+ delete[] bufs; //free(bufs);
}
void Player::interact(){ //the function that will cause the player to search for things to interact with