1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
|
//////////////////////////////////
/* CLIP SET */
//////////////////////////////////
struct ClipSet
{
public:
vector<SDL_Rect> Clips;
int Period;
int i;
ClipSet(int Period_);
SDL_Rect IncrementClip();
SDL_Rect IncrementClip(int StartingPoint_); //Override point where clip starts
};
ClipSet::ClipSet(int Period_)
{
Period = Period_;
i = 0;
}
SDL_Rect ClipSet::IncrementClip()
{
i = i + 1;
return Clips[(i/Period)%Clips.size()];
}
SDL_Rect ClipSet::IncrementClip(int StartingPoint_)
{
i = i + 1;
return Clips[StartingPoint_ + i/Period];
}
///////////////////////////////////////////
/*****************************************/
/* HERO */
/*****************************************/
///////////////////////////////////////////
class Hero
{
public:
int SpawnItems;
int PosX, PosY, HP, dt;
double PosXDoub, PosYDoub, PosXDoubProp, PosYDoubProp, DeltaX, DeltaY, VelX, VelY, Run_Vel, Jump_Vel, Jump_Space, TerminalVelocity, g, tpower, FloorPosYDoub, StunnedSpdX, RunSpdX, FloatSpdX;
int CurrentTile, ProposedTile, SlopeSign;
int ArmPosX, ArmPosY, LastShotTime, ShotRechargeTime, BusterUpTime;
int HitTime, StunDuration, InvincibleDuration;
bool Grounded, LoadShootClips, AcceptMove, Stunned, Invincible, Dead, Rotate;
direction HitDirection, LookingDirection;
int LeftClipCounter, RightClipCounter, RightClipTotal, RightClipPeriod, StunClipCounter, StunClipTotal, StunClipPeriod;
ClipSet* CurrentClipSet, LastClipSet;
ClipSet RunningClips;
SDL_Rect* Clip;
SDL_Rect SourceClip, DestinationClip;
SDL_Rect RightClip[11], RightShootClip[11], JumpClip[6], StandClip, StandShootClip, StunClip[5];
hitbox HitBox;
Hero();
void CheckGrounded();
void Move(int dt_);
void Move_Old();
void Move_Right();
void Move_Left();
void Move_Stand(){VelX = 0;};
void Move_Jump();
void Move_Fall();
void Move_Shoot();
void Move_Camera();
void GetRenderClip(); //Need to rename and rework this one
void GetSourceClip();
void GetHit(int DamageType);
};
Hero hero;
Hero::Hero() : RunningClips(11)
{
PosX = 31;
PosY = 463;
HitBox.x = PosX;
HitBox.y = PosY;
HitBox.w = 16;
HitBox.h = 32;
ProposedTile = CurrentTile;
HP = 100;
SpawnItems = 4;
PosXDoub = PosX;
PosYDoub = PosY;
DeltaX = 0;
AcceptMove = false;
StunDuration = 1500;
InvincibleDuration = 3000;
Dead = false;
ShotRechargeTime = 150;
LastShotTime = 0;
BusterUpTime = 300;
VelY = 0;
Run_Vel = 0.1;
RunSpdX = Run_Vel;
FloatSpdX = Run_Vel;
Jump_Vel = 0.55;
VelY = 0;
TerminalVelocity = 1.2*Jump_Vel;
Jump_Space = 64;
SlopeSign = 0;
g = 0.006;
tpower = 0.8;
Grounded = true;
LookingDirection = Right;
LoadShootClips = false;
RightClipCounter = 0;
LeftClipCounter = 0;
RightClipTotal = 11;
RightClipPeriod = 16;
StunClipCounter = 0;
StunClipTotal = 5;
StunClipPeriod = 32;
CurrentClipSet = &RunningClips;
//LastClipSet = &CurrentClipSet;
StandClip = {159,78,30,32};
StandShootClip = {41,167,29,34};
RightClip[0] = {319,19,30,33};
RightClip[1] = {350,19,20,33};
RightClip[2] = {371,18,23,34};
RightClip[3] = {394,19,32,33};
RightClip[4] = {426,20,34,32};
RightClip[5] = {460,20,26,32};
RightClip[6] = {489,19,22,33};
RightClip[7] = {511,18,25,34};
RightClip[8] = {539,19,30,33};
RightClip[9] = {570,20,34,32};
RightClip[10] = {604,20,29,32};
for( int i = 0; i < 10; i++ )
{
RunningClips.Clips.push_back(RightClip[i]);
}
RightShootClip[0] = {290,71,28,33};
RightShootClip[1] = {319,70,31,34};
RightShootClip[2] = {351,71,34,33};
RightShootClip[3] = {387,72,37,32};
RightShootClip[4] = {426,72,33,32};
RightShootClip[5] = {460,71,30,33};
RightShootClip[6] = {491,70,32,34};
RightShootClip[7] = {524,71,34,33};
RightShootClip[8] = {560,72,36,32};
RightShootClip[9] = {597,72,34,32};
RightShootClip[10] = RightShootClip[0];
JumpClip[0] = {5,73,23,36};
JumpClip[1] = {34,69,13,40};
JumpClip[2] = {55,64,18,45};
JumpClip[3] = {77,69,22,40};
JumpClip[4] = {102,68,26,41};
JumpClip[5] = {134,72,23,37};
StunClip[0] = {10,316,25,35};
StunClip[1] = {72,318,28,33};
StunClip[2] = {105, 308, 31, 47};
StunClip[3] = {139,318,28,33};
StunClip[4] = {341, 316, 25, 35};
SourceClip = StandClip;
}
|