generated from sigonasr2/CPlusPlusProjectTemplate
Corrected bug with loading players via game loading for less than 4 player countrs
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
e1a2237684
commit
d7ba1b4ded
Binary file not shown.
@ -4,8 +4,8 @@
|
|||||||
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????:4:4:4:4;6????
|
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????:4:4:4:4;6????
|
||||||
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????;4????
|
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????;4????
|
||||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????=6>6>6>6?6????;4????
|
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????=6>6>6>6?6????;4????
|
||||||
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????=6=7<2=2>2?7?6??;4????
|
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????=6=7=9=2?9?7?6??;4????
|
||||||
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????=7>6>6>6>6>6?7??;4????
|
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????=7>8>6>6>6>9?7??;4????
|
||||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????8282??;4????
|
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????8282??;4????
|
||||||
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????5<6<6<7<;4????
|
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????5<6<6<7<;4????
|
||||||
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 156 KiB After Width: | Height: | Size: 157 KiB |
Binary file not shown.
32
main.cpp
32
main.cpp
@ -961,7 +961,8 @@ void SeasonI::LoadMap(Map*map) {
|
|||||||
unsigned char tileX,tileY;
|
unsigned char tileX,tileY;
|
||||||
tileX=data[i]-'0';
|
tileX=data[i]-'0';
|
||||||
tileY=data[i+1]-'0';
|
tileY=data[i+1]-'0';
|
||||||
tiles.push_back(new TILE(tileX,tileY));
|
|
||||||
|
tiles.push_back(new TILE(tileX,tileY,TILE::GetTileDegree(map,tileX,tileY)));
|
||||||
}
|
}
|
||||||
MAP.push_back(tiles);
|
MAP.push_back(tiles);
|
||||||
MAP_HEIGHT++;
|
MAP_HEIGHT++;
|
||||||
@ -975,7 +976,7 @@ void SeasonI::LoadMap(Map*map) {
|
|||||||
unsigned char tileX,tileY;
|
unsigned char tileX,tileY;
|
||||||
tileX=data[i]-'0';
|
tileX=data[i]-'0';
|
||||||
tileY=data[i+1]-'0';
|
tileY=data[i+1]-'0';
|
||||||
tiles.push_back(new TILE(tileX,tileY));
|
tiles.push_back(new TILE(tileX,tileY,TILE::GetTileDegree(map,tileX,tileY)));
|
||||||
}
|
}
|
||||||
MAP2.push_back(tiles);
|
MAP2.push_back(tiles);
|
||||||
}
|
}
|
||||||
@ -986,7 +987,7 @@ void SeasonI::LoadMap(Map*map) {
|
|||||||
unsigned char tileX,tileY;
|
unsigned char tileX,tileY;
|
||||||
tileX=data[i]-'0';
|
tileX=data[i]-'0';
|
||||||
tileY=data[i+1]-'0';
|
tileY=data[i+1]-'0';
|
||||||
tiles.push_back(new TILE(tileX,tileY));
|
tiles.push_back(new TILE(tileX,tileY,TILE::GetTileDegree(map,tileX,tileY)));
|
||||||
}
|
}
|
||||||
MAP3.push_back(tiles);
|
MAP3.push_back(tiles);
|
||||||
}
|
}
|
||||||
@ -997,7 +998,7 @@ void SeasonI::LoadMap(Map*map) {
|
|||||||
unsigned char tileX,tileY;
|
unsigned char tileX,tileY;
|
||||||
tileX=data[i]-'0';
|
tileX=data[i]-'0';
|
||||||
tileY=data[i+1]-'0';
|
tileY=data[i+1]-'0';
|
||||||
tiles.push_back(new TILE(tileX,tileY));
|
tiles.push_back(new TILE(tileX,tileY,TILE::GetTileDegree(map,tileX,tileY)));
|
||||||
}
|
}
|
||||||
MAP4.push_back(tiles);
|
MAP4.push_back(tiles);
|
||||||
}
|
}
|
||||||
@ -1008,7 +1009,7 @@ void SeasonI::LoadMap(Map*map) {
|
|||||||
unsigned char tileX,tileY;
|
unsigned char tileX,tileY;
|
||||||
tileX=data[i]-'0';
|
tileX=data[i]-'0';
|
||||||
tileY=data[i+1]-'0';
|
tileY=data[i+1]-'0';
|
||||||
tiles.push_back(new TILE(tileX,tileY));
|
tiles.push_back(new TILE(tileX,tileY,TILE::GetTileDegree(map,tileX,tileY)));
|
||||||
}
|
}
|
||||||
MAP5.push_back(tiles);
|
MAP5.push_back(tiles);
|
||||||
}
|
}
|
||||||
@ -1019,7 +1020,7 @@ void SeasonI::LoadMap(Map*map) {
|
|||||||
unsigned char tileX,tileY;
|
unsigned char tileX,tileY;
|
||||||
tileX=data[i]-'0';
|
tileX=data[i]-'0';
|
||||||
tileY=data[i+1]-'0';
|
tileY=data[i+1]-'0';
|
||||||
tiles.push_back(new TILE(tileX,tileY));
|
tiles.push_back(new TILE(tileX,tileY,TILE::GetTileDegree(map,tileX,tileY)));
|
||||||
}
|
}
|
||||||
MAP6.push_back(tiles);
|
MAP6.push_back(tiles);
|
||||||
}
|
}
|
||||||
@ -4585,7 +4586,14 @@ void SeasonI::DrawGameWorld() {
|
|||||||
for (int y=-1;y<HEIGHT/32+2;y++) {
|
for (int y=-1;y<HEIGHT/32+2;y++) {
|
||||||
int yTileOffset = cameraPos.y/32;
|
int yTileOffset = cameraPos.y/32;
|
||||||
for (auto&obj:OBJECTS) {
|
for (auto&obj:OBJECTS) {
|
||||||
if (!obj->drawn&&(!obj->dead||EDITING_LAYER==layer::ENCOUNTER)&&obj->GetPos().y+obj->originPoint.y>(y+yTileOffset)*32&&obj->GetPos().y+obj->originPoint.y<=(y+yTileOffset+1)*32) {
|
if (!obj->drawn&&(!obj->dead||EDITING_LAYER==layer::ENCOUNTER)&&
|
||||||
|
(MAP2[y+yTileOffset][(obj->GetPos().x+obj->originPoint.x)/32]->tileDegree==0&&
|
||||||
|
obj->GetPos().y+obj->originPoint.y>(y+yTileOffset)*32&&
|
||||||
|
obj->GetPos().y+obj->originPoint.y<=(y+yTileOffset+1)*32||
|
||||||
|
MAP2[y+yTileOffset][(obj->GetPos().x+obj->originPoint.x)/32]->tileDegree==-1&& //y=-x+b Check if 32-x position is greater than our y.
|
||||||
|
((int)(obj->GetPos().x+obj->originPoint.x)%32<32-(int)(obj->GetPos().y+obj->originPoint.y)%32)/*||
|
||||||
|
y+yTileOffset<(int)(obj->GetPos().y+obj->originPoint.y)/32*/)) {
|
||||||
|
printf("%d<%d\n",(int)(obj->GetPos().x+obj->originPoint.x)%32,32-(int)(obj->GetPos().y+obj->originPoint.y)%32);
|
||||||
obj->drawn=true;
|
obj->drawn=true;
|
||||||
if (obj->blinkFrames>0) {
|
if (obj->blinkFrames>0) {
|
||||||
obj->blinkFrames--;
|
obj->blinkFrames--;
|
||||||
@ -4606,7 +4614,7 @@ void SeasonI::DrawGameWorld() {
|
|||||||
while (accY>=1) {
|
while (accY>=1) {
|
||||||
for (int xxx=0;xxx<accX;xxx++) {
|
for (int xxx=0;xxx<accX;xxx++) {
|
||||||
if (col.a>64) {
|
if (col.a>64) {
|
||||||
GetDrawTarget()->SetPixel(obj->GetPos().x-cameraPos.x+pixelOffsetX+xxx,obj->GetPos().y-cameraPos.y+pixelOffsetY,Pixel(255,255,255,abs(sin(M_PI/60*frameCount)*210)));
|
GetDrawTarget()->SetPixel(obj->GetPos().x-cameraPos.x+pixelOffsetX+xxx,obj->GetPos().y-cameraPos.y+pixelOffsetY,Pixel(255,255,255,std::abs(sin(M_PI/60*frameCount)*210)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
accY-=1;
|
accY-=1;
|
||||||
@ -5503,7 +5511,6 @@ void SeasonI::LoadGameSaveData(int saveSlot) {
|
|||||||
double xPos=ReadDoubleFromStream(file);
|
double xPos=ReadDoubleFromStream(file);
|
||||||
double yPos=ReadDoubleFromStream(file);
|
double yPos=ReadDoubleFromStream(file);
|
||||||
if (PARTY_MEMBER_STATS[i]->obj!=nullptr) {
|
if (PARTY_MEMBER_STATS[i]->obj!=nullptr) {
|
||||||
PARTY_MEMBER_STATS[i]->obj->SetPos({xPos,yPos});
|
|
||||||
positions[playerCount++]={xPos,yPos};
|
positions[playerCount++]={xPos,yPos};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5516,9 +5523,16 @@ void SeasonI::LoadGameSaveData(int saveSlot) {
|
|||||||
for (int i=0;i<gameFlagSize;i++) {
|
for (int i=0;i<gameFlagSize;i++) {
|
||||||
GAME_FLAGS[i]=ReadIntFromStream(file)?true:false;
|
GAME_FLAGS[i]=ReadIntFromStream(file)?true:false;
|
||||||
}
|
}
|
||||||
|
playerCount=0;
|
||||||
|
for (int f=(int)Flag::HAS_MAIN;f<(int)Flag::HAS_POO;f++) {
|
||||||
|
if (GetGameFlag((Flag)f)) {
|
||||||
|
playerCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
CURRENT_MAP=MAPS[(MapName::Map)ReadIntFromStream(file)];
|
CURRENT_MAP=MAPS[(MapName::Map)ReadIntFromStream(file)];
|
||||||
MONEY=ReadIntFromStream(file);
|
MONEY=ReadIntFromStream(file);
|
||||||
LoadMap(CURRENT_MAP);
|
LoadMap(CURRENT_MAP);
|
||||||
|
printf("Player count: %d\n",playerCount);
|
||||||
for (int i=0;i<playerCount;i++) {
|
for (int i=0;i<playerCount;i++) {
|
||||||
PARTY_MEMBER_OBJ[i]->SetPos(positions[i]);
|
PARTY_MEMBER_OBJ[i]->SetPos(positions[i]);
|
||||||
}
|
}
|
||||||
|
2
save0
2
save0
@ -1 +1 @@
|
|||||||
120 120 PLAYER 2 30 8 8 4 0 0 0 0 0 0 0 11 9 10 13 14 15 16 17 33 29 21 25 1 6 4 3 4 7 8 3428.04 408.473 120 120 NESS 30 30 8 8 4 0 0 0 0 0 0 0 6 33 34 29 30 31 32 0 3 -1 7 12 3441.04 408.473 120 120 PAULA 30 30 8 8 4 0 0 0 0 0 0 0 6 21 22 23 24 37 38 0 3 -1 7 -1 3453.04 408.473 120 120 JEFF 30 30 8 8 4 0 0 0 0 0 0 0 1 0 0 3 -1 -1 -1 -999 -999 120 120 ANNA 14 30 8 8 4 0 0 0 0 0 0 0 4 21 25 26 29 0 3 5 7 12 3465.04 408.473 120 120 KING 30 30 8 8 4 0 0 0 0 0 0 0 1 0 0 3 -1 -1 -1 -999 -999 120 120 POO 30 30 8 8 4 0 0 0 0 0 0 0 1 0 0 3 -1 -1 -1 -999 -999 47 6 7 7 7 7 7 7 7 7 7 7 6 3 3 3 10 10 10 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 2 2 2 2 2 2 2 11 0 0 512 1 1 0 0 1 1 1 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 748398 596691 PLAYER 0
|
24
tiles.h
24
tiles.h
@ -1,16 +1,30 @@
|
|||||||
#ifndef TILES_H
|
#ifndef TILES_H
|
||||||
#define TILES_H
|
#define TILES_H
|
||||||
#include "pixelGameEngine.h"
|
#include "pixelGameEngine.h"
|
||||||
|
#include "map.h"
|
||||||
using namespace olc;
|
using namespace olc;
|
||||||
|
|
||||||
|
extern std::map<std::string,Decal*> SPRITES;
|
||||||
|
|
||||||
class TILE{
|
class TILE{
|
||||||
public:
|
public:
|
||||||
int tileX;
|
int tileX;
|
||||||
int tileY;
|
int tileY;
|
||||||
char tileDegree;
|
char tileDegree=0; //-1 is slanted from bottom-left to top-right. 1 is slanted from top-left to bottom-right.
|
||||||
TILE(int tileX,int tileY) {
|
TILE(int tileX,int tileY,char tileDegree)
|
||||||
this->tileX=tileX;
|
:tileX(tileX),tileY(tileY),tileDegree(tileDegree){}
|
||||||
this->tileY=tileY;
|
static char GetTileDegree(Map*map,int tileX,int tileY) {
|
||||||
};
|
if (map->tileset==SPRITES["terrainmap.png"]) {
|
||||||
|
if (tileX==12&&tileY==0||
|
||||||
|
tileX==12&&tileY==1) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
if (tileX==14&&tileY==0||
|
||||||
|
tileX==14&&tileY==1) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
Loading…
x
Reference in New Issue
Block a user