Kukatz 3D  0.1
Török Attila szakdolgozata
projects/Kukatz 3D/include/kukac.hpp
00001 /*
00002  * kukac.hpp - Kukatz 3D
00003  * Copyright (c) 2010, 2011 - TÖRÖK Attila (torokati44@gmail.com)
00004  *
00005  * This software is provided 'as-is', without any express or implied
00006  * warranty. In no event will the authors be held liable for any damages
00007  * arising from the use of this software.
00008  *
00009  * Permission is granted to anyone to use this software for any purpose,
00010  * including commercial applications, and to alter it and redistribute it
00011  * freely, subject to the following restrictions:
00012  *
00013  *   1. The origin of this software must not be misrepresented; you must not
00014  *      claim that you wrote the original software. If you use this software
00015  *      in a product, an acknowledgment in the product documentation would be
00016  *      appreciated but is not required.
00017  *
00018  *   2. Altered source versions must be plainly marked as such, and must not be
00019  *      misrepresented as being the original software.
00020  *
00021  *   3. This notice may not be removed or altered from any source
00022  *      distribution.
00023  */
00024 
00025 #ifndef KUKAC_HPP_INCLUDED
00026 #define KUKAC_HPP_INCLUDED
00027 
00028 #include <SFML/System.hpp>
00029 
00030 #include "animatedobject.hpp"
00031 #include "updatable.hpp"
00032 #include "renderable.hpp"
00033 #include "grid.hpp"
00034 
00035 class Kukac: public Updatable, public Renderable
00036 {
00037 private:
00038         float step_time;
00039         float ratio;
00040         
00041         float speed;
00042         
00043         bool alive;
00044         
00045         unsigned int growth;
00046         
00047         bool moved;
00048         bool turned;
00049         bool reversed;
00050         bool should_reverse;
00051         
00052         struct body_part_t
00053         {
00054                 body_part_t(
00055                         sf::Vector3i p = sf::Vector3i(0, 0, 0),
00056                         body_part_t* b = 0,
00057                         body_part_t* f = 0
00058                 );
00059                 
00060                 body_part_t(const body_part_t&);
00061                 
00062                 GameObject* object;
00063                 
00064                 sf::Vector3i pos;
00065                 body_part_t* backward;
00066                 body_part_t* forward;
00067         };
00068         
00069         GameObject* tail_to_straight;
00070         GameObject* tail_to_corner;
00071         GameObject* tail_grow_straight;
00072         GameObject* tail_grow_corner;
00073         
00074         static AnimatedObject* get_anim(const sf::Vector3i, const sf::Vector3i&,
00075                 const sf::Vector3i&);
00076         
00077 public:
00078         Kukac(Grid&, unsigned int, const sf::Vector3i&, const sf::Vector3i&,
00079                 const sf::Vector3i&, unsigned int, float);
00080         
00081         Grid& grid;
00082         
00083         unsigned int type;
00084         
00085         body_part_t* head;
00086         body_part_t* tail;
00087         
00088         
00089         AnimatedObject* neck_forward;
00090         AnimatedObject* neck_turn;
00091         
00092         sf::Vector3i direction;
00093         sf::Vector3i next_direction;
00094         
00095         sf::Vector3i upward;
00096         sf::Vector3i next_upward;
00097         
00098         virtual void update(float);
00099         virtual void render();
00100         
00101         void step();
00102         void reverse();
00103         void grow(unsigned int);
00104         void accelerate(float);
00105         void die();
00106         
00107         void turn_left();
00108         void turn_right();
00109         void turn_up();
00110         void turn_down();
00111         
00112         void turn_random();
00113         
00114         bool can_move_to(const sf::Vector3i&);
00115         
00116         const bool& is_alive() const;
00117         const float& get_ratio() const;
00118         const float& get_speed() const;
00119         unsigned int get_length() const;
00120         const unsigned int& get_growth() const;
00121         const bool& did_move() const;
00122         const bool& did_reverse() const;
00123         
00124         virtual ~Kukac();
00125 };
00126 
00127 #endif // KUKAC_HPP_INCLUDED
 Összes Osztályok