CrawlerTurret.h - FULL
#ifndef CRAWLERTURRET_H#define CRAWLERTURRET_H#include "Particle.h"#include "Map.h"#include "Entity.h"#include "Math.h"class CrawlerTurret : public Entity{public: enum facing_enum {NONE, LEFT, RIGHT, UP, DOWN}; CrawlerTurret (); CrawlerTurret (int x, int y, int w, int h, INPUT_DEVICE = AUTONOMOUS); static void push (int x, int y, int w, int h, INPUT_DEVICE input = AUTONOMOUS); void update (); void render (BITMAP* buffer, int mapxoff = 0, int mapyoff = 0); void crawlerAI (); private: Entity* target; facing_enum facing; facing_enum lastContact; int lastx, lasty; int bufferedVelx, bufferedVely;};#endif
CrawlerTurret - SNIPPET
void CrawlerTurret::update(){ Entity::collision_correction(true); // <- This is causing problamos Entity::update(); int px = 5.0f + fabs(vx); int py = 5.0f + fabs(vy); int d = 0; //shooting distance as not to collide with shooting entity int pw = 5; //particle width int ph = 5; //particle height ...
Entity.h - FULL
#ifndef _ENTITY_#define _ENTITY_#include <list>#include "Animation.h"#include <stdio.h>#include <math.h>#include "Math.h"using namespace std;//entity state will dictate parameters for how an entity should //react, animate and moveenum ENTITY_STATE{ IDLE = 0, MOVING, DEAD,};enum INPUT_DEVICE{ AUTONOMOUS = 0, KEYBOARD, JOY0, JOY1, JOY2, JOY3};enum AFFILIATION{ NEUTRAL = 0, FRIENDLY, ENEMY};class Entity{public: Entity (); Entity (int col_x, int col_y, int col_w, int col_h); public://temporarily public for debug printing static list<Entity*> entity_list; int x, y, w, h; //entity source x,y,w,h int bx, by, bw, bh; //bitmap source x,y,w,h float vx, vy; //velocity x,y float ax, ay; //acceleration x,y int life; //if (life < 1) entity = dead; delete; int damage; //b.life -= a.damage when colliding ENTITY_STATE state; INPUT_DEVICE input; //AI or keyboard/joystick controlled AFFILIATION affiliation; Animation idle; //the run animation Animation moving; //other example animations Animation dead; bool inside (int x,int y,int left,int top,int right,int bottom); bool use_collision_correction; bool colliding;public: static void push (int x, int y, int w, int h); static void delete_dead_entities (); virtual void update (); virtual void render (BITMAP* buffer, int mapxoff = 0, int mapyoff = 0); void load_animation (ENTITY_STATE animation, char* path, int frames); Animation *get_animation (ENTITY_STATE); bool detect_collision (Entity* b); static Entity* get_entity (int number); static int get_count (); void apply_force (float x = 0, float y = 0); void move_to (int x = 0, int y = 0); void move (); void collision_correction (bool on_off = true); int get_x (); int get_y (); int get_w (); int get_h (); float get_vx (); float get_vy (); void set_life (int life); int get_life (); int get_damage (); int get_affiliation (); //level collision routines int collided_tl(int x, int y); int get_user_data(int x, int y, int u);};#endif // _ENTITY_
Entity.cpp - SNIPPET
... void Entity::collision_correction(bool on_off){ use_collision_correction = on_off;}...
In Terminal:
g++ -c Entity.cpp Entity.hg++ -c CrawlerTurret.cpp CrawlerTurret.h-- Error in CrawlerTurret.cpp in update function: collision_correction is not a member of Entity
... But update and everything else in there is fine??