src/Terrain.hh
author terom
Sun, 07 Dec 2008 20:07:28 +0000
changeset 255 99431fdb0dc8
parent 248 e40ef56dc62c
child 296 4d3ebaa29430
permissions -rw-r--r--
add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     1
#ifndef TERRAIN_HH
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     2
#define TERRAIN_HH
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     3
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     4
#include <vector>
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     5
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     6
#include "Vector.hh"
255
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
     7
#include "GraphicsPointer.hh"
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     8
#include "Config.hh"
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
     9
255
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    10
enum TerrainType {
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    11
    TERRAIN_EMPTY, 
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    12
    TERRAIN_DIRT, 
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    13
    TERRAIN_ROCK
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    14
};
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    15
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    16
const Vector DIRECTIONS[] = {
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    17
    Vector(0,-1),
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    18
    Vector(1,-1),
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    19
    Vector(1,0),
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    20
    Vector(1,1),
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    21
    Vector(0,1),
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    22
    Vector(-1,1),
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    23
    Vector(-1,0),
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    24
    Vector(-1,-1)
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    25
};
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    26
255
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    27
typedef long int PixelDimension;
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    28
typedef _Vector<PixelDimension> PixelCoordinate;
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    29
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    30
/**
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    31
 * Terrain class. Represents game terrain and contains member
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    32
 * functions to manipulate terrain and get info about it.
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    33
 * 
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    34
 * Terrain resolution is a constant that is defined in
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    35
 * configuration. Terrain has a scale (i.e. the width and height in
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    36
 * "real" units. Scaling is needed because physics simulation uses
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    37
 * "real" units. The idea is that this class is used with "real" units
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    38
 * and it uses pixelcoordinates internally.
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    39
 */ 
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    40
class Terrain {
255
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    41
public: // XXX: until we fix Network's access to this
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    42
    std::vector<std::vector<TerrainType> > terrain;    
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    43
    
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    44
    /**
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    45
     * Generates pixelbuffer from terrain. Should be used only on
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    46
     * constructors because this is expected to be slow.
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    47
     */
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    48
    void generatePixelBuffer();
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    49
255
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    50
protected:
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    51
    // terrain dimensions
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    52
    PixelDimension map_width, map_height;
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    53
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    54
    // We can pre-render the terrain as a pixel buffer and then just modify this
203
3ec7ab40755f send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents: 185
diff changeset
    55
    CL_PixelBuffer pixbuf;
255
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    56
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    57
    // terrain texture
243
25d9a0090397 some generated texture
nireco
parents: 222
diff changeset
    58
    std::vector<std::vector<int> > texture;
25d9a0090397 some generated texture
nireco
parents: 222
diff changeset
    59
255
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    60
    /**
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    61
     * Default constructor. The width/height are set to zero and the terrain is invalid until it gets updated
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    62
     *
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    63
     * @param scale The "real" width and height of the terrain.
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    64
     */
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    65
    Terrain (void);
203
3ec7ab40755f send initial terrain data to clients using a new NETCHAN_TERRAIN_ARRAY channel using raw BigNetworkPacket
terom
parents: 185
diff changeset
    66
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    67
    /**
255
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    68
     * Constructor.
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    69
     *
255
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    70
     * @param scale The "real" width and height of the terrain.
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    71
     * @param seed Random number generator seed used to create the
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    72
     * terrain.
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    73
     */
255
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    74
    Terrain (PixelDimension map_width, PixelDimension map_height, int seed);
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    75
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    76
    /**
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    77
     * Copy constructor.
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    78
     *
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    79
     * @param t Terrain to be copied.
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    80
     */
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    81
    Terrain (const Terrain &t);
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    82
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    83
    /**
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    84
     * Destructor
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    85
     */
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    86
    ~Terrain (void) {}
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    87
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    88
protected:
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    89
    void generate_texture();
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    90
    void noisifyPixel(CL_Color& col, PixelCoordinate pc);
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    91
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    92
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    93
    /**
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    94
     * Scale parameter to "pixels"
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    95
     *
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    96
     * @param x Scaled value
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    97
     * @return Corresponding value in pixels
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
    98
     */
255
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
    99
    PixelDimension scale (float x) const;
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   100
243
25d9a0090397 some generated texture
nireco
parents: 222
diff changeset
   101
    /**
25d9a0090397 some generated texture
nireco
parents: 222
diff changeset
   102
     * Sets to color the correct color of pixel in (x,y)
25d9a0090397 some generated texture
nireco
parents: 222
diff changeset
   103
     */
255
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
   104
    void loadPixelColor (CL_Color& color, PixelCoordinate pc);
243
25d9a0090397 some generated texture
nireco
parents: 222
diff changeset
   105
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   106
 public:
255
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
   107
    /**
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
   108
     * Get pixel location of a point that is in "real" units.
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
   109
     *
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
   110
     * @param point Point in "real" units
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
   111
     * @return Int vector
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
   112
     */
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
   113
    PixelCoordinate getPixelCoordinate (Vector point) const;
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   114
255
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
   115
    /**
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
   116
     * Return the terrain dimensions à la a PixelCoordinate
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
   117
     */
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
   118
    PixelCoordinate getDimensions (void) const;
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
   119
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   120
    /**
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   121
     * Return the type of terrain at given position. Returns ROCK if
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   122
     * given point is not inside terrain area.
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   123
     *
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   124
     * @param x X coordinate
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   125
     * @param y Y coordinate
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   126
     * @return Terrain type
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   127
     */
255
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
   128
    TerrainType getType (PixelDimension px, PixelDimension py) const;
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
   129
    TerrainType getType (PixelCoordinate pc) const;
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
   130
    TerrainType getType (Vector point) const;
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   131
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   132
    /**
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   133
     * Check if given point has some terrain.
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   134
     *
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   135
     * @param point Point that is in scaled units.
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   136
     */
255
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
   137
    bool collides (const Vector &point) const;
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   138
    /**
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   139
     * Check if given line collides with terrain.
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   140
     *
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   141
     * @param begin Line begin point in scaled units.
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   142
     * @param end Line end point in scaled units.
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   143
     */
255
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
   144
    bool collides (const Vector &begin, const Vector &end) const;
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   145
    
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   146
    /**
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   147
     * Remove a circular area from terrain.
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   148
     *
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   149
     * @param pos Circle center
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   150
     * @param r Circle radius
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   151
     */ 
255
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
   152
    void removeGround (const Vector &pos, float r);
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   153
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   154
    /**
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   155
     * Return normal for the given point.
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   156
     *
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   157
     * @param point Point for which the normal is calculated.
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   158
     * @return Normal vector ((0,0) if there's no terrain)
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   159
     */
255
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
   160
    Vector getNormal (Vector point, Vector prevPoint) const;
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   161
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   162
    /**
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   163
     * Generate random terrain.
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   164
     *
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   165
     * @param seed Seed for the randomnumber generator.
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   166
     */
255
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
   167
    void generateTerrain (int seed);
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   168
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   169
    /**
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   170
     * Draw the terrain for given graphicscontext.
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   171
     *
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   172
     * @param gc CL_GraphicContext
248
e40ef56dc62c scrolling looks like it works
nireco
parents: 243
diff changeset
   173
     * @param camera - upper left corner of screen
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   174
     */
255
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
   175
    virtual void draw (Graphics *g, PixelCoordinate camera = PixelCoordinate(0, 0));
222
293ddf4c067d reorganize PhysicsObject/Player/Projectile lists so that PhysicsObject doesn't need to know about its subclasses anymore, and PhysicsWorld doesn't need to know about GameState
ekku
parents: 203
diff changeset
   176
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   177
    /**
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   178
     * Draw part of the terrain for given graphiscontext.
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   179
     *
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   180
     * @param gc CL_GraphicContext
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   181
     * @param center Center of the rectangle drawn.
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   182
     * @param dimension Dimensions of the rectangle.
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   183
     */
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   184
    //void draw(CL_GraphicContext &gc, Vector center, Vector dimensions);
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   186
    /**
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   187
     * Set terrain.
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   188
     *
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   189
     * @param terrain Terrain.
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   190
     */
255
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
   191
    void setTerrain (const std::vector<std::vector<TerrainType> > &terrain);
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
   192
    
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   193
    /**
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   194
     * Get terrain.
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   195
     *
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   196
     * @return Terrain.
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   197
     */
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   198
    std::vector<std::vector<TerrainType> > getTerrain() const;
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   199
};
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   200
255
99431fdb0dc8 add PixelDimension/PixelCoordinate types, convert Terrain to use them, and convert/clean up drawing code
terom
parents: 248
diff changeset
   201
Vector direction (const Vector &v);
185
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   202
25becd2cb026 that's not a prototype anymore... at least it shouldn't be
terom
parents:
diff changeset
   203
#endif