00001 /* 00002 RealTimeBattle, a robot programming game for Unix 00003 Copyright (C) 1998-2000 Erik Ouchterlony and Ragnar Ouchterlony 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, write to the Free Software Foundation, 00017 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 */ 00019 00020 #ifndef __SHAPE__ 00021 #define __SHAPE__ 00022 00023 class Vector2D; 00024 00025 #ifndef NO_GRAPHICS 00026 #include <gdk/gdktypes.h> 00027 #include <gdk/gdk.h> 00028 #endif 00029 00030 00031 /* 00032 00033 Shape is the base class for all objects in the arena. The class hierarchy 00034 is as follows: 00035 00036 --------- 00037 | Shape | 00038 --------- 00039 _____/ | \_____________ 00040 / | \ 00041 -------- ---------- --------------- 00042 | Line | | Circle | | InnerCircle | 00043 -------- ---------- --------------- 00044 | | | \ \ 00045 | | | \ \ 00046 ------------ | | -------------- ------------------- 00047 | WallLine | / | | WallCircle | | WallInnerCircle | 00048 ------------ / \ -------------- ------------------- 00049 / \ 00050 ---------- ---------------- 00051 | Extras | | MovingObject | 00052 ---------- ---------------- 00053 / \ | \ 00054 / \ | \ 00055 ---------- -------- -------- --------- 00056 | Cookie | | Mine | | Shot | | Robot | 00057 ---------- -------- -------- --------- 00058 00059 */ 00060 00061 00062 00063 00064 00065 00066 00067 class Shape 00068 { 00069 public: 00070 Shape(); 00071 Shape(int long colour); 00072 00073 virtual ~Shape() {} 00074 00075 virtual double get_distance(const Vector2D& pos, const Vector2D& vel, 00076 const double size) = 0; 00077 virtual bool within_distance(const Vector2D& pos, const double size) = 0; 00078 virtual Vector2D get_normal(const Vector2D& pos) = 0; 00079 00080 int get_id() { return id; } 00081 long int get_rgb_colour() { return rgb_colour; } 00082 00083 double get_bounce_coeff() { return bounce_coeff; } 00084 double get_hardness_coeff() { return hardness_coeff; } 00085 00086 // virtual arenaobject_t get_arenaobject_t() = 0; 00087 // friend void bounce_on_wall(class Robot& robot, const class Shape& wall, const Vector2D& normal); 00088 00089 #ifndef NO_GRAPHICS 00090 virtual void draw_shape(bool erase) = 0; 00091 GdkColor& get_gdk_colour() { return gdk_colour; } 00092 void set_colour(const GdkColor& gdk_colour); 00093 #endif 00094 00095 void set_colour(const long int colour); 00096 00097 protected: 00098 #ifndef NO_GRAPHICS 00099 GdkColor gdk_colour; 00100 #endif 00101 long int rgb_colour; 00102 00103 double bounce_coeff; 00104 double hardness_coeff; 00105 int id; 00106 }; 00107 00108 #endif
1.3.9.1