Reformat code
This commit is contained in:
@@ -1,33 +1,31 @@
|
||||
---
|
||||
Language: Cpp
|
||||
Language: Cpp
|
||||
# BasedOnStyle: LLVM
|
||||
AccessModifierOffset: -2
|
||||
AlignAfterOpenBracket: true
|
||||
AlignEscapedNewlinesLeft: false
|
||||
AlignOperands: true
|
||||
AlignAfterOpenBracket: AlwaysBreak
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: Always
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortIfStatementsOnASingleLine: false
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AlwaysBreakAfterDefinitionReturnType: false
|
||||
AlwaysBreakTemplateDeclarations: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakTemplateDeclarations: No
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BinPackParameters: true
|
||||
BinPackArguments: true
|
||||
ColumnLimit: 80
|
||||
BinPackArguments: false
|
||||
ColumnLimit: 120
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
DerivePointerAlignment: false
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
IndentCaseLabels: false
|
||||
IndentWrappedFunctionNames: false
|
||||
IndentFunctionDeclarationAfterType: false
|
||||
MaxEmptyLinesToKeep: 1
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
NamespaceIndentation: None
|
||||
@@ -43,23 +41,23 @@ PenaltyReturnTypeOnItsOwnLine: 60
|
||||
PointerAlignment: Right
|
||||
SpacesBeforeTrailingComments: 1
|
||||
Cpp11BracedListStyle: true
|
||||
Standard: Cpp11
|
||||
IndentWidth: 4
|
||||
TabWidth: 4
|
||||
UseTab: true
|
||||
Standard: c++11
|
||||
IndentWidth: 4
|
||||
TabWidth: 4
|
||||
UseTab: AlignWithSpaces
|
||||
BreakBeforeBraces: Attach
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
SpacesInAngles: false
|
||||
SpacesInAngles: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpaceAfterCStyleCast: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
ContinuationIndentWidth: 4
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
|
||||
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
|
||||
SpaceBeforeParens: ControlStatements
|
||||
DisableFormat: false
|
||||
DisableFormat: false
|
||||
AlignConsecutiveAssignments: Consecutive
|
||||
...
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ Entity ent_Platform;
|
||||
Entity ent_Block;
|
||||
|
||||
int EntityApplyGravity(Entity e) {
|
||||
float grav = 10.0f;
|
||||
float grav = 10.0f;
|
||||
float vTerminal = 50.0f;
|
||||
vec2 vGrav;
|
||||
|
||||
@@ -35,9 +35,9 @@ int EntityApplyGravity(Entity e) {
|
||||
}
|
||||
|
||||
void Player_Proc(Entity e, int ft) {
|
||||
float acel = 8.0f;
|
||||
float maxVel = 30.0f;
|
||||
float jumpVel = 50.0f;
|
||||
float acel = 8.0f;
|
||||
float maxVel = 30.0f;
|
||||
float jumpVel = 50.0f;
|
||||
float airMovementFactor = 0.1f;
|
||||
|
||||
// Process elasticity
|
||||
@@ -48,8 +48,7 @@ void Player_Proc(Entity e, int ft) {
|
||||
Entity_SetScale(e, entityScale);
|
||||
|
||||
if (e->A > 0) {
|
||||
if (Input_GetKey(InputKey_Jump) == InputKey_Pressed ||
|
||||
Input_GetKey(InputKey_Up) == InputKey_Pressed) {
|
||||
if (Input_GetKey(InputKey_Jump) == InputKey_Pressed || Input_GetKey(InputKey_Up) == InputKey_Pressed) {
|
||||
|
||||
// Apply jump
|
||||
if (e->vel[1] > (-jumpVel)) {
|
||||
@@ -91,8 +90,7 @@ void Player_Proc(Entity e, int ft) {
|
||||
Entity_AddVelLimit(e, right, maxVel * airMovementFactor);
|
||||
}
|
||||
}
|
||||
if (Input_GetKey(InputKey_Action1) == InputKey_Pressed ||
|
||||
Input_GetKey(InputKey_Action2) == InputKey_Pressed) {
|
||||
if (Input_GetKey(InputKey_Action1) == InputKey_Pressed || Input_GetKey(InputKey_Action2) == InputKey_Pressed) {
|
||||
Entity_SetScale(e, (float[2]){1.0f, 1.0f});
|
||||
}
|
||||
|
||||
@@ -114,14 +112,12 @@ int Player_Collision(Entity ent, Entity ent2, float t, vec2 n) {
|
||||
if (fabs(n[0]) > fabs(n[1])) {
|
||||
float intensity = (fabs(ent->vel[0]) - 10.0f) / 40.0f;
|
||||
if (intensity > 0) {
|
||||
Entity_SetScale(ent, (float[2]){1.0f - (0.3f * intensity),
|
||||
1.0f + (0.3f * intensity)});
|
||||
Entity_SetScale(ent, (float[2]){1.0f - (0.3f * intensity), 1.0f + (0.3f * intensity)});
|
||||
}
|
||||
} else {
|
||||
float intensity = (fabs(ent->vel[1]) - 10.0f) / 40.0f;
|
||||
if (intensity > 0) {
|
||||
Entity_SetScale(ent, (float[2]){1.0f + (0.3f * intensity),
|
||||
1.0f - (0.3f * intensity)});
|
||||
Entity_SetScale(ent, (float[2]){1.0f + (0.3f * intensity), 1.0f - (0.3f * intensity)});
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
@@ -133,52 +129,52 @@ void GameEnts_Init() {
|
||||
// Load and initialize media.
|
||||
//
|
||||
|
||||
img_player = Draw_LoadImage("data/player.png");
|
||||
img_player = Draw_LoadImage("data/player.png");
|
||||
img_platform = Draw_LoadImage("data/platform.png");
|
||||
img_block = Draw_LoadImage("data/block.png");
|
||||
img_block = Draw_LoadImage("data/block.png");
|
||||
|
||||
/////////////////////////
|
||||
// Initialize entity types.
|
||||
//
|
||||
|
||||
ent_Player = Entity_New();
|
||||
ent_Player = Entity_New();
|
||||
ent_Player->type = Ent_Player;
|
||||
// ent_Player->flags=EntityFlag_Light;
|
||||
// Entity_SetLight(ent_Player,.2,.2,.2,200);
|
||||
ent_Player->flags = EntityFlag_Collision | EntityFlag_Overlap;
|
||||
ent_Player->flags = EntityFlag_Collision | EntityFlag_Overlap;
|
||||
ent_Player->zorder = 0;
|
||||
AnimPlay_SetImg(&ent_Player->anim, img_player);
|
||||
ent_Player->proc = Player_Proc;
|
||||
ent_Player->postproc = Player_PostProc;
|
||||
ent_Player->collision = Player_Collision;
|
||||
ent_Player->mass = 1.0f;
|
||||
ent_Player->radius = 12;
|
||||
ent_Player->width = 24;
|
||||
ent_Player->height = 24;
|
||||
ent_Player->fric_static = 0.0f;
|
||||
ent_Player->proc = Player_Proc;
|
||||
ent_Player->postproc = Player_PostProc;
|
||||
ent_Player->collision = Player_Collision;
|
||||
ent_Player->mass = 1.0f;
|
||||
ent_Player->radius = 12;
|
||||
ent_Player->width = 24;
|
||||
ent_Player->height = 24;
|
||||
ent_Player->fric_static = 0.0f;
|
||||
ent_Player->fric_dynamic = 0.2f;
|
||||
|
||||
ent_Platform = Entity_New();
|
||||
ent_Platform->type = Ent_Platform;
|
||||
ent_Platform->flags = EntityFlag_PlatformCollision;
|
||||
ent_Platform = Entity_New();
|
||||
ent_Platform->type = Ent_Platform;
|
||||
ent_Platform->flags = EntityFlag_PlatformCollision;
|
||||
ent_Platform->zorder = -1;
|
||||
AnimPlay_SetImg(&ent_Platform->anim, img_platform);
|
||||
ent_Platform->mass = 0.0f;
|
||||
ent_Platform->radius = 12;
|
||||
ent_Platform->width = 64;
|
||||
ent_Platform->height = 16;
|
||||
ent_Platform->fric_static = 0.0f;
|
||||
ent_Platform->mass = 0.0f;
|
||||
ent_Platform->radius = 12;
|
||||
ent_Platform->width = 64;
|
||||
ent_Platform->height = 16;
|
||||
ent_Platform->fric_static = 0.0f;
|
||||
ent_Platform->fric_dynamic = 0.2f;
|
||||
|
||||
ent_Block = Entity_New();
|
||||
ent_Block->type = Ent_Block;
|
||||
ent_Block->flags = EntityFlag_BlockCollision;
|
||||
ent_Block = Entity_New();
|
||||
ent_Block->type = Ent_Block;
|
||||
ent_Block->flags = EntityFlag_BlockCollision;
|
||||
ent_Block->zorder = -1;
|
||||
AnimPlay_SetImg(&ent_Block->anim, img_block);
|
||||
ent_Block->mass = 0.0f;
|
||||
ent_Block->radius = 32;
|
||||
ent_Block->width = 64;
|
||||
ent_Block->height = 64;
|
||||
ent_Block->fric_static = 0.0f;
|
||||
ent_Block->mass = 0.0f;
|
||||
ent_Block->radius = 32;
|
||||
ent_Block->width = 64;
|
||||
ent_Block->height = 64;
|
||||
ent_Block->fric_static = 0.0f;
|
||||
ent_Block->fric_dynamic = 0.2f;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ int GameMap_LoadLevel(char *filename, int res) {
|
||||
}
|
||||
|
||||
// Read the file to determine sizes
|
||||
width = 0;
|
||||
width = 0;
|
||||
height = 0;
|
||||
do {
|
||||
len = ReadLine(file, line, MaxLineLen);
|
||||
|
||||
@@ -44,7 +44,7 @@ int main(int argc, char *argv[]) {
|
||||
/////////////////////////////
|
||||
// Load and initialize media.
|
||||
//
|
||||
font = Draw_DefaultFont(255, 255, 255, 255);
|
||||
font = Draw_DefaultFont(255, 255, 255, 255);
|
||||
imgBackground = Draw_LoadImage("data/background.png");
|
||||
Draw_SetOffset(imgBackground, 0, 0);
|
||||
GameEnts_Init();
|
||||
@@ -59,8 +59,7 @@ int main(int argc, char *argv[]) {
|
||||
// Run the world.
|
||||
//
|
||||
GameLib_CleanParallaxBackgrounds();
|
||||
GameLib_AddParallaxBackground(imgBackground, (int[2]){512, 512},
|
||||
(int[2]){0, 0}, (float[2]){0.5f, 0.0f});
|
||||
GameLib_AddParallaxBackground(imgBackground, (int[2]){512, 512}, (int[2]){0, 0}, (float[2]){0.5f, 0.0f});
|
||||
GameLib_Loop(ProcGame, PostProcGame, PreDrawGame, DrawGame);
|
||||
|
||||
return (0);
|
||||
|
||||
Reference in New Issue
Block a user