00001
00002
00003
00004
00005
00006
00007
00009
00016 #include "utils.h"
00017 #include "map.h"
00018 #include "map_objects.h"
00019 #include "map_dialogue.h"
00020 #include "map_actions.h"
00021
00022 #include "audio.h"
00023 #include "video.h"
00024 #include "script.h"
00025 #include "system.h"
00026 #include "global.h"
00027
00028 using namespace std;
00029 using namespace hoa_utils;
00030 using namespace hoa_audio;
00031 using namespace hoa_video;
00032 using namespace hoa_script;
00033 using namespace hoa_system;
00034 using namespace hoa_global;
00035
00036 namespace hoa_map {
00037
00038 namespace private_map {
00039
00040
00041
00042
00043
00044
00045 MapObject::MapObject() :
00046 object_id(-1),
00047 context(-1),
00048 x_position(-1),
00049 y_position(-1),
00050 x_offset(0.0f),
00051 y_offset(0.0f),
00052 img_half_width(0.0f),
00053 img_height(0.0f),
00054 coll_half_width(0.0f),
00055 coll_height(0.0f),
00056 updatable(true),
00057 visible(true),
00058 no_collision(false),
00059 draw_on_second_pass(false)
00060 {}
00061
00062
00063
00064 bool MapObject::DrawHelper() {
00065 if (visible == false)
00066 return false;
00067
00068
00069 float x_pos = static_cast<float>(x_position) + x_offset;
00070 float y_pos = static_cast<float>(y_position) + y_offset;
00071
00072
00073
00074 if (x_pos + img_half_width < MapMode::_current_map->_draw_info.left_edge ||
00075 x_pos - img_half_width > MapMode::_current_map->_draw_info.right_edge ||
00076 y_pos - img_height > MapMode::_current_map->_draw_info.bottom_edge ||
00077 y_pos < MapMode::_current_map->_draw_info.top_edge) {
00078 return false;
00079 }
00080
00081
00082
00083 VideoManager->Move(x_pos - MapMode::_current_map->_draw_info.left_edge, y_pos - MapMode::_current_map->_draw_info.top_edge);
00084 return true;
00085 }
00086
00087
00088
00089
00090
00091 PhysicalObject::PhysicalObject() :
00092 current_animation(0)
00093 {
00094 MapObject::_object_type = PHYSICAL_TYPE;
00095 }
00096
00097
00098
00099 PhysicalObject::~PhysicalObject() {
00100 animations.clear();
00101 }
00102
00103
00104
00105 void PhysicalObject::Update() {
00106 if (updatable)
00107 animations[current_animation].Update();
00108 }
00109
00110
00111
00112 void PhysicalObject::Draw() {
00113 if (MapObject::DrawHelper() == true)
00114 VideoManager->DrawImage(animations[current_animation]);
00115 }
00116
00117 }
00118
00119 }