Map.h

Go to the documentation of this file.
00001 /* -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 5 -*- */
00002 
00003 /*
00004  * Combination of a first person action and a real time strategy battle game.
00005  */
00006 
00007 /*
00008  * Map.h
00009  * MetalWarriors
00010  * $Revision: 1.7 $
00011  *
00012  * Created by Daniel Aarno on Sun Oct 12 2003.
00013  * Copyright (c) 2003 Daniel Aarno and Erik Ytterberg - All rights reserved.
00014  *
00015  *     This program is free software; you can redistribute it and/or modify
00016  *     it under the terms of the GNU General Public License as published by
00017  *     the Free Software Foundation; either version 2 of the License, or
00018  *     (at your option) any later version.
00019  *
00020  *     This program is distributed in the hope that it will be useful,
00021  *     but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023  *     GNU General Public License for more details.
00024  *
00025  *     You should have received a copy of the GNU General Public License
00026  *     along with this program; if not, write to the Free Software
00027  *     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00028  */
00029 
00030 #ifndef MAP_H
00031 #define MAP_H
00032 
00033 #include <list>
00034 #include "Sprite.h"
00035 
00036 #define MARK_SIZE 30.0f
00037 
00038 class Marker
00039 {
00040 public:
00041      virtual ~Marker() {}
00042 
00043      float coord[2];
00044      float *pos;
00045      Sprite *sprite;
00046      GLuint texture;
00047     
00048      Marker(void);
00049      Marker(float x, float y);
00050      void update(void);
00051      virtual void draw(float scale);
00052      virtual float getDistance(float x, float y);
00053 };
00054 
00055 class SpriteMarker: public Marker
00056 {
00057 public:
00058      Sprite *master;
00059 };
00060 
00061 
00062 
00063 
00064 #define MAX_MAP_HEIGHT 11.0
00065 
00066 #define MAP_SCREEN_COVERAGE_FULL 1.3
00067 #define MAP_PLACEMENT_FULL_X 0.6
00068 #define MAP_PLACEMENT_FULL_Y 0.55
00069 
00070 #define MAP_SCREEN_COVERAGE_THUMB 3.5
00071 #define MAP_PLACEMENT_THUMB_X 0.85
00072 #define MAP_PLACEMENT_THUMB_Y 0.2
00073 #define MAP_THUMB_ZOOM 5.0
00074 
00075 typedef enum
00076   {
00077     MAP_MODE_FULL,
00078     MAP_MODE_THUMB,
00079     MAP_MODE_OFF
00080   } map_mode_t;
00081 
00082 
00083 
00084 class Map
00085 {
00086  protected:
00087   int segments_x;
00088   int segments_y;
00089   int size_x;
00090   int size_y;
00091   
00092   float zoom;
00093   float zoom_step;
00094   float zoom_full;
00095   float current_x;
00096   float current_y;
00097 
00098   map_mode_t mode;
00099 
00100   GLuint **map_texture;
00101   char ***map_image;
00102 
00103   std::list<Marker*> markers;
00104   Marker *currentMarker;
00105   
00106   
00107  public:
00108   Map(int subdivisions);
00109   void addMarker(Marker *mark);
00110   void delMarker(Marker *mark);
00111   void setPosition(float x, float y);
00112   void setCurrentMarkerFromSprite(Sprite *sprite);
00113   void setMode(map_mode_t new_mode);
00114   map_mode_t getMode(void);
00115   void cycleMode(void);
00116   
00117   void setZoom(float new_zoom);
00118   void incZoom(void);
00119   void decZoom(void);
00120   void setZoomStep(float new_zoom_step);
00121   void update(void);
00122   void draw(void);
00123 
00124  protected:
00125   void buildTextures(int subdivisions);
00126   void setupProjTrans(float x_position, float y_position, float coverage);
00127   void setupStencilMask(void);
00128   void restore(void);
00129   void drawMarkers(void);
00130   int inverseMapCoords(int x_query, int y_query, float *x_result, float *y_result);
00131   Marker* findClosestMarker(float x, float y, float max_distance);
00132 };
00133 
00134 
00135 
00136 
00137 
00138 #endif /*MAP_H*/

Generated on Sun Mar 11 15:33:23 2007 for MetalWarriors by  doxygen 1.4.7