diff --git a/New Text Document.txt b/New Text Document.txt deleted file mode 100644 index e69de29..0000000 diff --git a/assets/hamster_jet.png b/assets/hamster_jet.png new file mode 100644 index 0000000..59e1143 Binary files /dev/null and b/assets/hamster_jet.png differ diff --git a/hamster.vcxproj b/hamster.vcxproj index 52be66e..95e34d7 100644 --- a/hamster.vcxproj +++ b/hamster.vcxproj @@ -382,6 +382,10 @@ if %errorlevel% neq 0 goto :VCEnd + + + + diff --git a/hamster.vcxproj.filters b/hamster.vcxproj.filters index 7560861..9645fc4 100644 --- a/hamster.vcxproj.filters +++ b/hamster.vcxproj.filters @@ -94,5 +94,8 @@ Header Files + + Header Files + \ No newline at end of file diff --git a/src/HamsterGame.cpp b/src/HamsterGame.cpp index f387914..d29f29a 100644 --- a/src/HamsterGame.cpp +++ b/src/HamsterGame.cpp @@ -2,6 +2,7 @@ #include "Hamster.h" #include #include +#include "util.h" geom2d::rectHamsterGame::SCREEN_FRAME{{96,0},{320,288}}; std::unordered_map>HamsterGame::ANIMATIONS; @@ -113,6 +114,7 @@ void HamsterGame::LoadLevel(const std::string_view mapName){ } void HamsterGame::UpdateGame(const float fElapsedTime){ + UpdateMatrixTexture(); camera.SetViewSize(tv.GetWorldVisibleArea()); camera.Update(fElapsedTime); tv.SetWorldOffset(tv.ScaleToWorld(-SCREEN_FRAME.pos)+camera.GetViewPosition()); @@ -156,8 +158,6 @@ void HamsterGame::DrawGame(){ GradientFillRectDecal(vf2d{12.f,240.f}+vf2d{12.f,5.f},vf2d{Hamster::GetPlayer().GetBurnRatio()*57.f,4.f},{250,177,163},{226,228,255},{226,228,255},{250,177,163}); } #pragma endregion - - tv.FillRectDecal(GetMousePos(),{2,2},GREEN); } const Terrain::TerrainType HamsterGame::GetTerrainTypeAtPos(const vf2d pos)const{ @@ -224,6 +224,65 @@ const double HamsterGame::GetRuntime()const{ return runTime; } +void HamsterGame::UpdateMatrixTexture(){ + const auto result{GFX.insert({ASSETS_DIR+"MATRIX_TEXTURE",Renderable{}})}; + Renderable&texture{(*result.first).second}; + if(result.second){ + texture.Create(64,64); + } + + const std::arraymatrixLetters{'0','1','2','3','4','5','6','7','8','9'}; + + if(matrixTimer==0){ + activeLetters.emplace_back(vf2d{float(rand()%64),float(64)},util::random(-40)-20,matrixLetters[rand()%matrixLetters.size()]); + matrixTimer=util::random(0.125); + } + if(updatePixelsTimer==0){ + SetDrawTarget(texture.Sprite()); + Sprite*img=texture.Sprite(); + for(int y=63;y>=0;y--){ + for(int x=63;x>=0;x--){ + Pixel col=img->GetPixel(x,y); + if(col.r>0){ + if(x>0){ + Pixel leftCol=img->GetPixel(x-1,y); + if(leftCol.rwidth-1){ + Pixel rightCol=img->GetPixel(x+1,y); + if(rightCol.rGetPixel(1,y)); + } + SetDrawTarget(nullptr); + updatePixelsTimer=0.1; + } + if(activeLetters.size()>0){ + SetDrawTarget(texture.Sprite()); + for(Letter&letter:activeLetters){ + letter.pos.y+=letter.spd*GetElapsedTime(); + DrawString(letter.pos,std::string(1,letter.c)); + } + SetDrawTarget(nullptr); + texture.Decal()->Update(); + } + matrixTimer=std::max(0.f,matrixTimer-GetElapsedTime()); + updatePixelsTimer=std::max(0.f,updatePixelsTimer-GetElapsedTime()); + std::erase_if(activeLetters,[](Letter&letter){return letter.pos.y<-32;}); +} + int main() { HamsterGame game; diff --git a/src/HamsterGame.h b/src/HamsterGame.h index 40b93ef..e01eb5c 100644 --- a/src/HamsterGame.h +++ b/src/HamsterGame.h @@ -46,6 +46,12 @@ All rights reserved. #include "TSXParser.h" #include "Terrain.h" +struct Letter{ + vf2d pos; + float spd; + char c; +}; + class HamsterGame : public olc::PixelGameEngine { const static std::string ASSETS_DIR; @@ -87,4 +93,8 @@ private: double runTime{}; Camera2D camera; Renderable mapImage; + void UpdateMatrixTexture(); + float matrixTimer; + std::vectoractiveLetters; + float updatePixelsTimer; }; \ No newline at end of file diff --git a/src/SpecialRenderable.h b/src/SpecialRenderable.h new file mode 100644 index 0000000..c79739d --- /dev/null +++ b/src/SpecialRenderable.h @@ -0,0 +1,47 @@ +#pragma region License +/* +License (OLC-3) +~~~~~~~~~~~~~~~ + +Copyright 2024 Joshua Sigona + +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 + +#include "olcPixelGameEngine.h" + +class SpecialRenderable{ + Renderable originalImg; + Renderable modifiedImg; +public: + +}; \ No newline at end of file