This commit is contained in:
2023-07-06 14:59:22 -05:00
8 changed files with 114 additions and 5 deletions
+1
View File
@@ -3,6 +3,7 @@
#include "Animation.h"
#include "olcUTIL_Animate2D.h"
#include "Monster.h"
#include "DEFINES.h"
struct Bullet{
friend class Crawler;
+1 -1
View File
@@ -290,7 +290,7 @@ bool Wizard::AutoAttack(){
bool Wizard::Ability1(){
ACCESS_PLAYER
float angleToCursor=atan2(game->GetWorldMousePos().y-p.pos.y,game->GetWorldMousePos().x-p.pos.x);
PLAYER_BULLET_LIST.push_back(std::make_unique<FireBolt>(FireBolt(p.pos,{cos(angleToCursor)*200,sin(angleToCursor)*200},12,p.GetAttack(),true,{240,120,60})));
PLAYER_BULLET_LIST.push_back(std::make_unique<FireBolt>(FireBolt(p.pos,{cos(angleToCursor)*275,sin(angleToCursor)*275},12,p.GetAttack(),true,{240,120,60})));
return true;
}
BIN
View File
Binary file not shown.
+12 -2
View File
@@ -10,6 +10,7 @@
#include "TSXParser.h"
#include "Map.h"
#include "DEFINES.h"
#include "utils.h"
INCLUDE_CLASS_DATA
@@ -576,8 +577,14 @@ void Crawler::UpdateCamera(float fElapsedTime){
lastWorldShakeAdjust=std::max(0.f,lastWorldShakeAdjust-fElapsedTime);
if(worldShakeTime-fElapsedTime>0){
if(lastWorldShakeAdjust==0){
lastWorldShakeAdjust=float(rand()%int(WORLD_SHAKE_ADJUST_MAX_TIME*1000))/1000+0.05;
worldShakeVel={float(rand()%1000)/1000*100-50,float(rand()%1000)/1000*100-50};
lastWorldShakeAdjust=util::random(0.04)+0.01;
worldShakeVel={util::random(200)+100,util::random(200)+100};
if(rand()%2==0){
worldShakeVel.x*=-1;
}
if(rand()%2==0){
worldShakeVel.y*=-1;
}
}
worldShake+=worldShakeVel*fElapsedTime;
} else {
@@ -827,6 +834,9 @@ void Crawler::RenderHud(){
FillRectDecal(vf2d{11,ScreenHeight()-21.f}-vf2d{0,float(offset)},{62,4},DARK_GREY);
GradientFillRectDecal(vf2d{10,ScreenHeight()-22.f}-vf2d{0,float(offset)},{(a.cooldown/a.COOLDOWN_TIME)*64,6},a.barColor1,a.barColor1,a.barColor2,a.barColor2);
DrawRotatedShadowStringPropDecal(vf2d{8,ScreenHeight()-20.f}+vf2d{1,1}-vf2d{0,float(offset)},capitalize(a.name),-PI/64,{0,0},WHITE,BLACK,{0.4,0.4},0.5);
std::stringstream cooldownTimeDisplay;
cooldownTimeDisplay<<std::fixed<<std::setprecision(1)<<a.cooldown;
DrawShadowStringPropDecal(vf2d{74,ScreenHeight()-22.f+1}-vf2d{float(GetTextSizeProp(cooldownTimeDisplay.str()).x*0.5),float(offset)},cooldownTimeDisplay.str(),WHITE,BLACK,{0.5,0.5});
}
offset-=6;
}
+1
View File
@@ -33,6 +33,7 @@ bool FireBolt::MonsterHit(Monster& monster)
for(int i=0;i<72;i++){
game->AddEffect(Effect(monster.GetPos(),util::random(0.5),AnimationState::DOT_PARTICLE,util::random(2),util::random(0.4),{util::random(300)-150,util::random(300)-150},{255,uint8_t(util::random(190)+60),60}));
}
game->SetupWorldShake(0.25);
for(Monster&m:MONSTER_LIST){
if(geom2d::line(monster.GetPos(),m.GetPos()).length()<=2.5*24){
m.Hurt(3*damage);
+14 -2
View File
@@ -1,5 +1,6 @@
#pragma once
#include "olcPixelGameEngine.h"
#include "olcUTIL_Geometry2D.h"
#include <strstream>
using namespace olc;
@@ -40,6 +41,7 @@ struct Map{
std::vector<XMLTag> TilesetData;
std::vector<LayerTag> LayerData;
std::vector<SpawnerTag> SpawnerData;
std::map<std::string,std::vector<geom2d::rect<int>>> ZoneData;
std::string FormatLayerData(std::ostream& os, std::vector<LayerTag>tiles);
std::string FormatSpawnerData(std::ostream& os, std::vector<SpawnerTag>tiles);
friend std::ostream& operator << (std::ostream& os, Map& rhs);
@@ -57,7 +59,6 @@ class TMXParser{
public:
TMXParser(std::string file);
};
#ifdef TMX_PARSER_SETUP
#undef TMX_PARSER_SETUP
const std::string XMLTag::FormatTagData(std::map<std::string,std::string>tiles){
@@ -201,7 +202,7 @@ class TMXParser{
if (newTag.tag=="layer") {
LayerTag l = {newTag};
parsedMapInfo.LayerData.push_back(l);
} else
}else
if (newTag.tag=="object"&&newTag.data["type"]=="SpawnGroup") {
if(buildingSpawner){
parsedMapInfo.SpawnerData.push_back(obj);
@@ -213,6 +214,17 @@ class TMXParser{
if (newTag.tag=="object"&&newTag.data["type"]=="PlayerSpawnLocation") {
parsedMapInfo.MapData.playerSpawnLocation={newTag.GetInteger("x")-newTag.GetInteger("width")/2,newTag.GetInteger("y")-newTag.GetInteger("height")/2};
} else
if (newTag.tag=="object"&&newTag.data.find("type")!=newTag.data.end()){
//This is an object with a type that doesn't fit into other categories, we can add it to ZoneData.
if(parsedMapInfo.ZoneData.find(newTag.data["type"])!=parsedMapInfo.ZoneData.end()){
std::vector<geom2d::rect<int>>&zones=parsedMapInfo.ZoneData[newTag.data["type"]];
zones.push_back({{newTag.GetInteger("x"),newTag.GetInteger("y")},{newTag.GetInteger("width"),newTag.GetInteger("height")}});
} else {
std::vector<geom2d::rect<int>>zones;
zones.push_back({{newTag.GetInteger("x"),newTag.GetInteger("y")},{newTag.GetInteger("width"),newTag.GetInteger("height")}});
parsedMapInfo.ZoneData[newTag.data["type"]]=zones;
}
}
if (newTag.tag=="property"&&buildingSpawner) {
if(newTag.data["propertytype"]=="MonsterName"){
obj.properties.push_back(newTag);
Binary file not shown.