00001 // SuperTux 00002 // Copyright (C) 2006 Matthias Braun <matze@braunis.de> 00003 // 00004 // This program is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 00017 #ifndef HEADER_SUPERTUX_OBJECT_SCRIPTED_OBJECT_HPP 00018 #define HEADER_SUPERTUX_OBJECT_SCRIPTED_OBJECT_HPP 00019 00020 #include "object/moving_sprite.hpp" 00021 #include "scripting/scripted_object.hpp" 00022 #include "supertux/physic.hpp" 00023 #include "supertux/script_interface.hpp" 00024 00025 class ScriptedObject : public MovingSprite, 00026 public scripting::ScriptedObject, 00027 public ScriptInterface 00028 { 00029 public: 00030 ScriptedObject(const Reader& lisp); 00031 00032 virtual void expose(HSQUIRRELVM vm, SQInteger table_idx); 00033 virtual void unexpose(HSQUIRRELVM vm, SQInteger table_idx); 00034 00035 void update(float elapsed_time); 00036 void draw(DrawingContext& context); 00037 00038 void collision_solid(const CollisionHit& hit); 00039 HitResponse collision(GameObject& other, const CollisionHit& hit); 00040 00041 // --- scripting Interface stuff --- 00042 00043 void set_action(const std::string& animation); 00044 std::string get_action(); 00045 00046 void move(float x, float y); 00047 void set_pos(float x, float y); 00048 float get_pos_x(); 00049 float get_pos_y(); 00050 void set_velocity(float x, float y); 00051 float get_velocity_x(); 00052 float get_velocity_y(); 00053 void set_visible(bool visible); 00054 bool is_visible(); 00055 void set_solid(bool solid); 00056 bool is_solid(); 00057 00058 std::string get_name(); 00059 00060 private: 00061 Physic physic; 00062 std::string name; 00063 bool solid; 00064 bool physic_enabled; 00065 bool visible; 00066 bool new_vel_set; 00067 Vector new_vel; 00068 }; 00069 00070 #endif 00071 00072 /* EOF */