generated from sigonasr2/CPlusPlusProjectTemplate
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
923 lines
38 KiB
923 lines
38 KiB
#define OLC_PGE_APPLICATION
|
|
#include "pixelGameEngine.h"
|
|
#define OLC_PGEX_SPLASHSCREEN
|
|
#include "splash.h"
|
|
#define OLC_SOUNDWAVE
|
|
#include "soundwaveEngine.h"
|
|
#include "tiles.h"
|
|
#include "references.h"
|
|
#include "states.h"
|
|
#include "flags.h"
|
|
|
|
#define WIDTH 256
|
|
#define HEIGHT 224
|
|
#define CAMERA_MOVESPD 5
|
|
#define TILEMAP_SIZE_X 512
|
|
#define TILEMAP_SIZE_Y 512
|
|
#define TILEMAP_EDITOR_DRAW_MULT 0.4375
|
|
#define TILEMAP_EDITOR_TILESIZE (32*TILEMAP_EDITOR_DRAW_MULT)
|
|
|
|
using namespace olc;
|
|
|
|
namespace layer{
|
|
enum layer{
|
|
INTERFACE, //Interface items should be on this layer. On top of everything.
|
|
COLLISION, //Collision checking layer. This layer is
|
|
HIGH,
|
|
DYNAMIC,
|
|
GROUND,
|
|
BACKGROUND,
|
|
OBJECT, //The object layer doesn't actually exist, it's used to tell the editor we are adding an object instead.
|
|
};
|
|
}
|
|
|
|
class Map{
|
|
public:
|
|
std::string filename;
|
|
std::string l2filename;
|
|
std::string l3filename;
|
|
std::string l4filename;
|
|
std::string l5filename;
|
|
Decal*tileset;
|
|
Map(std::string fname,std::string layer2_fname,std::string layer3_fname,std::string layer4_fname,std::string layer5_fname,Decal*tileset) {
|
|
this->filename=fname;
|
|
this->l2filename=layer2_fname;
|
|
this->l3filename=layer3_fname;
|
|
this->l4filename=layer4_fname;
|
|
this->l5filename=layer5_fname;
|
|
this->tileset=tileset;
|
|
}
|
|
};
|
|
|
|
class Animation{
|
|
public:
|
|
Decal*spr;
|
|
int frames=1;
|
|
int width=0;
|
|
Animation(Decal*spr,int width){
|
|
this->frames=spr->sprite->width/width;
|
|
this->width=width;
|
|
this->spr=spr;
|
|
}
|
|
};
|
|
|
|
class Object{
|
|
public:
|
|
int id;
|
|
Animation*spr;
|
|
vd2d pos;
|
|
int frameIndex=0;
|
|
int frameCount=0;
|
|
int animationSpd=12; //How many frames to wait between each frame.
|
|
std::string name;
|
|
vd2d scale={1,1};
|
|
Pixel color=WHITE;
|
|
vd2d originPoint={0,0};
|
|
bool drawn=false;
|
|
int disableFlag;
|
|
int enableFlag;
|
|
//animationSpd is how long to wait before switching frames.
|
|
Object(int id,std::string name,vd2d pos,Animation*spr,vd2d scale={1,1},Pixel color=WHITE,int animationSpd=1) {
|
|
this->spr=spr;
|
|
this->pos=pos;
|
|
this->id=id;
|
|
this->name=name;
|
|
this->scale=scale;
|
|
this->color=color;
|
|
this->animationSpd=animationSpd;
|
|
this->originPoint={spr->width/2,spr->spr->sprite->height-4};
|
|
}
|
|
};
|
|
|
|
class SeasonI : public PixelGameEngine
|
|
{
|
|
public:
|
|
SeasonI()
|
|
{
|
|
sAppName = "Season I: Winters of Loneliness";
|
|
|
|
}
|
|
|
|
public:
|
|
int frameCount=0;
|
|
float elapsedTime=0;
|
|
const float TARGET_RATE = 1/60.0;
|
|
int MAP_WIDTH;
|
|
int MAP_HEIGHT;
|
|
Map*CURRENT_MAP;
|
|
Map*MAP_ONETT;
|
|
vd2d cameraPos = {0,0};
|
|
int GAME_STATE = GameState::EDITOR;
|
|
vi2d SELECTED_TILE={0,0};
|
|
vi2d HIGHLIGHTED_TILE={0,0};
|
|
int EDITING_LAYER=layer::DYNAMIC;
|
|
int SELECTED_OBJ_ID = PLAYER;
|
|
int OBJ_DISPLAY_OFFSET = 0;
|
|
bool GAME_FLAGS[128]={};
|
|
|
|
bool MOUSE_PRESSED_DOWN=false,MOUSE_DOWN=false,MOUSE_RELEASED=false; //TODO Implement Mouse things.
|
|
|
|
std::vector<std::vector<TILE*>> MAP; //The foreground layer.
|
|
std::vector<std::vector<TILE*>> MAP2;
|
|
std::vector<std::vector<TILE*>> MAP3;
|
|
std::vector<std::vector<TILE*>> MAP4;
|
|
std::vector<std::vector<TILE*>> MAP5; //Collision Layer
|
|
std::map<Reference,Decal*> SPRITES;
|
|
std::map<Reference,Animation*> ANIMATIONS;
|
|
std::map<int,Object*> OBJ_INFO;
|
|
std::vector<Object*> OBJECTS;
|
|
|
|
bool OnUserCreate() override
|
|
{
|
|
for (int i=1;i<6;i++) {
|
|
CreateLayer();
|
|
EnableLayer(i,true);
|
|
}
|
|
SetPixelMode(Pixel::ALPHA);
|
|
ConsoleCaptureStdOut(true);
|
|
// Called once at the start, so create things here
|
|
|
|
EnableLayer(layer::COLLISION,false);
|
|
|
|
SetupAnimations();
|
|
SetupObjectInfo();
|
|
|
|
GAME_FLAGS[Flag::TEST_FLAG1]=true;
|
|
GAME_FLAGS[Flag::TEST_FLAG2]=false;
|
|
GAME_FLAGS[Flag::TEST_FLAG3]=true;
|
|
|
|
MAP_ONETT=new Map("map0","map0_2","map0_3","map0_4","map0_5",SPRITES[TILESET1]);
|
|
|
|
CURRENT_MAP=MAP_ONETT;
|
|
//OBJ_INFO["PLAYER"]=PLAYER_ANIMATION;
|
|
LoadMap(MAP_ONETT);
|
|
|
|
return true;
|
|
}
|
|
|
|
bool OnUserUpdate(float fElapsedTime) override
|
|
{
|
|
elapsedTime+=fElapsedTime;
|
|
while (elapsedTime>TARGET_RATE) {
|
|
elapsedTime-=TARGET_RATE;
|
|
updateGame();
|
|
}
|
|
keyUpdates();
|
|
SetDrawTarget(nullptr);
|
|
Clear(BLANK);
|
|
SetDrawTarget(layer::COLLISION);
|
|
if (EDITING_LAYER!=layer::COLLISION) {
|
|
Clear(MAGENTA);
|
|
} else {
|
|
Clear(BLANK);
|
|
}
|
|
SetDrawTarget(layer::HIGH);
|
|
Clear(BLANK);
|
|
SetDrawTarget(layer::DYNAMIC);
|
|
Clear(BLANK);
|
|
SetDrawTarget(layer::GROUND);
|
|
Clear(BLANK);
|
|
SetDrawTarget(layer::BACKGROUND);
|
|
Clear(BLANK);
|
|
drawGame();
|
|
return true;
|
|
}
|
|
|
|
void updateGame(){
|
|
frameCount++;
|
|
for (auto&obj:OBJECTS) {
|
|
if (obj->animationSpd!=0&&obj->frameCount++>obj->animationSpd) {
|
|
obj->frameCount=0;
|
|
obj->frameIndex++;
|
|
}
|
|
}
|
|
|
|
std::cout << Collision(GetMousePos());
|
|
|
|
switch (GAME_STATE) {
|
|
case GameState::TILE_SELECT:{
|
|
if (!TabHeld()) {
|
|
GAME_STATE=GameState::EDITOR;
|
|
}
|
|
if (GetMouse(0).bHeld) {
|
|
int selectedTileX=GetMouseX()/TILEMAP_EDITOR_TILESIZE;
|
|
int selectedTileY=GetMouseY()/TILEMAP_EDITOR_TILESIZE;
|
|
if (selectedTileX*TILEMAP_EDITOR_DRAW_MULT>=0&&selectedTileX*TILEMAP_EDITOR_DRAW_MULT<TILEMAP_SIZE_X&&selectedTileY*TILEMAP_EDITOR_DRAW_MULT<TILEMAP_SIZE_Y&&selectedTileY*TILEMAP_EDITOR_DRAW_MULT>=0) {
|
|
SELECTED_TILE={selectedTileX,selectedTileY};
|
|
}
|
|
}
|
|
}break;
|
|
case GameState::EDITOR:{
|
|
if (TabHeld()) {
|
|
GAME_STATE=GameState::TILE_SELECT;
|
|
}
|
|
if (OBJECTS.size()>0) {
|
|
if (GetKey(I).bHeld) {
|
|
if (!Collision({OBJECTS[0]->pos.x+OBJECTS[0]->originPoint.x,OBJECTS[0]->pos.y-1+OBJECTS[0]->originPoint.y})) {
|
|
OBJECTS[0]->pos.y-=1;
|
|
}
|
|
}
|
|
if (GetKey(K).bHeld) {
|
|
if (!Collision({OBJECTS[0]->pos.x+OBJECTS[0]->originPoint.x,OBJECTS[0]->pos.y+1+OBJECTS[0]->originPoint.y})) {
|
|
OBJECTS[0]->pos.y+=1;
|
|
}
|
|
}
|
|
if (GetKey(J).bHeld) {
|
|
if (!Collision({OBJECTS[0]->pos.x-1+OBJECTS[0]->originPoint.x,OBJECTS[0]->pos.y+OBJECTS[0]->originPoint.y})) {
|
|
OBJECTS[0]->pos.x-=1;
|
|
}
|
|
}
|
|
if (GetKey(L).bHeld) {
|
|
if (!Collision({OBJECTS[0]->pos.x+1+OBJECTS[0]->originPoint.x,OBJECTS[0]->pos.y+OBJECTS[0]->originPoint.y})) {
|
|
OBJECTS[0]->pos.x+=1;
|
|
}
|
|
}
|
|
}
|
|
int selectedTileX=(GetMouseX()+cameraPos.x)/32;
|
|
int selectedTileY=(GetMouseY()+cameraPos.y)/32;
|
|
if (selectedTileX<MAP_WIDTH&&selectedTileY<MAP_HEIGHT&&selectedTileX>=0&&selectedTileY>=0) {
|
|
HIGHLIGHTED_TILE={selectedTileX,selectedTileY};
|
|
}
|
|
if (GetMouse(0).bHeld) {
|
|
switch (EDITING_LAYER) {
|
|
case layer::COLLISION:{
|
|
TILE*tile=MAP5[HIGHLIGHTED_TILE.y][HIGHLIGHTED_TILE.x];
|
|
tile->tileX=SELECTED_TILE.x;
|
|
tile->tileY=SELECTED_TILE.y;
|
|
}break;
|
|
case layer::HIGH:{
|
|
TILE*tile=MAP[HIGHLIGHTED_TILE.y][HIGHLIGHTED_TILE.x];
|
|
tile->tileX=SELECTED_TILE.x;
|
|
tile->tileY=SELECTED_TILE.y;
|
|
}break;
|
|
case layer::DYNAMIC:{
|
|
TILE*tile=MAP2[HIGHLIGHTED_TILE.y][HIGHLIGHTED_TILE.x];
|
|
tile->tileX=SELECTED_TILE.x;
|
|
tile->tileY=SELECTED_TILE.y;
|
|
}break;
|
|
case layer::GROUND:{
|
|
TILE*tile=MAP3[HIGHLIGHTED_TILE.y][HIGHLIGHTED_TILE.x];
|
|
tile->tileX=SELECTED_TILE.x;
|
|
tile->tileY=SELECTED_TILE.y;
|
|
}break;
|
|
case layer::BACKGROUND:{
|
|
TILE*tile=MAP4[HIGHLIGHTED_TILE.y][HIGHLIGHTED_TILE.x];
|
|
tile->tileX=SELECTED_TILE.x;
|
|
tile->tileY=SELECTED_TILE.y;
|
|
}break;
|
|
}
|
|
} else
|
|
if (GetMouse(1).bHeld) {
|
|
switch (EDITING_LAYER) {
|
|
case layer::COLLISION:{
|
|
TILE*tile=MAP5[HIGHLIGHTED_TILE.y][HIGHLIGHTED_TILE.x];
|
|
tile->tileX=tile->tileY=15;
|
|
}break;
|
|
case layer::HIGH:{
|
|
TILE*tile=MAP[HIGHLIGHTED_TILE.y][HIGHLIGHTED_TILE.x];
|
|
tile->tileX=tile->tileY=15;
|
|
}break;
|
|
case layer::DYNAMIC:{
|
|
TILE*tile=MAP2[HIGHLIGHTED_TILE.y][HIGHLIGHTED_TILE.x];
|
|
tile->tileX=tile->tileY=15;
|
|
}break;
|
|
case layer::GROUND:{
|
|
TILE*tile=MAP3[HIGHLIGHTED_TILE.y][HIGHLIGHTED_TILE.x];
|
|
tile->tileX=tile->tileY=15;
|
|
}break;
|
|
case layer::BACKGROUND:{
|
|
TILE*tile=MAP4[HIGHLIGHTED_TILE.y][HIGHLIGHTED_TILE.x];
|
|
tile->tileX=tile->tileY=15;
|
|
}break;
|
|
}
|
|
}
|
|
|
|
}break;
|
|
}
|
|
|
|
//CAMERA UPDATES MUST BE LAST!!! COLLISIONS RELY ON THE GAME POSITION STATES REMAINING THE SAME!
|
|
cameraUpdate();
|
|
}
|
|
|
|
//CAMERA UPDATES MUST BE LAST!!! COLLISIONS RELY ON THE GAME POSITION STATES REMAINING THE SAME!
|
|
void cameraUpdate() {
|
|
|
|
switch (GAME_STATE) {
|
|
case GameState::EDITOR:{
|
|
//CAMERA MOVEMENTS MUST BE LAST!!!
|
|
if (UpHeld()) {
|
|
cameraPos.y-=CAMERA_MOVESPD;
|
|
}
|
|
if (RightHeld()) {
|
|
cameraPos.x+=CAMERA_MOVESPD;
|
|
}
|
|
if (LeftHeld()) {
|
|
cameraPos.x-=CAMERA_MOVESPD;
|
|
}
|
|
if (DownHeld()) {
|
|
cameraPos.y+=CAMERA_MOVESPD;
|
|
}
|
|
}break;
|
|
}
|
|
}
|
|
|
|
void keyUpdates() {
|
|
|
|
if (GetKey(F1).bPressed) {
|
|
ConsoleShow(F1,false);
|
|
}
|
|
if (GetKey(F2).bPressed) {
|
|
SaveMap(CURRENT_MAP);
|
|
printf("Map Saved\n");
|
|
}
|
|
|
|
switch (GAME_STATE) {
|
|
case GameState::TILE_SELECT:{
|
|
if (UpPressed()) {
|
|
SELECTED_TILE.y=SELECTED_TILE.y-1;
|
|
if (SELECTED_TILE.y<0) {
|
|
SELECTED_TILE.y=TILEMAP_SIZE_Y/32-1;
|
|
}
|
|
}
|
|
if (RightPressed()) {
|
|
SELECTED_TILE.x=(SELECTED_TILE.x+1)%(TILEMAP_SIZE_X/32);
|
|
}
|
|
if (LeftPressed()) {
|
|
SELECTED_TILE.x=SELECTED_TILE.x-1;
|
|
if (SELECTED_TILE.x<0) {
|
|
SELECTED_TILE.x=TILEMAP_SIZE_X/32-1;
|
|
}
|
|
}
|
|
if (DownPressed()) {
|
|
SELECTED_TILE.y=(SELECTED_TILE.y+1)%(TILEMAP_SIZE_Y/32);
|
|
}
|
|
}break;
|
|
case GameState::EDITOR:{
|
|
if (GetKey(K1).bPressed) {
|
|
EDITING_LAYER=layer::COLLISION;
|
|
EnableLayer(layer::COLLISION,true);
|
|
SetLayerTint(layer::COLLISION,{255,0,0,215});
|
|
}
|
|
if (GetKey(K2).bPressed) {
|
|
EDITING_LAYER=layer::HIGH;
|
|
EnableLayer(layer::COLLISION,false);
|
|
}
|
|
if (GetKey(K3).bPressed) {
|
|
EDITING_LAYER=layer::DYNAMIC;
|
|
EnableLayer(layer::COLLISION,false);
|
|
}
|
|
if (GetKey(K4).bPressed) {
|
|
EDITING_LAYER=layer::GROUND;
|
|
EnableLayer(layer::COLLISION,false);
|
|
}
|
|
if (GetKey(K5).bPressed) {
|
|
EDITING_LAYER=layer::BACKGROUND;
|
|
EnableLayer(layer::COLLISION,false);
|
|
}
|
|
if (GetKey(ESCAPE).bPressed) {
|
|
GAME_STATE=GameState::OBJ_SELECT;
|
|
}
|
|
if (EDITING_LAYER==layer::OBJECT&&GetMouse(0).bPressed) {
|
|
OBJECTS.push_back(CreateObject(SELECTED_OBJ_ID,HIGHLIGHTED_TILE*32));
|
|
} else
|
|
if (EDITING_LAYER==layer::OBJECT&&GetMouse(1).bReleased) {
|
|
for (int i=0;i<OBJECTS.size();i++) {
|
|
if (OBJECTS[i]->pos==HIGHLIGHTED_TILE*32) {
|
|
delete OBJECTS[i];
|
|
OBJECTS.erase(OBJECTS.begin()+i--);
|
|
}
|
|
}
|
|
}
|
|
}break;
|
|
case GameState::OBJ_SELECT:{
|
|
if (GetKey(ESCAPE).bPressed) {
|
|
GAME_STATE=GameState::EDITOR;
|
|
}
|
|
if ((GetMouseWheel()<0||GetKey(PGDN).bHeld)&&OBJ_DISPLAY_OFFSET+(WIDTH/16)<OBJ_INFO.size()) {
|
|
OBJ_DISPLAY_OFFSET+=WIDTH/16;
|
|
} else
|
|
if ((GetMouseWheel()>0||GetKey(PGUP).bHeld)&&OBJ_DISPLAY_OFFSET-(WIDTH/16)>=0) {
|
|
OBJ_DISPLAY_OFFSET-=WIDTH/16;
|
|
}
|
|
}break;
|
|
}
|
|
}
|
|
|
|
void drawGame(){
|
|
for (auto&obj:OBJECTS) {
|
|
obj->drawn=false;
|
|
}
|
|
switch (GAME_STATE) {
|
|
case GameState::EDITOR:{
|
|
for (int y=-1;y<HEIGHT/32+2;y++) {
|
|
int yTileOffset = cameraPos.y/32;
|
|
for (auto&obj:OBJECTS) {
|
|
if (!obj->drawn&&obj->pos.y+obj->originPoint.y>(y+yTileOffset)*32&&obj->pos.y+obj->originPoint.y<=(y+yTileOffset+1)*32) {
|
|
obj->drawn=true;
|
|
SetDrawTarget(layer::DYNAMIC);
|
|
DrawPartialDecal(obj->pos-cameraPos,obj->spr->spr,{(obj->frameIndex%obj->spr->frames)*obj->spr->width,0},{obj->spr->width,obj->spr->spr->sprite->height},obj->scale,obj->color);
|
|
}
|
|
}
|
|
for (int x=-1;x<WIDTH/32+2;x++) {
|
|
int xTileOffset = cameraPos.x/32;
|
|
if (x+xTileOffset>=0&&x+xTileOffset<MAP_WIDTH&&y+yTileOffset>=0&&y+yTileOffset<MAP_HEIGHT) {
|
|
if(MAP5[y+yTileOffset][x+xTileOffset]->tileX*MAP5[y+yTileOffset][x+xTileOffset]->tileY!=225) {
|
|
SetDrawTarget(layer::COLLISION);
|
|
DrawPartialSprite({x*32-fmod(cameraPos.x,32),y*32-fmod(cameraPos.y,32)},SPRITES[TILESET1]->sprite,{MAP5[y+yTileOffset][x+xTileOffset]->tileX*32,MAP5[y+yTileOffset][x+xTileOffset]->tileY*32},{32,32});
|
|
}
|
|
if(MAP4[y+yTileOffset][x+xTileOffset]->tileX*MAP4[y+yTileOffset][x+xTileOffset]->tileY!=225) {
|
|
SetDrawTarget(layer::BACKGROUND);
|
|
DrawPartialDecal({x*32-fmod(cameraPos.x,32),y*32-fmod(cameraPos.y,32)},SPRITES[TILESET1],{MAP4[y+yTileOffset][x+xTileOffset]->tileX*32,MAP4[y+yTileOffset][x+xTileOffset]->tileY*32},{32,32});
|
|
}
|
|
if(MAP3[y+yTileOffset][x+xTileOffset]->tileX*MAP3[y+yTileOffset][x+xTileOffset]->tileY!=225) {
|
|
SetDrawTarget(layer::GROUND);
|
|
DrawPartialDecal({x*32-fmod(cameraPos.x,32),y*32-fmod(cameraPos.y,32)},SPRITES[TILESET1],{MAP3[y+yTileOffset][x+xTileOffset]->tileX*32,MAP3[y+yTileOffset][x+xTileOffset]->tileY*32},{32,32});
|
|
}
|
|
if(MAP2[y+yTileOffset][x+xTileOffset]->tileX*MAP2[y+yTileOffset][x+xTileOffset]->tileY!=225) {
|
|
SetDrawTarget(layer::DYNAMIC);
|
|
DrawPartialDecal({x*32-fmod(cameraPos.x,32),y*32-fmod(cameraPos.y,32)},SPRITES[TILESET1],{MAP2[y+yTileOffset][x+xTileOffset]->tileX*32,MAP2[y+yTileOffset][x+xTileOffset]->tileY*32},{32,32});
|
|
}
|
|
if(MAP[y+yTileOffset][x+xTileOffset]->tileX*MAP[y+yTileOffset][x+xTileOffset]->tileY!=225) {
|
|
SetDrawTarget(layer::HIGH);
|
|
DrawPartialDecal({x*32-fmod(cameraPos.x,32),y*32-fmod(cameraPos.y,32)},SPRITES[TILESET1],{MAP[y+yTileOffset][x+xTileOffset]->tileX*32,MAP[y+yTileOffset][x+xTileOffset]->tileY*32},{32,32});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
SetDrawTarget(nullptr);
|
|
DrawRectDecal((HIGHLIGHTED_TILE)*32-cameraPos,{32,32},YELLOW);
|
|
if (EDITING_LAYER==layer::OBJECT) {
|
|
DrawStringPropDecal({2,2},"Editing Layer "+std::to_string(EDITING_LAYER));
|
|
} else {
|
|
DrawStringPropDecal({2,2},"Editing Layer "+std::to_string(EDITING_LAYER));
|
|
}
|
|
}break;
|
|
case GameState::TILE_SELECT:{
|
|
//14x14 pixels per tile.
|
|
DrawDecal({0,0},SPRITES[TILESET1],{TILEMAP_EDITOR_DRAW_MULT,TILEMAP_EDITOR_DRAW_MULT});
|
|
DrawRectDecal(SELECTED_TILE*(TILEMAP_EDITOR_TILESIZE),{TILEMAP_EDITOR_TILESIZE,TILEMAP_EDITOR_TILESIZE},RED);
|
|
}break;
|
|
case GameState::OBJ_SELECT:{
|
|
vd2d drawpos={0,0};
|
|
int counter=0;
|
|
for (std::map<int,Object*>::const_iterator it = OBJ_INFO.cbegin();it!=OBJ_INFO.cend();++it){
|
|
if (counter<OBJ_DISPLAY_OFFSET) {
|
|
counter++;
|
|
continue;
|
|
}
|
|
if (drawpos.y>HEIGHT) {
|
|
break;
|
|
}
|
|
Object*obj = it->second;
|
|
if (GetMouse(0).bHeld&&
|
|
GetMousePos().x>=drawpos.x&&
|
|
GetMousePos().x<drawpos.x+16&&
|
|
GetMousePos().y>=drawpos.y&&
|
|
GetMousePos().y<drawpos.y+24) {
|
|
SELECTED_OBJ_ID=obj->id;
|
|
EDITING_LAYER=layer::OBJECT;
|
|
}
|
|
FillRectDecal(drawpos,{16,24},VERY_DARK_GREY);
|
|
DrawPartialDecal({drawpos.x,drawpos.y+8},{16,16},obj->spr->spr,{(obj->frameIndex%obj->spr->frames)*obj->spr->width,0},{obj->spr->width,obj->spr->spr->sprite->height},obj->color);
|
|
DrawStringDecal({drawpos.x+2,drawpos.y},obj->name,WHITE,{12.0/GetTextSize(obj->name).x,1.0});
|
|
if (SELECTED_OBJ_ID==obj->id) {
|
|
DrawRectDecal(drawpos,{16,24},YELLOW);
|
|
}
|
|
drawpos.x+=16;
|
|
if (drawpos.x>=WIDTH) {
|
|
drawpos.x=0;
|
|
drawpos.y+=24;
|
|
}
|
|
counter++;
|
|
}
|
|
}break;
|
|
}
|
|
};
|
|
|
|
void LoadMap(Map*map) {
|
|
std::ifstream f("assets/maps/"+map->filename,std::ios::binary);
|
|
std::ifstream f2("assets/maps/"+map->l2filename,std::ios::binary);
|
|
std::ifstream f3("assets/maps/"+map->l3filename,std::ios::binary);
|
|
std::ifstream f4("assets/maps/"+map->l4filename,std::ios::binary);
|
|
std::ifstream f5("assets/maps/"+map->l5filename,std::ios::binary);
|
|
for (int i=0;i<MAP.size();i++) {
|
|
for (int j=0;j<MAP[i].size();j++) {
|
|
delete MAP[i][j];
|
|
}
|
|
MAP[i].clear();
|
|
}
|
|
for (int i=0;i<MAP2.size();i++) {
|
|
for (int j=0;j<MAP2[i].size();j++) {
|
|
delete MAP2[i][j];
|
|
}
|
|
MAP2[i].clear();
|
|
}
|
|
for (int i=0;i<MAP3.size();i++) {
|
|
for (int j=0;j<MAP3[i].size();j++) {
|
|
delete MAP3[i][j];
|
|
}
|
|
MAP3[i].clear();
|
|
}
|
|
for (int i=0;i<MAP4.size();i++) {
|
|
for (int j=0;j<MAP4[i].size();j++) {
|
|
delete MAP4[i][j];
|
|
}
|
|
MAP4[i].clear();
|
|
}
|
|
for (int i=0;i<MAP5.size();i++) {
|
|
for (int j=0;j<MAP5[i].size();j++) {
|
|
delete MAP5[i][j];
|
|
}
|
|
MAP5[i].clear();
|
|
}
|
|
MAP_WIDTH=-1;
|
|
MAP_HEIGHT=-1;
|
|
MAP.clear();
|
|
std::string data;
|
|
while (f.good()) {
|
|
f>>data;
|
|
if (MAP_WIDTH==-1) {
|
|
MAP_WIDTH=data.length()/2;
|
|
printf("Map Width: %d\n",MAP_WIDTH);
|
|
}
|
|
if (data.find("OBJECT")!=std::string::npos) {
|
|
int marker=data.find_first_of(';');
|
|
int lastMarker=marker;
|
|
std::stringstream split1(data.substr(6,marker-6));
|
|
marker=data.find_first_of(';',marker+1);
|
|
std::stringstream split2(data.substr(lastMarker+1,marker-lastMarker-1));
|
|
lastMarker=marker;
|
|
marker=data.find_first_of(';',marker+1);
|
|
std::stringstream split3(data.substr(lastMarker+1,marker-lastMarker-1));
|
|
lastMarker=marker;
|
|
double x,y;
|
|
|
|
split1>>x;
|
|
split2>>y;
|
|
|
|
int id;
|
|
split3>>id;
|
|
|
|
bool enabled=true;
|
|
if (OBJ_INFO[id]->disableFlag!=Flag::NONE) {
|
|
if (GAME_FLAGS[OBJ_INFO[id]->disableFlag]) {
|
|
enabled=false;
|
|
}
|
|
}
|
|
if (OBJ_INFO[id]->enableFlag!=Flag::NONE) {
|
|
if (!GAME_FLAGS[OBJ_INFO[id]->enableFlag]) {
|
|
enabled=false;
|
|
}
|
|
}
|
|
if (enabled) {
|
|
OBJECTS.push_back(CreateObject(id,{x,y}));
|
|
}
|
|
printf("Object %s Loaded.\n",OBJ_INFO[id]->name.c_str());
|
|
} else {
|
|
std::vector<TILE*> tiles;
|
|
printf("%s\n",data.c_str());
|
|
for (int i=0;i<data.length();i+=2) {
|
|
unsigned char tileX,tileY;
|
|
tileX=data[i]-'0';
|
|
tileY=data[i+1]-'0';
|
|
tiles.push_back(new TILE(tileX,tileY));
|
|
}
|
|
MAP.push_back(tiles);
|
|
MAP_HEIGHT++;
|
|
}
|
|
}
|
|
while (f2.good()) {
|
|
f2>>data;
|
|
std::vector<TILE*> tiles;
|
|
for (int i=0;i<data.length();i+=2) {
|
|
unsigned char tileX,tileY;
|
|
tileX=data[i]-'0';
|
|
tileY=data[i+1]-'0';
|
|
tiles.push_back(new TILE(tileX,tileY));
|
|
}
|
|
MAP2.push_back(tiles);
|
|
}
|
|
while (f3.good()) {
|
|
f3>>data;
|
|
std::vector<TILE*> tiles;
|
|
for (int i=0;i<data.length();i+=2) {
|
|
unsigned char tileX,tileY;
|
|
tileX=data[i]-'0';
|
|
tileY=data[i+1]-'0';
|
|
tiles.push_back(new TILE(tileX,tileY));
|
|
}
|
|
MAP3.push_back(tiles);
|
|
}
|
|
while (f4.good()) {
|
|
f4>>data;
|
|
std::vector<TILE*> tiles;
|
|
for (int i=0;i<data.length();i+=2) {
|
|
unsigned char tileX,tileY;
|
|
tileX=data[i]-'0';
|
|
tileY=data[i+1]-'0';
|
|
tiles.push_back(new TILE(tileX,tileY));
|
|
}
|
|
MAP4.push_back(tiles);
|
|
}
|
|
while (f5.good()) {
|
|
f5>>data;
|
|
std::vector<TILE*> tiles;
|
|
for (int i=0;i<data.length();i+=2) {
|
|
unsigned char tileX,tileY;
|
|
tileX=data[i]-'0';
|
|
tileY=data[i+1]-'0';
|
|
tiles.push_back(new TILE(tileX,tileY));
|
|
}
|
|
MAP5.push_back(tiles);
|
|
}
|
|
printf("Loaded map %s.\n",map->filename.c_str());
|
|
f.close();
|
|
f2.close();
|
|
f3.close();
|
|
f4.close();
|
|
f5.close();
|
|
}
|
|
|
|
void SaveMap(Map*map) {
|
|
std::ofstream f("assets/maps/"+map->filename,std::ios::binary);
|
|
std::ofstream f2("assets/maps/"+map->l2filename,std::ios::binary);
|
|
std::ofstream f3("assets/maps/"+map->l3filename,std::ios::binary);
|
|
std::ofstream f4("assets/maps/"+map->l4filename,std::ios::binary);
|
|
std::ofstream f5("assets/maps/"+map->l5filename,std::ios::binary);
|
|
|
|
printf("Map width: %d, Map Height: %d::\n",MAP_WIDTH,MAP_HEIGHT);
|
|
for (int y=0;y<MAP_HEIGHT;y++) {
|
|
for (int x=0;x<MAP_WIDTH;x++) {
|
|
f.put(MAP[y][x]->tileX+'0');f.put(MAP[y][x]->tileY+'0');
|
|
f2.put(MAP2[y][x]->tileX+'0');f2.put(MAP2[y][x]->tileY+'0');
|
|
f3.put(MAP3[y][x]->tileX+'0');f3.put(MAP3[y][x]->tileY+'0');
|
|
f4.put(MAP4[y][x]->tileX+'0');f4.put(MAP4[y][x]->tileY+'0');
|
|
f5.put(MAP5[y][x]->tileX+'0');f5.put(MAP5[y][x]->tileY+'0');
|
|
}
|
|
if (y!=MAP_HEIGHT-1) {
|
|
f.put('\n');
|
|
f2.put('\n');
|
|
f3.put('\n');
|
|
f4.put('\n');
|
|
f5.put('\n');
|
|
}
|
|
}
|
|
|
|
for (int i=0;i<OBJECTS.size();i++) {
|
|
f.put('\n');
|
|
const std::string obj="OBJECT"+std::to_string(OBJECTS[i]->pos.x)+";"+std::to_string(OBJECTS[i]->pos.y)+";"+std::to_string(OBJECTS[i]->id);
|
|
for (int i=0;i<obj.length();i++) {
|
|
f.put(obj[i]);
|
|
}
|
|
}
|
|
|
|
f.close();
|
|
f2.close();
|
|
f3.close();
|
|
f4.close();
|
|
f5.close();
|
|
}
|
|
|
|
Decal*CreateSprite(std::string spriteName) {
|
|
return new Decal(new Sprite("assets/"+spriteName));
|
|
}
|
|
|
|
Object*CreateObject(int id,vd2d pos) {
|
|
return new Object(id,OBJ_INFO[id]->name,pos,OBJ_INFO[id]->spr,OBJ_INFO[id]->scale,OBJ_INFO[id]->color,OBJ_INFO[id]->animationSpd);
|
|
}
|
|
|
|
Object*CreateObjectInfo(Reference ref,std::string name,vd2d pos,std::string spriteFileName,int sprWidth,vd2d scale={1,1},Pixel tint=WHITE,int enableFlag=Flag::NONE,int disableFlag=Flag::NONE,int animationDelay=1) {
|
|
ANIMATIONS[ref] = new Animation(SPRITES[ref]=CreateSprite("player.png"),32);
|
|
Object*newObj = new Object(ref,name,pos,ANIMATIONS[ref],scale,tint,animationDelay);
|
|
newObj->disableFlag=disableFlag;
|
|
newObj->enableFlag=enableFlag;
|
|
OBJ_INFO[ref]=newObj;
|
|
return newObj;
|
|
}
|
|
|
|
|
|
void SetupAnimations() {
|
|
SPRITES[TILESET1] = CreateSprite("terrainmap.png");
|
|
}
|
|
|
|
void SetupObjectInfo() {
|
|
CreateObjectInfo(PLAYER,"player",{0,0},"player.png",32,{1,1},WHITE);
|
|
CreateObjectInfo(NPC1,"npc1",{0,0},"player.png",32,{1,1},RED,Flag::NONE,Flag::NONE,60);
|
|
CreateObjectInfo(NPC2,"npc2",{0,0},"player.png",32,{1,1},GREEN,Flag::NONE,Flag::NONE,2);
|
|
CreateObjectInfo(NPC3,"npc3",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC4,"npc4",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC5,"npc5",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC6,"npc6",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC7,"npc7",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC8,"npc8",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC9,"npc9",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC10,"npc10",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC11,"npc11",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC12,"npc12",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC13,"npc13",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC13,"npc14",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC14,"npc15",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC15,"npc16",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC16,"npc17",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC17,"npc18",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC18,"npc19",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC19,"npc20",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC1_2,"npc1_2",{0,0},"player.png",32,{1,1},RED,Flag::NONE,Flag::NONE,60);
|
|
CreateObjectInfo(NPC2_2,"npc2_2",{0,0},"player.png",32,{1,1},GREEN,Flag::NONE,Flag::NONE,2);
|
|
CreateObjectInfo(NPC3_2,"npc3_2",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC4_2,"npc4_2",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC5_2,"npc5_2",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC6_2,"npc6_2",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC7_2,"npc7_2",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC8_2,"npc8_2",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC9_2,"npc9_2",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC10_2,"npc10_2",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC11_2,"npc11_2",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC12_2,"npc12_2",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC13_2,"npc13_2",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC13_2,"npc14_2",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC14_2,"npc15_2",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC15_2,"npc16_2",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC16_2,"npc17_2",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC17_2,"npc18_2",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC18_2,"npc19_2",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC19_2,"npc20_2",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC1_3,"npc1_3",{0,0},"player.png",32,{1,1},RED,Flag::NONE,Flag::NONE,60);
|
|
CreateObjectInfo(NPC2_3,"npc2_3",{0,0},"player.png",32,{1,1},GREEN,Flag::NONE,Flag::NONE,2);
|
|
CreateObjectInfo(NPC3_3,"npc3_3",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC4_3,"npc4_3",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC5_3,"npc5_3",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC6_3,"npc6_3",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC7_3,"npc7_3",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC8_3,"npc8_3",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC9_3,"npc9_3",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC10_3,"npc10_3",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC11_3,"npc11_3",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC12_3,"npc12_3",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC13_3,"npc13_3",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC13_3,"npc14_3",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC14_3,"npc15_3",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC15_3,"npc16_3",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC16_3,"npc17_3",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC17_3,"npc18_3",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC18_3,"npc19_3",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC19_3,"npc20_3",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC1_4,"npc1_4",{0,0},"player.png",32,{1,1},RED,Flag::NONE,Flag::NONE,60);
|
|
CreateObjectInfo(NPC2_4,"npc2_4",{0,0},"player.png",32,{1,1},GREEN,Flag::NONE,Flag::NONE,2);
|
|
CreateObjectInfo(NPC3_4,"npc3_4",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC4_4,"npc4_4",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC5_4,"npc5_4",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC6_4,"npc6_4",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC7_4,"npc7_4",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC8_4,"npc8_4",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC9_4,"npc9_4",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC10_4,"npc10_4",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC11_4,"npc11_4",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC12_4,"npc12_4",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC13_4,"npc13_4",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC13_4,"npc14_4",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC14_4,"npc15_4",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC15_4,"npc16_4",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC16_4,"npc17_4",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC17_4,"npc18_4",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC18_4,"npc19_4",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC19_4,"npc20_4",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC1_5,"npc1_5",{0,0},"player.png",32,{1,1},RED,Flag::NONE,Flag::NONE,60);
|
|
CreateObjectInfo(NPC2_5,"npc2_5",{0,0},"player.png",32,{1,1},GREEN,Flag::NONE,Flag::NONE,2);
|
|
CreateObjectInfo(NPC3_5,"npc3_5",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC4_5,"npc4_5",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC5_5,"npc5_5",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC6_5,"npc6_5",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC7_5,"npc7_5",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC8_5,"npc8_5",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC9_5,"npc9_5",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC10_5,"npc10_5",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC11_5,"npc11_5",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC12_5,"npc12_5",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC13_5,"npc13_5",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC13_5,"npc14_5",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC14_5,"npc15_5",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC15_5,"npc16_5",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC16_5,"npc17_5",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC17_5,"npc18_5",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC18_5,"npc19_5",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC19_5,"npc20_5",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC1_6,"npc1_6",{0,0},"player.png",32,{1,1},RED,Flag::NONE,Flag::NONE,60);
|
|
CreateObjectInfo(NPC2_6,"npc2_6",{0,0},"player.png",32,{1,1},GREEN,Flag::NONE,Flag::NONE,2);
|
|
CreateObjectInfo(NPC3_6,"npc3_6",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC4_6,"npc4_6",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC5_6,"npc5_6",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC6_6,"npc6_6",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC7_6,"npc7_6",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC8_6,"npc8_6",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC9_6,"npc9_6",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC10_6,"npc10_6",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC11_6,"npc11_6",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC12_6,"npc12_6",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC13_6,"npc13_6",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC13_6,"npc14_6",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC14_6,"npc15_6",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC15_6,"npc16_6",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC16_6,"npc17_6",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC17_6,"npc18_6",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC18_6,"npc19_6",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC19_6,"npc20_6",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC1_7,"npc1_7",{0,0},"player.png",32,{1,1},RED,Flag::NONE,Flag::NONE,60);
|
|
CreateObjectInfo(NPC2_7,"npc2_7",{0,0},"player.png",32,{1,1},GREEN,Flag::NONE,Flag::NONE,2);
|
|
CreateObjectInfo(NPC3_7,"npc3_7",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC4_7,"npc4_7",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC5_7,"npc5_7",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC6_7,"npc6_7",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC7_7,"npc7_7",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC8_7,"npc8_7",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC9_7,"npc9_7",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC10_7,"npc10_7",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC11_7,"npc11_7",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC12_7,"npc12_7",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC13_7,"npc13_7",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC13_7,"npc14_7",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC14_7,"npc15_7",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC15_7,"npc16_7",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC16_7,"npc17_7",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC17_7,"npc18_7",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC18_7,"npc19_7",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC19_7,"npc20_7",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC1_8,"npc1_8",{0,0},"player.png",32,{1,1},RED,Flag::NONE,Flag::NONE,60);
|
|
CreateObjectInfo(NPC2_8,"npc2_8",{0,0},"player.png",32,{1,1},GREEN,Flag::NONE,Flag::NONE,2);
|
|
CreateObjectInfo(NPC3_8,"npc3_8",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC4_8,"npc4_8",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC5_8,"npc5_8",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC6_8,"npc6_8",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC7_8,"npc7_8",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC8_8,"npc8_8",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC9_8,"npc9_8",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC10_8,"npc10_8",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC11_8,"npc11_8",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC12_8,"npc12_8",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC13_8,"npc13_8",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC13_8,"npc14_8",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC14_8,"npc15_8",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC15_8,"npc16_8",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC16_8,"npc17_8",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC17_8,"npc18_8",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC18_8,"npc19_8",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
CreateObjectInfo(NPC19_8,"npc20_8",{0,0},"player.png",32,{2,2},BLUE,Flag::NONE,Flag::NONE,0);
|
|
}
|
|
|
|
bool Collision(vd2d pos) {
|
|
SetDrawTarget(layer::COLLISION);
|
|
Pixel collisionData = GetDrawTarget()->GetPixel((int)pos.x-cameraPos.x,(int)pos.y-cameraPos.y);
|
|
return collisionData!=MAGENTA;
|
|
}
|
|
|
|
|
|
bool TabHeld(){
|
|
return GetKey(TAB).bHeld;
|
|
}
|
|
bool UpPressed(){
|
|
return GetKey(W).bPressed||GetKey(UP).bPressed||GetKey(NP8).bPressed||MOUSE_PRESSED_DOWN&&GetMouseY()<=HEIGHT-128+32&&GetMouseY()>=HEIGHT-128&&GetMouseX()<=HEIGHT-128;
|
|
}
|
|
bool DownPressed(){
|
|
return GetKey(S).bPressed||GetKey(DOWN).bPressed||GetKey(NP5).bPressed||GetKey(NP2).bPressed||MOUSE_PRESSED_DOWN&&GetMouseY()<=HEIGHT&&GetMouseY()>=HEIGHT-32&&GetMouseX()<=HEIGHT-128;
|
|
}
|
|
bool LeftPressed(){
|
|
return GetKey(A).bPressed||GetKey(LEFT).bPressed||GetKey(NP4).bPressed||MOUSE_PRESSED_DOWN&&GetMouseX()<=32&&GetMouseX()>=0&&GetMouseY()>=HEIGHT-128;
|
|
}
|
|
bool RightPressed(){
|
|
return GetKey(D).bPressed||GetKey(RIGHT).bPressed||GetKey(NP6).bPressed||MOUSE_PRESSED_DOWN&&GetMouseX()<=128&&GetMouseX()>=96&&GetMouseY()>=HEIGHT-128;
|
|
}
|
|
bool UpHeld(){
|
|
return GetKey(W).bHeld||GetKey(UP).bHeld||GetKey(NP8).bHeld||MOUSE_DOWN&&GetMouseY()<=HEIGHT-128+32&&GetMouseY()>=HEIGHT-128&&GetMouseX()<=HEIGHT-128;
|
|
}
|
|
bool DownHeld(){
|
|
return GetKey(S).bHeld||GetKey(DOWN).bHeld||GetKey(NP5).bHeld||GetKey(NP2).bHeld||MOUSE_DOWN&&GetMouseY()<=HEIGHT&&GetMouseY()>=HEIGHT-32&&GetMouseX()<=HEIGHT-128;
|
|
}
|
|
bool LeftHeld(){
|
|
return GetKey(A).bHeld||GetKey(LEFT).bHeld||GetKey(NP4).bHeld||MOUSE_DOWN&&GetMouseX()<=32&&GetMouseX()>=0&&GetMouseY()>=HEIGHT-128;
|
|
}
|
|
bool RightHeld(){
|
|
return GetKey(D).bHeld||GetKey(RIGHT).bHeld||GetKey(NP6).bHeld||MOUSE_DOWN&&GetMouseX()<=128&&GetMouseX()>=96&&GetMouseY()>=HEIGHT-128;
|
|
}
|
|
bool UpReleased(){
|
|
return GetKey(W).bReleased||GetKey(UP).bReleased||GetKey(NP8).bReleased||MOUSE_RELEASED&&GetMouseY()<=HEIGHT-128+32&&GetMouseY()>=HEIGHT-128&&GetMouseX()<=HEIGHT-128;
|
|
}
|
|
bool DownReleased(){
|
|
return GetKey(S).bReleased||GetKey(DOWN).bReleased||GetKey(NP5).bReleased||GetKey(NP2).bReleased||MOUSE_RELEASED&&GetMouseY()<=HEIGHT&&GetMouseY()>=HEIGHT-32&&GetMouseX()<=HEIGHT-128;
|
|
}
|
|
bool LeftReleased(){
|
|
return GetKey(A).bReleased||GetKey(LEFT).bReleased||GetKey(NP4).bReleased||MOUSE_RELEASED&&GetMouseX()<=32&&GetMouseX()>=0&&GetMouseY()>=HEIGHT-128;
|
|
}
|
|
bool RightReleased(){
|
|
return GetKey(D).bReleased||GetKey(RIGHT).bReleased||GetKey(NP6).bReleased||MOUSE_RELEASED&&GetMouseX()<=128&&GetMouseX()>=96&&GetMouseY()>=HEIGHT-128;
|
|
}
|
|
};
|
|
|
|
|
|
int main()
|
|
{
|
|
SeasonI demo;
|
|
if (demo.Construct(WIDTH, HEIGHT, 4, 4))
|
|
demo.Start();
|
|
|
|
return 0;
|
|
} |