mirror of
https://github.com/sigonasr2/hamster.git
synced 2025-04-18 14:39:40 -05:00
Moved Hamster Jet camera down, added targeting indicator, fix ground detection issues while in the air.
This commit is contained in:
parent
121061f3b8
commit
8720d20b82
BIN
assets/aimingTarget.png
Normal file
BIN
assets/aimingTarget.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
@ -150,11 +150,11 @@ void Hamster::DrawHamsters(TransformedView&tv){
|
|||||||
const Animate2D::Frame&wheelBottomImg{wheelBottomAnim.GetFrame(h.distanceTravelled/80.f)};
|
const Animate2D::Frame&wheelBottomImg{wheelBottomAnim.GetFrame(h.distanceTravelled/80.f)};
|
||||||
if(h.state==FLYING)h.hamsterJet.value().Draw();
|
if(h.state==FLYING)h.hamsterJet.value().Draw();
|
||||||
HamsterGame::Game().SetZ(h.z);
|
HamsterGame::Game().SetZ(h.z);
|
||||||
if(h.HasPowerup(Powerup::WHEEL))tv.DrawPartialRotatedDecal(h.pos,wheelBottomImg.GetSourceImage()->Decal(),h.rot,wheelBottomImg.GetSourceRect().size/2,wheelBottomImg.GetSourceRect().pos,wheelBottomImg.GetSourceRect().size,vf2d{1.f,1.f}*h.imgScale,PixelLerp(h.shrinkEffectColor,WHITE,h.imgScale));
|
if(h.HasPowerup(Powerup::WHEEL))tv.DrawPartialRotatedDecal(h.pos+vf2d{0.f,h.drawingOffsetY},wheelBottomImg.GetSourceImage()->Decal(),h.rot,wheelBottomImg.GetSourceRect().size/2,wheelBottomImg.GetSourceRect().pos,wheelBottomImg.GetSourceRect().size,vf2d{1.f,1.f}*h.imgScale,PixelLerp(h.shrinkEffectColor,WHITE,h.imgScale));
|
||||||
HamsterGame::Game().SetZ(h.z+0.005f);
|
HamsterGame::Game().SetZ(h.z+0.005f);
|
||||||
tv.DrawPartialRotatedDecal(h.pos,img.GetSourceImage()->Decal(),h.rot,img.GetSourceRect().size/2,img.GetSourceRect().pos,img.GetSourceRect().size,vf2d{1.f,1.f}*h.imgScale,PixelLerp(h.shrinkEffectColor,WHITE,h.imgScale));
|
tv.DrawPartialRotatedDecal(h.pos+vf2d{0.f,h.drawingOffsetY},img.GetSourceImage()->Decal(),h.rot,img.GetSourceRect().size/2,img.GetSourceRect().pos,img.GetSourceRect().size,vf2d{1.f,1.f}*h.imgScale,PixelLerp(h.shrinkEffectColor,WHITE,h.imgScale));
|
||||||
HamsterGame::Game().SetZ(h.z+0.01f);
|
HamsterGame::Game().SetZ(h.z+0.01f);
|
||||||
if(h.HasPowerup(Powerup::WHEEL))tv.DrawPartialRotatedDecal(h.pos,wheelTopImg.GetSourceImage()->Decal(),h.rot,wheelTopImg.GetSourceRect().size/2,wheelTopImg.GetSourceRect().pos,wheelTopImg.GetSourceRect().size,vf2d{1.f,1.f}*h.imgScale,PixelLerp(h.shrinkEffectColor,{255,255,255,192},h.imgScale));
|
if(h.HasPowerup(Powerup::WHEEL))tv.DrawPartialRotatedDecal(h.pos+vf2d{0.f,h.drawingOffsetY},wheelTopImg.GetSourceImage()->Decal(),h.rot,wheelTopImg.GetSourceRect().size/2,wheelTopImg.GetSourceRect().pos,wheelTopImg.GetSourceRect().size,vf2d{1.f,1.f}*h.imgScale,PixelLerp(h.shrinkEffectColor,{255,255,255,192},h.imgScale));
|
||||||
HamsterGame::Game().SetZ(0.f);
|
HamsterGame::Game().SetZ(0.f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -261,6 +261,7 @@ const float Hamster::GetRadius()const{
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Terrain::TerrainType Hamster::GetTerrainStandingOn()const{
|
const Terrain::TerrainType Hamster::GetTerrainStandingOn()const{
|
||||||
|
if(state==FLYING)return Terrain::ROCK;
|
||||||
return HamsterGame::Game().GetTerrainTypeAtPos(GetPos());
|
return HamsterGame::Game().GetTerrainTypeAtPos(GetPos());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -354,12 +355,12 @@ const float&Hamster::GetZ()const{
|
|||||||
|
|
||||||
void Hamster::SetPos(const vf2d pos){
|
void Hamster::SetPos(const vf2d pos){
|
||||||
bool movedY{false};
|
bool movedY{false};
|
||||||
if(state==FLYING||!HamsterGame::Game().IsTerrainSolid(vf2d{this->pos.x,pos.y})){
|
if(state==FLYING&&HamsterGame::Game().IsInBounds(vf2d{this->pos.x,pos.y})||!HamsterGame::Game().IsTerrainSolid(vf2d{this->pos.x,pos.y})){
|
||||||
this->pos=vf2d{this->pos.x,pos.y};
|
this->pos=vf2d{this->pos.x,pos.y};
|
||||||
movedY=true;
|
movedY=true;
|
||||||
}
|
}
|
||||||
if(state==FLYING||!HamsterGame::Game().IsTerrainSolid(vf2d{pos.x,this->pos.y}))this->pos=vf2d{pos.x,this->pos.y};
|
if(state==FLYING&&HamsterGame::Game().IsInBounds(vf2d{pos.x,this->pos.y})||!HamsterGame::Game().IsTerrainSolid(vf2d{pos.x,this->pos.y}))this->pos=vf2d{pos.x,this->pos.y};
|
||||||
if (!movedY&&(state==FLYING||!HamsterGame::Game().IsTerrainSolid(vf2d{this->pos.x,pos.y})))this->pos=vf2d{this->pos.x,pos.y};
|
if (!movedY&&(state==FLYING&&HamsterGame::Game().IsInBounds(vf2d{this->pos.x,pos.y})||!HamsterGame::Game().IsTerrainSolid(vf2d{this->pos.x,pos.y})))this->pos=vf2d{this->pos.x,pos.y};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hamster::SetZ(const float z){
|
void Hamster::SetZ(const float z){
|
||||||
@ -368,4 +369,8 @@ void Hamster::SetZ(const float z){
|
|||||||
|
|
||||||
void Hamster::OnUserDestroy(){
|
void Hamster::OnUserDestroy(){
|
||||||
HAMSTER_LIST.clear();
|
HAMSTER_LIST.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Hamster::SetDrawingOffsetY(const float offsetY){
|
||||||
|
drawingOffsetY=offsetY;
|
||||||
}
|
}
|
@ -102,6 +102,7 @@ class Hamster{
|
|||||||
std::unordered_set<Powerup::PowerupType>powerups;
|
std::unordered_set<Powerup::PowerupType>powerups;
|
||||||
std::optional<HamsterJet>hamsterJet;
|
std::optional<HamsterJet>hamsterJet;
|
||||||
float lastTappedSpace{0.f};
|
float lastTappedSpace{0.f};
|
||||||
|
float drawingOffsetY{0.f};
|
||||||
public:
|
public:
|
||||||
Hamster(const vf2d spawnPos,const std::string_view img,const PlayerControlled IsPlayerControlled=NPC);
|
Hamster(const vf2d spawnPos,const std::string_view img,const PlayerControlled IsPlayerControlled=NPC);
|
||||||
static const Hamster&GetPlayer();
|
static const Hamster&GetPlayer();
|
||||||
@ -134,4 +135,5 @@ public:
|
|||||||
void SetPos(const vf2d pos);
|
void SetPos(const vf2d pos);
|
||||||
void SetZ(const float z);
|
void SetZ(const float z);
|
||||||
static void OnUserDestroy();
|
static void OnUserDestroy();
|
||||||
|
void SetDrawingOffsetY(const float offsetY);
|
||||||
};
|
};
|
@ -47,6 +47,7 @@ void HamsterGame::LoadGraphics(){
|
|||||||
_LoadImage("hamster_jet.png");
|
_LoadImage("hamster_jet.png");
|
||||||
_LoadImage("dot.png");
|
_LoadImage("dot.png");
|
||||||
_LoadImage("clouds.png");
|
_LoadImage("clouds.png");
|
||||||
|
_LoadImage("aimingTarget.png");
|
||||||
UpdateMatrixTexture();
|
UpdateMatrixTexture();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,6 +400,10 @@ const float HamsterGame::GetZoom()const{
|
|||||||
return zoom;
|
return zoom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool HamsterGame::IsInBounds(const vf2d pos)const{
|
||||||
|
return !(pos.x<=-160.f||pos.y<=-160.f||pos.x>=currentMap.value().GetData().GetMapData().width*16+160.f||pos.y>=currentMap.value().GetData().GetMapData().height*16+160.f);
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
HamsterGame game;
|
HamsterGame game;
|
||||||
|
@ -84,6 +84,7 @@ public:
|
|||||||
const bool IsTerrainSolid(const vf2d pos)const;
|
const bool IsTerrainSolid(const vf2d pos)const;
|
||||||
void SetZoom(const float zoom);
|
void SetZoom(const float zoom);
|
||||||
const float GetZoom()const;
|
const float GetZoom()const;
|
||||||
|
const bool IsInBounds(const vf2d pos)const;
|
||||||
private:
|
private:
|
||||||
void UpdateGame(const float fElapsedTime);
|
void UpdateGame(const float fElapsedTime);
|
||||||
void DrawGame();
|
void DrawGame();
|
||||||
|
@ -49,6 +49,7 @@ void HamsterJet::Update(const float fElapsedTime){
|
|||||||
jet.Update(fElapsedTime);
|
jet.Update(fElapsedTime);
|
||||||
lights.Update(fElapsedTime);
|
lights.Update(fElapsedTime);
|
||||||
timer=std::max(0.f,timer-fElapsedTime);
|
timer=std::max(0.f,timer-fElapsedTime);
|
||||||
|
easeInTimer=std::max(0.f,easeInTimer-fElapsedTime);
|
||||||
lastTappedSpace+=fElapsedTime;
|
lastTappedSpace+=fElapsedTime;
|
||||||
switch(state){
|
switch(state){
|
||||||
case SWOOP_DOWN:{
|
case SWOOP_DOWN:{
|
||||||
@ -58,8 +59,7 @@ void HamsterJet::Update(const float fElapsedTime){
|
|||||||
if(timer<=0.4f){
|
if(timer<=0.4f){
|
||||||
hamster.SetPos(hamsterOriginalPos-vf2d{0.f,sin(float(geom2d::pi)*timer/0.4f)*8.f});
|
hamster.SetPos(hamsterOriginalPos-vf2d{0.f,sin(float(geom2d::pi)*timer/0.4f)*8.f});
|
||||||
hamster.SetZ(sin(float(geom2d::pi)*timer/0.4f)*0.2f);
|
hamster.SetZ(sin(float(geom2d::pi)*timer/0.4f)*0.2f);
|
||||||
jetState[TOP_LEFT]=OFF;
|
jetState[TOP_LEFT]=jetState[BOTTOM_LEFT]=jetState[BOTTOM_RIGHT]=jetState[TOP_RIGHT]=OFF;
|
||||||
jetState[BOTTOM_LEFT]=OFF;
|
|
||||||
}else{
|
}else{
|
||||||
jetState[TOP_LEFT]=jetState[BOTTOM_LEFT]=jetState[BOTTOM_RIGHT]=jetState[TOP_RIGHT]=ON;
|
jetState[TOP_LEFT]=jetState[BOTTOM_LEFT]=jetState[BOTTOM_RIGHT]=jetState[TOP_RIGHT]=ON;
|
||||||
pos=hamster.GetPos().lerp(originalPos,std::pow(timer/3.f,4));
|
pos=hamster.GetPos().lerp(originalPos,std::pow(timer/3.f,4));
|
||||||
@ -81,7 +81,8 @@ void HamsterJet::Update(const float fElapsedTime){
|
|||||||
hamster.SetZ(z+0.03f);
|
hamster.SetZ(z+0.03f);
|
||||||
if(timer<=0.f){
|
if(timer<=0.f){
|
||||||
state=PLAYER_CONTROL;
|
state=PLAYER_CONTROL;
|
||||||
HamsterGame::Game().SetZoom(1.f);
|
HamsterGame::Game().SetZoom(0.6f);
|
||||||
|
easeInTimer=0.6f;
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
case PLAYER_CONTROL:{
|
case PLAYER_CONTROL:{
|
||||||
@ -92,19 +93,29 @@ void HamsterJet::Update(const float fElapsedTime){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
void HamsterJet::Draw(){
|
void HamsterJet::Draw(){
|
||||||
|
float drawingOffsetY{0.f};
|
||||||
|
hamster.SetDrawingOffsetY(0.f);
|
||||||
|
if((state==PLAYER_CONTROL||state==LANDING)&&z>2.f){
|
||||||
|
HamsterGame::Game().SetZ(z/2.f);
|
||||||
|
HamsterGame::Game().tv.DrawRotatedDecal(pos,HamsterGame::GetGFX("aimingTarget.png").Decal(),0.f,HamsterGame::GetGFX("aimingTarget.png").Sprite()->Size()/2);
|
||||||
|
}
|
||||||
|
if(state==PLAYER_CONTROL){
|
||||||
|
drawingOffsetY=util::lerp(48.f,0.f,easeInTimer/0.6f);
|
||||||
|
hamster.SetDrawingOffsetY(util::lerp(48.f,0.f,easeInTimer/0.6f));
|
||||||
|
}
|
||||||
HamsterGame::Game().SetZ(z);
|
HamsterGame::Game().SetZ(z);
|
||||||
HamsterGame::Game().tv.DrawPartialRotatedDecal(pos,jet.Decal(),0.f,{24,24},{},{48,48});
|
HamsterGame::Game().tv.DrawPartialRotatedDecal(pos+vf2d{0,drawingOffsetY},jet.Decal(),0.f,{24,24},{},{48,48});
|
||||||
const Animate2D::FrameSequence&flameAnim{HamsterGame::Game().GetAnimation("hamster_jet.png",HamsterGame::AnimationState::JET_FLAMES)};
|
const Animate2D::FrameSequence&flameAnim{HamsterGame::Game().GetAnimation("hamster_jet.png",HamsterGame::AnimationState::JET_FLAMES)};
|
||||||
const Animate2D::Frame&flameFrame{flameAnim.GetFrame(HamsterGame::Game().GetRuntime())};
|
const Animate2D::Frame&flameFrame{flameAnim.GetFrame(HamsterGame::Game().GetRuntime())};
|
||||||
HamsterGame::Game().SetZ(z+0.01f);
|
HamsterGame::Game().SetZ(z+0.01f);
|
||||||
if(jetState[TOP_LEFT])HamsterGame::Game().tv.DrawPartialRotatedDecal(pos,flameFrame.GetSourceImage()->Decal(),0.f,flameFrame.GetSourceRect().size/2,flameFrame.GetSourceRect().pos+vf2d{0,0},flameFrame.GetSourceRect().size/2);
|
if(jetState[TOP_LEFT])HamsterGame::Game().tv.DrawPartialRotatedDecal(pos+vf2d{0,drawingOffsetY},flameFrame.GetSourceImage()->Decal(),0.f,flameFrame.GetSourceRect().size/2,flameFrame.GetSourceRect().pos+vf2d{0,0},flameFrame.GetSourceRect().size/2);
|
||||||
if(jetState[BOTTOM_LEFT])HamsterGame::Game().tv.DrawPartialRotatedDecal(pos,flameFrame.GetSourceImage()->Decal(),0.f,{24,0},flameFrame.GetSourceRect().pos+vf2d{0,24},flameFrame.GetSourceRect().size/2);
|
if(jetState[BOTTOM_LEFT])HamsterGame::Game().tv.DrawPartialRotatedDecal(pos+vf2d{0,drawingOffsetY},flameFrame.GetSourceImage()->Decal(),0.f,{24,0},flameFrame.GetSourceRect().pos+vf2d{0,24},flameFrame.GetSourceRect().size/2);
|
||||||
if(jetState[BOTTOM_RIGHT])HamsterGame::Game().tv.DrawPartialRotatedDecal(pos,flameFrame.GetSourceImage()->Decal(),0.f,{0,0},flameFrame.GetSourceRect().pos+vf2d{24,24},flameFrame.GetSourceRect().size/2);
|
if(jetState[BOTTOM_RIGHT])HamsterGame::Game().tv.DrawPartialRotatedDecal(pos+vf2d{0,drawingOffsetY},flameFrame.GetSourceImage()->Decal(),0.f,{0,0},flameFrame.GetSourceRect().pos+vf2d{24,24},flameFrame.GetSourceRect().size/2);
|
||||||
if(jetState[TOP_RIGHT])HamsterGame::Game().tv.DrawPartialRotatedDecal(pos,flameFrame.GetSourceImage()->Decal(),0.f,{0,24},flameFrame.GetSourceRect().pos+vf2d{24,0},flameFrame.GetSourceRect().size/2);
|
if(jetState[TOP_RIGHT])HamsterGame::Game().tv.DrawPartialRotatedDecal(pos+vf2d{0,drawingOffsetY},flameFrame.GetSourceImage()->Decal(),0.f,{0,24},flameFrame.GetSourceRect().pos+vf2d{24,0},flameFrame.GetSourceRect().size/2);
|
||||||
const Animate2D::FrameSequence&lightAnim{HamsterGame::Game().GetAnimation("hamster_jet.png",HamsterGame::AnimationState::JET_LIGHTS)};
|
const Animate2D::FrameSequence&lightAnim{HamsterGame::Game().GetAnimation("hamster_jet.png",HamsterGame::AnimationState::JET_LIGHTS)};
|
||||||
const Animate2D::Frame&lightFrame{lightAnim.GetFrame(HamsterGame::Game().GetRuntime())};
|
const Animate2D::Frame&lightFrame{lightAnim.GetFrame(HamsterGame::Game().GetRuntime())};
|
||||||
HamsterGame::Game().SetZ(z+0.02f);
|
HamsterGame::Game().SetZ(z+0.02f);
|
||||||
HamsterGame::Game().tv.DrawPartialRotatedDecal(pos,lights.Decal(),0.f,lightFrame.GetSourceRect().size/2.f,lightFrame.GetSourceRect().pos,lightFrame.GetSourceRect().size);
|
HamsterGame::Game().tv.DrawPartialRotatedDecal(pos+vf2d{0,drawingOffsetY},lights.Decal(),0.f,lightFrame.GetSourceRect().size/2.f,lightFrame.GetSourceRect().pos,lightFrame.GetSourceRect().size);
|
||||||
HamsterGame::Game().SetZ(0.f);
|
HamsterGame::Game().SetZ(0.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,6 +65,7 @@ class HamsterJet{
|
|||||||
vf2d hamsterOriginalPos;
|
vf2d hamsterOriginalPos;
|
||||||
vf2d originalPos;
|
vf2d originalPos;
|
||||||
vf2d targetPos;
|
vf2d targetPos;
|
||||||
|
float easeInTimer{};
|
||||||
float z;
|
float z;
|
||||||
float targetZ{};
|
float targetZ{};
|
||||||
State state;
|
State state;
|
||||||
|
21
src/TODO.txt
21
src/TODO.txt
@ -71,5 +71,26 @@ Fall-o-meter
|
|||||||
|
|
||||||
Hamster Rescue Boat
|
Hamster Rescue Boat
|
||||||
|
|
||||||
|
|
||||||
|
LORE
|
||||||
|
===================
|
||||||
|
|
||||||
|
(?) discovered a strange floating energy orb while going for their morning run. Curious, they approached it and came into contact with it, granting them new powers.
|
||||||
|
|
||||||
|
Excited by this discovery (?) decided to share it with the rest of their hamster friends.
|
||||||
|
|
||||||
|
A couple villain/scientist hamsters realize that this has become a stubby legs race with great potential and recruited world class hamsters to run and obtain these new orbs for research.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Hamsters are experimenting with new technologies to emphasize their running capabilities beyond what was originally thought possible.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Hamsters from all around Hamster planet have been recruited to scavenge for
|
||||||
|
|
||||||
|
============================
|
||||||
|
|
||||||
============================
|
============================
|
||||||
olcPGEX_ViewPort - Submit a PR where the offset is subtracted instead of added to determine clip region cutoffs.
|
olcPGEX_ViewPort - Submit a PR where the offset is subtracted instead of added to determine clip region cutoffs.
|
Loading…
x
Reference in New Issue
Block a user