|
|
|
|
/******************************************************************************
|
|
|
|
|
* File - world.h
|
|
|
|
|
* Author - Joey Pollack
|
|
|
|
|
* Date - 2022/01/12 (y/m/d)
|
|
|
|
|
* Mod Date - 2022/01/20 (y/m/d)
|
|
|
|
|
* Description - Manages a game "world". A world is made up of regions which
|
|
|
|
|
* are subdivisions of the world. Each region contains: a set
|
|
|
|
|
* of images for the maps layers, a list of objects that spawn
|
|
|
|
|
* in this region and static collision data.
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef WORLD_H_
|
|
|
|
|
#define WORLD_H_
|
|
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <utils/types.h>
|
|
|
|
|
#include <utils/opRes.h>
|
|
|
|
|
#include <utils/grid.h>
|
|
|
|
|
|
|
|
|
|
namespace lunarium
|
|
|
|
|
{
|
|
|
|
|
class Graphics;
|
|
|
|
|
class Camera;
|
|
|
|
|
class GameObject;
|
|
|
|
|
class Script;
|
|
|
|
|
class Image;
|
|
|
|
|
|
|
|
|
|
class World
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
struct Region
|
|
|
|
|
{
|
|
|
|
|
Script* mRegionScript;
|
|
|
|
|
Point2Di mCoords;
|
|
|
|
|
std::vector<GameObject*> mObjects;
|
|
|
|
|
std::vector<Image*> mLayers;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public: // INTERFACE
|
|
|
|
|
|
|
|
|
|
World(Camera* pCam, Sizei region_size, Sizei world_size);
|
|
|
|
|
|
|
|
|
|
void OnLoad();
|
|
|
|
|
void OnUnload();
|
|
|
|
|
void Update(float dt);
|
|
|
|
|
void Render(Graphics* pGraphics) const;
|
|
|
|
|
void RenderToTexture(Graphics* pGraphics, Image* pTexture) const;
|
|
|
|
|
|
|
|
|
|
// Game objects should probably be added/removed from the regions directly
|
|
|
|
|
// No World-wide game objects
|
|
|
|
|
// Unless I can think of a good reason why they would be useful
|
|
|
|
|
// void AddGameObject(GameObject* pObj);
|
|
|
|
|
// bool RemoveGameObject(GameObject* pObj);
|
|
|
|
|
|
|
|
|
|
OpRes SetRegion(Region* region, Point2Di at);
|
|
|
|
|
Region* GetRegion(Point2Di at);
|
|
|
|
|
bool RemoveRegion(Point2Di at);
|
|
|
|
|
|
|
|
|
|
void SetWorldScript(Script* pScript);
|
|
|
|
|
Script* GetWorldScript();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
Camera* mpCamera;
|
|
|
|
|
std::vector<GameObject*> mWorldObjects;
|
|
|
|
|
Script* mpWorldScript;
|
|
|
|
|
Sizei mRegionSize; // in pixels
|
|
|
|
|
Sizei mWorldSize; // num regions ex. 10x10
|
|
|
|
|
Grid<Region*> mRegions;
|
|
|
|
|
Point2Di mActiveRegion;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // WORLD_H_
|