You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
2.0 KiB
C
76 lines
2.0 KiB
C
|
4 years ago
|
/******************************************************************************
|
||
|
|
* File - world.h
|
||
|
|
* Author - Joey Pollack
|
||
|
|
* Date - 2022/01/12 (y/m/d)
|
||
|
4 years ago
|
* Mod Date - 2022/01/20 (y/m/d)
|
||
|
4 years ago
|
* 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>
|
||
|
4 years ago
|
#include <utils/opRes.h>
|
||
|
|
#include <utils/grid.h>
|
||
|
4 years ago
|
|
||
|
|
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
|
||
|
|
|
||
|
4 years ago
|
World(Camera* pCam, Sizei region_size);
|
||
|
|
|
||
|
4 years ago
|
void OnLoad();
|
||
|
|
void OnUnload();
|
||
|
|
void Update(float dt);
|
||
|
4 years ago
|
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();
|
||
|
|
|
||
|
4 years ago
|
|
||
|
|
private:
|
||
|
|
Camera* mpCamera;
|
||
|
|
std::vector<GameObject*> mWorldObjects;
|
||
|
4 years ago
|
Script* mpWorldScript;
|
||
|
4 years ago
|
Sizei mRegionSize;
|
||
|
4 years ago
|
Grid<Region*> mRegions;
|
||
|
|
Point2Di mActiveRegion;
|
||
|
4 years ago
|
|
||
|
|
|
||
|
|
};
|
||
|
|
}
|
||
|
|
|
||
|
|
#endif // WORLD_H_
|