Show Scene.h syntax highlighted
/**
**************************************************************************************
*Palisma - Secrets of the Illuminati is an open-source 2D RPG *
*Copyright (C) 2006, Tony Sparks *
* *
*This library is free software; you can redistribute it and/or *
*modify it under the terms of the GNU Lesser General Public *
*License as published by the Free Software Foundation; either *
*version 2.1 of the License, or (at your option) any later version. *
* *
*This library is distributed in the hope that it will be useful, *
*but WITHOUT ANY WARRANTY; without even the implied warranty of *
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
*Lesser General Public License for more details. *
* *
*You should have received a copy of the GNU Lesser General Public *
*License along with this library; if not, write to the Free Software *
*Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
**************************************************************************************
*/
#pragma once
#include "../render/ICamera.h"
#include "../render/Irender.h"
#include "../shared/vector.h"
#include "../shared/geom.h"
#include "ientity.h"
#include <string>
#include "tile.h"
#include <vector>
typedef std::vector< std::vector<Tile*> > type_Layer;
/**
======================================
A scene is a chunk of the map
There are many scenes which make up
an entire map
======================================
*/
class Scene
{
public:
Scene(void);
/** Update the scene */
void Update(long dt);
/** Draw the scene */
void Draw( IRender *r, ICamera* cam );
/** Free the scene - delete resources */
void FreeScene();
/** Get the tile at this location in array*/
Tile* GetTile(int layer, int x, int y);
/** Get the tile from screen coords */
Tile* GetScreenTile(int layer, int x, int y);
/** Test wether entities are allowed on the tile */
bool Collide(int x, int y, Rect& bounds);
/** Check the map boundries */
bool CheckBounds(int x, int y);
/** Check for a Trigger event */
void InvokeTrigger( IEntity *ent, int x, int y );
/** Get the map X for tile retrieval */
float GetX() { return m_offset.x; };
/** Get the map Y for tile retrieval */
float GetY() { return m_offset.y; };
/** Set the max dimensions of the map */
void SetMaxX(int mx) { m_maxX = mx; };
void SetMaxY(int my) { m_maxY = my; };
/** Get the Map dimensions */
int GetMaxX() { return m_maxX; };
int GetMaxY() { return m_maxY; };
/** Center the camera around our player */
void CenterCamera( ICamera* cam, Vector2f &pos );
/** convert from world coordinates to tile locations */
void WorldToTile( int x, int y, int &px, int &py );
/** Convert Tile coordinates to world coordinates */
void TileToWorld( int tx, int ty, int &wx, int &wy );
/** Get the background tiles */
type_Layer &GetBackgroundLayer() { return m_layer1; };
/** Get the foreground tiles */
type_Layer &GetForegroundLayer() { return m_layer2; };
private:
// check if we are indoors
bool m_inDoors;
// if this scene has been created
bool m_init;
// max scene dimensions
int m_maxX;
int m_maxY;
// current tile location
Vector2f m_offset;
// layer one tiles
type_Layer m_layer1;
// layer two tiles
type_Layer m_layer2;
// Standard tile size
int TILESIZE;
public:
virtual ~Scene(void);
};
See more files for this project here