00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "fgentity.h"
00031
00032 FGEntity::FGEntity(){
00033 info = new tile_info;
00034 name = string();
00035 index = 0;
00036 onscreen = 0;
00037 current_frame = 0;
00038 stationary = 0;
00039
00040 }
00041
00042 FGEntity::~FGEntity(){
00043 }
00044
00045 void FGEntity::set_tiledata(Tiledata &t){
00046 tiledata = t;
00047 set_name(tiledata.get_name());
00048 }
00049
00050 void FGEntity::set_paul_info(paul_info *p){
00051 pinfo = p;
00052 }
00053
00054 void FGEntity::set_tileinfo(tile_info *newinfo){
00055 info = newinfo;
00056 }
00057
00058 void FGEntity::set_fgentity_list(FGEntityList *new_list){
00059 fgentity_list = new_list;
00060 }
00061
00062 void FGEntity::set_index(int i){
00063 index = i;
00064 }
00065
00066 void FGEntity::set_walkable(int i){
00067 walkable = i;
00068 }
00069
00070 void FGEntity::set_onscreen(int i){
00071 onscreen = i;
00072 }
00073
00074 int FGEntity::get_index(){
00075 return(index);
00076 }
00077
00078 int FGEntity::is_onscreen(){
00079 return(onscreen);
00080 }
00081
00082 void FGEntity::set_location(int x, int y){
00083 box = makerect(x, y, tiledata.tile[0]->w, tiledata.tile[0]->h);
00084 current_box = makerect(x*TILESIZE, y*TILESIZE, tiledata.tile[0]->w, tiledata.tile[0]->h);
00085 }
00086
00087 SDL_Rect FGEntity::get_box(){
00088 return(box);
00089 }
00090
00091 string FGEntity::get_name(){
00092 return(name);
00093 }
00094
00095 void FGEntity::set_name(string str){
00096 name = str;
00097 }
00098
00099 void FGEntity::reverse(){
00100 int amount = 2;
00101 SDL_Rect rect = get_box();
00102 switch(direction){
00103 case 0: direction = 4;
00104 set_location(box.x, box.y+amount);
00105 break;
00106 case 1: direction = 5;
00107 set_location(box.x-amount, box.y+amount);
00108 break;
00109 case 2: direction = 6;
00110 set_location(box.x-amount, box.y);
00111 break;
00112 case 3: direction = 7;
00113 set_location(box.x-amount, box.y-amount);
00114 break;
00115 case 4: direction = 0;
00116 set_location(box.x, box.y-amount);
00117 break;
00118 case 5: direction = 1;
00119 set_location(box.x+amount, box.y-amount);
00120 break;
00121 case 6: direction = 2;
00122 set_location(box.x+amount, box.y);
00123 break;
00124 case 7: direction = 3;
00125 set_location(box.x+amount, box.y+amount);
00126 break;
00127 }
00128 }
00129
00130 int FGEntity::activate(){
00131 return(0);
00132 }