mirror of
https://github.com/sigonasr2/hamster.git
synced 2025-04-16 05:49:17 -05:00
Added Stage 2, AI per-map difficulty settings.
This commit is contained in:
parent
9d56e9c564
commit
e3606ab931
44
Difficulty.h
Normal file
44
Difficulty.h
Normal file
@ -0,0 +1,44 @@
|
||||
#pragma region License
|
||||
/*
|
||||
License (OLC-3)
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions or derivations of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce the above
|
||||
copyright notice. This list of conditions and the following disclaimer must be
|
||||
reproduced in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
|
||||
Portions of this software are copyright © 2024 The FreeType
|
||||
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
|
||||
All rights reserved.
|
||||
*/
|
||||
#pragma endregion
|
||||
#pragma once
|
||||
|
||||
enum class Difficulty{
|
||||
EASY,
|
||||
MEDIUM,
|
||||
HARD,
|
||||
};
|
1
StageII.tmx.1
Normal file
1
StageII.tmx.1
Normal file
File diff suppressed because one or more lines are too long
@ -10,6 +10,18 @@
|
||||
"properties": [
|
||||
],
|
||||
"propertyTypes": [
|
||||
{
|
||||
"id": 9,
|
||||
"name": "Difficulty",
|
||||
"storageType": "int",
|
||||
"type": "enum",
|
||||
"values": [
|
||||
"EASY",
|
||||
"MEDIUM",
|
||||
"HARD"
|
||||
],
|
||||
"valuesAsFlags": false
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"name": "FacingDirection",
|
||||
@ -23,6 +35,26 @@
|
||||
],
|
||||
"valuesAsFlags": false
|
||||
},
|
||||
{
|
||||
"color": "#ffa0a0a4",
|
||||
"drawFill": true,
|
||||
"id": 8,
|
||||
"members": [
|
||||
{
|
||||
"name": "AI Difficulty",
|
||||
"propertyType": "Difficulty",
|
||||
"type": "int",
|
||||
"value": 0
|
||||
}
|
||||
],
|
||||
"name": "Map",
|
||||
"type": "class",
|
||||
"useAs": [
|
||||
"property",
|
||||
"map",
|
||||
"project"
|
||||
]
|
||||
},
|
||||
{
|
||||
"color": "#ffa0a0a4",
|
||||
"drawFill": true,
|
||||
|
@ -10,11 +10,22 @@
|
||||
"file.lastUsedOpenFilter": "All Files (*)",
|
||||
"fileStates": {
|
||||
"StageI.tmx": {
|
||||
"scale": 3,
|
||||
"selectedLayer": 3,
|
||||
"expandedObjectLayers": [
|
||||
12
|
||||
],
|
||||
"scale": 0.75,
|
||||
"selectedLayer": 1,
|
||||
"viewCenter": {
|
||||
"x": 473.16666666666663,
|
||||
"y": -1766.8333333333333
|
||||
"x": 844.6666666666665,
|
||||
"y": 827.3333333333334
|
||||
}
|
||||
},
|
||||
"StageII.tmx": {
|
||||
"scale": 3,
|
||||
"selectedLayer": 2,
|
||||
"viewCenter": {
|
||||
"x": -159.83333333333331,
|
||||
"y": -2171.833333333333
|
||||
}
|
||||
},
|
||||
"Terrain.tsx": {
|
||||
@ -35,7 +46,7 @@
|
||||
},
|
||||
"TreeTemplates.tmx": {
|
||||
"scale": 3,
|
||||
"selectedLayer": 0,
|
||||
"selectedLayer": 1,
|
||||
"viewCenter": {
|
||||
"x": 250.49999999999997,
|
||||
"y": 104.5
|
||||
@ -45,6 +56,7 @@
|
||||
"frame.defaultDuration": 200,
|
||||
"last.imagePath": "C:/Users/sigon/source/repos/hamster/assets",
|
||||
"last.objectTypesPath": "C:/Users/sigon/source/repos/hamster/assets/propertytypes.json",
|
||||
"map.fixedSize": false,
|
||||
"map.height": 100,
|
||||
"map.lastUsedFormat": "tmx",
|
||||
"map.tileHeight": 16,
|
||||
@ -56,7 +68,7 @@
|
||||
"StageI.tmx"
|
||||
],
|
||||
"project": "HamsterGame.tiled-project",
|
||||
"property.type": "FacingDirection",
|
||||
"property.type": "Difficulty",
|
||||
"recentFiles": [
|
||||
"StageI.tmx",
|
||||
"TestLevel.tmx",
|
||||
|
@ -1,5 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.10" tiledversion="1.10.2" orientation="orthogonal" renderorder="right-down" width="102" height="262" tilewidth="16" tileheight="16" infinite="0" backgroundcolor="#55aaff" nextlayerid="13" nextobjectid="2">
|
||||
<map version="1.10" tiledversion="1.10.2" class="Map" orientation="orthogonal" renderorder="right-down" width="102" height="262" tilewidth="16" tileheight="16" infinite="0" backgroundcolor="#55aaff" nextlayerid="13" nextobjectid="2">
|
||||
<properties>
|
||||
<property name="AI Difficulty" type="int" propertytype="Difficulty" value="0"/>
|
||||
</properties>
|
||||
<tileset firstgid="1" source="Terrain.tsx"/>
|
||||
<layer id="10" name="Tile Layer 1" width="102" height="262">
|
||||
<data encoding="csv">
|
||||
|
1307
assets/StageII.tmx
Normal file
1307
assets/StageII.tmx
Normal file
File diff suppressed because it is too large
Load Diff
@ -37,9 +37,9 @@
|
||||
0,0,1303,1304,1303,1304,1303,1304,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1269,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,1247,1248,1247,1248,1247,1248,1247,1248,1247,1248,1247,1248,0,1245,1246,0,1240,1241,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,1275,1276,1275,1276,1275,1276,1275,1276,1275,1276,1275,1276,0,1273,1274,0,1268,1269,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,1303,1304,1303,1304,1303,1304,1303,1304,1303,1304,1303,1304,0,1301,1302,0,0,1241,
|
||||
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,1269,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,1247,1248,1247,1248,1247,1248,1247,1248,1247,1248,1247,1248,0,1245,1246,0,1240,1241,
|
||||
0,0,1258,1259,1258,1259,1258,1259,0,0,0,0,1303,1304,1303,1304,1303,1304,1303,1304,1303,1304,1303,1304,0,1301,1302,0,0,1241,
|
||||
0,0,1286,1287,1286,1287,1286,1287,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1269,
|
||||
0,0,1314,1315,1314,1315,1314,1315,0,0,0,0,1247,1248,1247,1248,1247,1248,1247,1248,1247,1248,1247,1248,0,1245,1246,0,1240,1241,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,1275,1276,1275,1276,1275,1276,1275,1276,1275,1276,1275,1276,0,1273,1274,0,1268,1269,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,1303,1304,1303,1304,1303,1304,1303,1304,1303,1304,1303,1304,0,1301,1302,0,0,1241,
|
||||
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,1269,
|
||||
@ -59,9 +59,9 @@
|
||||
0,0,1303,1304,1303,1304,1303,1304,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,1245,1246,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,1273,1274,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,1301,1302,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,1245,1246,0,0,0,
|
||||
0,0,1258,1259,1258,1259,1258,1259,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1301,1302,0,0,0,
|
||||
0,0,1286,1287,1286,1287,1286,1287,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,1314,1315,1314,1315,1314,1315,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1245,1246,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,1273,1274,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,1301,1302,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,
|
||||
|
44
src/Difficulty.h
Normal file
44
src/Difficulty.h
Normal file
@ -0,0 +1,44 @@
|
||||
#pragma region License
|
||||
/*
|
||||
License (OLC-3)
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions or derivations of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce the above
|
||||
copyright notice. This list of conditions and the following disclaimer must be
|
||||
reproduced in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
|
||||
Portions of this software are copyright © 2024 The FreeType
|
||||
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
|
||||
All rights reserved.
|
||||
*/
|
||||
#pragma endregion
|
||||
#pragma once
|
||||
|
||||
enum class Difficulty{
|
||||
EASY,
|
||||
MEDIUM,
|
||||
HARD,
|
||||
};
|
@ -27,7 +27,7 @@ bool HamsterGame::OnUserCreate(){
|
||||
LoadGraphics();
|
||||
LoadAnimations();
|
||||
currentTileset=TSXParser{ASSETS_DIR+std::string("Terrain.tsx")};
|
||||
LoadLevel("StageI.tmx"); //THIS IS TEMPORARY.
|
||||
LoadLevel("StageII.tmx"); //THIS IS TEMPORARY.
|
||||
|
||||
border.ChangeBorder(Border::DEFAULT);
|
||||
|
||||
@ -542,6 +542,10 @@ void HamsterGame::OnTextEntryComplete(const std::string& sText){
|
||||
HamsterAI::OnTextEntryComplete(sText);
|
||||
}
|
||||
|
||||
const Difficulty&HamsterGame::GetMapDifficulty()const{
|
||||
return currentMap.value().GetData().GetMapDifficulty();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
HamsterGame game("Project Hamster");
|
||||
|
@ -48,6 +48,7 @@ All rights reserved.
|
||||
#include "olcPGEX_Graphics3D.h"
|
||||
#include "AnimationState.h"
|
||||
#include "olcPGEX_Viewport.h"
|
||||
#include "Difficulty.h"
|
||||
|
||||
struct Letter{
|
||||
vf2d pos;
|
||||
@ -83,6 +84,7 @@ public:
|
||||
const Terrain::Direction&GetTileFacingDirection(const vf2d worldPos)const;
|
||||
const std::string&GetCurrentMapName()const;
|
||||
virtual void OnTextEntryComplete(const std::string& sText)override;
|
||||
const Difficulty&GetMapDifficulty()const;
|
||||
private:
|
||||
void UpdateGame(const float fElapsedTime);
|
||||
void DrawGame();
|
||||
|
@ -41,6 +41,7 @@ All rights reserved.
|
||||
#include <sstream>
|
||||
#include <set>
|
||||
#include <queue>
|
||||
#include "Difficulty.h"
|
||||
|
||||
using MapName=std::string;
|
||||
using namespace olc;
|
||||
@ -111,6 +112,7 @@ private:
|
||||
std::map<std::string,std::vector<::ZoneData>>ZoneData;
|
||||
std::unordered_map<TunnelId,Tunnel>TunnelData;
|
||||
geom2d::rect<int>SpawnZone;
|
||||
Difficulty mapDifficulty{Difficulty::EASY};
|
||||
public:
|
||||
Map();
|
||||
void _SetMapData(MapTag data);
|
||||
@ -127,6 +129,7 @@ public:
|
||||
std::string FormatLayerData(std::ostream& os, std::vector<LayerTag>tiles);
|
||||
friend std::ostream& operator << (std::ostream& os, Map& rhs);
|
||||
friend std::ostream& operator << (std::ostream& os, std::vector<XMLTag>& rhs);
|
||||
const Difficulty&GetMapDifficulty()const;
|
||||
};
|
||||
|
||||
struct Property{
|
||||
@ -240,6 +243,9 @@ class TMXParser{
|
||||
}
|
||||
return displayStr;
|
||||
}
|
||||
const Difficulty&Map::GetMapDifficulty()const{
|
||||
return mapDifficulty;
|
||||
}
|
||||
const std::string_view Map::GetMapType()const{
|
||||
return mapType;
|
||||
}
|
||||
@ -357,6 +363,9 @@ class TMXParser{
|
||||
if(newTag.tag=="property"&&newTag.GetString("name")=="Link"){
|
||||
TunnelLinks.emplace_back(previousTunnelId,newTag.GetInteger("value"));
|
||||
}else
|
||||
if(newTag.tag=="property"&&newTag.GetString("name")=="AI Difficulty"){
|
||||
parsedMapInfo.mapDifficulty=Difficulty(newTag.GetInteger("value"));
|
||||
}else
|
||||
if (newTag.tag=="object"&&newTag.data.find("type")!=newTag.data.end()){
|
||||
if (newTag.GetString("type")=="Tunnel"){
|
||||
previousTunnelId=newTag.GetInteger("id");
|
||||
|
@ -101,10 +101,12 @@ A couple villain/scientist hamsters realize that this has become a stubby legs r
|
||||
|
||||
Stage II - Branching
|
||||
|
||||
Stage III - Swamp/Ice
|
||||
Stage III - Swamp/Ice/Tunnels
|
||||
|
||||
Stage IV - Hamster Jet
|
||||
|
||||
Hamster Boost - Provides 3 Speed Boosts that can be activated with a key. Obtained when running over a Hamster Wheel powerup. Recharge boosts by running over another one.
|
||||
|
||||
|
||||
|
||||
Hamsters are experimenting with new technologies to emphasize their running capabilities beyond what was originally thought possible.
|
||||
|
Loading…
x
Reference in New Issue
Block a user