Skip to content

Commit 174e26a

Browse files
committed
cleanup
1 parent 1957eba commit 174e26a

16 files changed

Lines changed: 94 additions & 89 deletions

gamedata/entities/weapons.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
"projectile_hit_object_sfx": 43, // sound index
2020
"projectile_offset":
2121
[
22-
{ "anim": "shoot_pistol_while_standing", "px": [8, -1] },
23-
{ "anim": "shoot_pistol_while_walking", "px": [11, -2] },
24-
{ "anim": "shoot_pistol_while_running", "px": [11, 2] }
22+
{ "anim": "shoot_pistol_while_standing", "px": [8, 2] },
23+
{ "anim": "shoot_pistol_while_walking", "px": [11, 0] },
24+
{ "anim": "shoot_pistol_while_running", "px": [11, 5] }
2525
],
2626
// base params
2727
"base_hit_range": 4.5,
@@ -44,9 +44,9 @@
4444
"projectile_hit_object_sfx": 43, // sound index
4545
"projectile_offset":
4646
[
47-
{ "anim": "shoot_machinegun_while_standing", "px": [6, 0] },
48-
{ "anim": "shoot_machinegun_while_walking", "px": [8, 0] },
49-
{ "anim": "shoot_machinegun_while_running", "px": [12, 4] }
47+
{ "anim": "shoot_machinegun_while_standing", "px": [6, 3] },
48+
{ "anim": "shoot_machinegun_while_walking", "px": [10, 3] },
49+
{ "anim": "shoot_machinegun_while_running", "px": [11, 7] }
5050
],
5151
// base params
5252
"base_hit_range": 4.5,
@@ -68,9 +68,9 @@
6868
"projectile_object": 75,
6969
"projectile_offset":
7070
[
71-
{ "anim": "shoot_flamethrower_while_standing", "px": [18, 2] },
72-
{ "anim": "shoot_flamethrower_while_walking", "px": [18, 2] },
73-
{ "anim": "shoot_flamethrower_while_running", "px": [20, 5] }
71+
{ "anim": "shoot_flamethrower_while_standing", "px": [16, 3] },
72+
{ "anim": "shoot_flamethrower_while_walking", "px": [16, 3] },
73+
{ "anim": "shoot_flamethrower_while_running", "px": [18, 6] }
7474
],
7575
// base params
7676
"base_hit_range": 1.1,

src/DamageInfo.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,8 @@ void DamageInfo::SetDamageFromCollision(const MapCollision& collisionInfo)
8181
mHitPoints = 0; // not used
8282
mContactImpulse = collisionInfo.GetContactImpulse();
8383
if (!collisionInfo.HasContactPoints())
84-
{
85-
debug_assert(false);
8684
return;
87-
}
85+
8886
mContactPoint = collisionInfo.mContactPoints[0];
8987
}
9088

src/Decoration.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void Decoration::UpdateFrame()
2020
float deltaTime = gTimeManager.mGameFrameDelta;
2121
if (mAnimationState.UpdateFrame(deltaTime))
2222
{
23-
SetupSpriteFrame();
23+
SetSprite(mAnimationState.GetSpriteIndex(), 0);
2424
}
2525

2626
glm::vec3 newPosition = mTransform.mPosition + (mMoveVelocity * deltaTime);
@@ -41,10 +41,12 @@ void Decoration::DebugDraw(DebugRenderer& debugRender)
4141

4242
void Decoration::HandleSpawn()
4343
{
44+
mRemapClut = 0;
45+
4446
mAnimationState.ClearState();
4547
mAnimationState.PlayAnimation(eSpriteAnimLoop_FromStart);
4648

47-
SetupSpriteFrame();
49+
SetSprite(mAnimationState.GetSpriteIndex(), 0);
4850
}
4951

5052
void Decoration::SetLifeDuration(int numCycles)
@@ -68,9 +70,3 @@ void Decoration::SetMoveVelocity(const glm::vec3& moveVelocity)
6870
{
6971
mMoveVelocity = moveVelocity;
7072
}
71-
72-
void Decoration::SetupSpriteFrame()
73-
{
74-
gSpriteManager.GetSpriteTexture(mObjectID, mAnimationState.GetSpriteIndex(), 0, mDrawSprite);
75-
RefreshDrawSprite();
76-
}

src/Decoration.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ class Decoration final: public GameObject
2525
// Change current draw order for decoration object
2626
void SetDrawOrder(eSpriteDrawOrder drawOrder);
2727

28-
private:
29-
void SetupSpriteFrame();
30-
3128
private:
3229
SpriteAnimation mAnimationState;
3330
glm::vec3 mMoveVelocity;

src/Explosion.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ void Explosion::DebugDraw(DebugRenderer& debugRender)
6161

6262
void Explosion::HandleSpawn()
6363
{
64+
mRemapClut = 0;
6465
mUpdatesCounter = 0;
6566

6667
mDrawSprite.mDrawOrder = eSpriteDrawOrder_Explosion;

src/GameDefs.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,13 @@ enum eSpriteOriginMode: unsigned char
126126
eSpriteOrigin_Center,
127127
};
128128

129+
enum eSpriteOrientation: unsigned char
130+
{
131+
eSpriteOrientation_N, // +90 degrees
132+
eSpriteOrientation_E, // 0 degrees, default
133+
eSpriteOrientation_S // -90 degrees
134+
};
135+
129136
// Object sprites draw prioriry
130137
enum eSpriteDrawOrder: unsigned char
131138
{

src/GameObject.cpp

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "AudioManager.h"
66
#include "PhysicsManager.h"
77
#include "GameMapManager.h"
8+
#include "SpriteManager.h"
89

910
GameObject::GameObject(eGameObjectClass objectTypeID, GameObjectID uniqueID)
1011
: mObjectID(uniqueID)
@@ -40,6 +41,19 @@ void GameObject::FreeSounds()
4041
}
4142
}
4243

44+
void GameObject::SetSprite(int spriteIndex, SpriteDeltaBits deltaBits)
45+
{
46+
if (deltaBits > 0)
47+
{
48+
gSpriteManager.GetSpriteTexture(mObjectID, spriteIndex, mRemapClut, deltaBits, mDrawSprite);
49+
}
50+
else
51+
{
52+
gSpriteManager.GetSpriteTexture(mObjectID, spriteIndex, mRemapClut, mDrawSprite);
53+
}
54+
RefreshDrawSprite();
55+
}
56+
4357
void GameObject::SetPhysics(PhysicsBody* physicsBody)
4458
{
4559
if (mPhysicsBody)
@@ -120,7 +134,17 @@ bool GameObject::ReceiveDamage(const DamageInfo& damageInfo)
120134

121135
void GameObject::RefreshDrawSprite()
122136
{
123-
mDrawSprite.mRotateAngle = mTransformSmooth.mOrientation - cxx::angle_t::from_degrees(SPRITE_ZERO_ANGLE);
137+
cxx::angle_t angleOffset;
138+
if (mDrawSpriteOrientation == eSpriteOrientation_N)
139+
{
140+
angleOffset = cxx::angle_t::from_degrees(SPRITE_ZERO_ANGLE);
141+
}
142+
if (mDrawSpriteOrientation == eSpriteOrientation_S)
143+
{
144+
angleOffset = -cxx::angle_t::from_degrees(SPRITE_ZERO_ANGLE);
145+
}
146+
147+
mDrawSprite.mRotateAngle = mTransformSmooth.mOrientation + angleOffset;
124148

125149
mDrawSprite.mPosition.x = mTransformSmooth.mPosition.x;
126150
mDrawSprite.mPosition.y = mTransformSmooth.mPosition.z;

src/GameObject.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ class GameObject: public cxx::handled_object
122122
void InitSounds();
123123
void FreeSounds();
124124

125+
void SetSprite(int spriteIndex, SpriteDeltaBits deltaBits = 0);
125126
void SetPhysics(PhysicsBody* physicsBody);
126127
void SetParentObject(GameObject* gameObject);
127128
void RefreshDrawSprite();
@@ -145,6 +146,8 @@ class GameObject: public cxx::handled_object
145146

146147
// drawing spricific data
147148
Sprite2D mDrawSprite;
149+
eSpriteOrientation mDrawSpriteOrientation = eSpriteOrientation_S;
150+
int mRemapClut = 0;
148151
cxx::aabbox2d_t mDrawBounds; // sprite bounds cache
149152

150153
private:

src/Obstacle.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void Obstacle::UpdateFrame()
1919
float deltaTime = gTimeManager.mGameFrameDelta;
2020
if (mAnimationState.UpdateFrame(deltaTime))
2121
{
22-
SetupSpriteFrame();
22+
SetSprite(mAnimationState.GetSpriteIndex(), 0);
2323
}
2424
}
2525

@@ -31,16 +31,12 @@ void Obstacle::HandleSpawn()
3131
{
3232
debug_assert(mGameObjectDesc);
3333

34+
mRemapClut = 0;
35+
3436
mAnimationState.Clear();
3537
mAnimationState.mAnimDesc = mGameObjectDesc->mAnimationData;
3638

3739
//mAnimationState.PlayAnimation(eSpriteAnimLoop_FromStart);
3840

39-
SetupSpriteFrame();
40-
}
41-
42-
void Obstacle::SetupSpriteFrame()
43-
{
44-
gSpriteManager.GetSpriteTexture(mObjectID, mAnimationState.GetSpriteIndex(), 0, mDrawSprite);
45-
RefreshDrawSprite();
41+
SetSprite(mAnimationState.GetSpriteIndex(), 0);
4642
}

src/Obstacle.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ class Obstacle final: public GameObject
1414
void DebugDraw(DebugRenderer& debugRender) override;
1515
void HandleSpawn() override;
1616

17-
private:
18-
void SetupSpriteFrame();
19-
2017
private:
2118
SpriteAnimation mAnimationState;
2219
GameObjectInfo* mGameObjectDesc = nullptr;

0 commit comments

Comments
 (0)