00001 /************************************************************************* 00002 bgentity.cpp 00003 Project Piedmont game 00004 ------------------------- 00005 00006 Date Created: 10/19/00 Last Modified: 05/05/08 00007 Programmer: David Foster 00008 Copyright: (C) 2000 David Foster (see file COPYING) 00009 E-mail: dfoster@computer.org 00010 00011 Description: main character class from which background tiles will 00012 be derived 00013 00014 This program is free software; you can redistribute it and/or modify 00015 it under the terms of the GNU General Public License as published by 00016 the Free Software Foundation; either version 2 of the License, or 00017 (at your option) any later version. 00018 00019 This program is distributed in the hope that it will be useful, 00020 but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 GNU General Public License for more details. 00023 00024 You should have received a copy of the GNU General Public License 00025 along with this program; if not, write to the Free Software 00026 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00027 00028 ************************************************************************/ 00029 00030 #include "bgentity.h" 00031 00032 BGEntity::BGEntity(){ 00033 // tiledata = new Tiledata; 00034 info = new tile_info; 00035 name = string(); 00036 index = 0; 00037 onscreen = 0; 00038 } 00039 00040 BGEntity::~BGEntity(){ 00041 // delete tiledata; 00042 delete info; 00043 } 00044 00045 void BGEntity::set_tiledata(Tiledata *t){ 00046 //cerr << t->get_name() << endl; 00047 tiledata = t; 00048 set_name(tiledata->get_name()); 00049 } 00050 00051 void BGEntity::set_tileinfo(tile_info *newinfo){ 00052 info = newinfo; 00053 } 00054 00055 void BGEntity::set_tile_props(int first_prop, int second_prop){ 00056 walkable = info->first_prop = first_prop; 00057 damage = info->second_prop = second_prop; 00058 // printf("%d %d\n", info->first_prop, info->second_prop); 00059 } 00060 00061 void BGEntity::set_index(int i){ 00062 index = i; 00063 } 00064 00065 void BGEntity::set_onscreen(int i){ 00066 onscreen = i; 00067 } 00068 00069 int BGEntity::is_onscreen(){ 00070 return(onscreen); 00071 } 00072 00073 void BGEntity::set_location(int x, int y){ 00074 box = makerect(x, y, tiledata->get_width(), tiledata->get_height()); 00075 } 00076 00077 SDL_Rect BGEntity::get_box(){ 00078 return(box); 00079 } 00080 00081 int BGEntity::is_walkable(){ 00082 return(walkable); 00083 } 00084 00085 int BGEntity::get_damage(){ 00086 return(damage); 00087 } 00088 00089 int BGEntity::get_tilesize(){ 00090 return(tiledata->tile[0]->w); 00091 } 00092 00093 string BGEntity::get_name(){ 00094 return(name); 00095 } 00096 00097 void BGEntity::set_name(string str){ 00098 name = str; 00099 }