aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsalaaad2 <arthurdurant263@gmail.com>2022-01-11 17:04:34 +0100
committersalaaad2 <arthurdurant263@gmail.com>2022-01-11 17:04:34 +0100
commit0f52cc0373370d639b8de42c7c9551da0db86d52 (patch)
tree35c270760a1d9b3b1c11e3a3b55268aac464d1ea
parentmouselook on shotgun (diff)
downloadthreshold-0f52cc0373370d639b8de42c7c9551da0db86d52.tar.gz
threshold-0f52cc0373370d639b8de42c7c9551da0db86d52.tar.bz2
threshold-0f52cc0373370d639b8de42c7c9551da0db86d52.tar.xz
threshold-0f52cc0373370d639b8de42c7c9551da0db86d52.tar.zst
threshold-0f52cc0373370d639b8de42c7c9551da0db86d52.zip
clang-format chromium test
-rw-r--r--.clang-format212
-rw-r--r--src/gameplay.cpp27
-rw-r--r--src/gameplay.hpp4
-rw-r--r--src/wp_assaultrifle.cpp29
-rw-r--r--src/wp_shotty.cpp1
5 files changed, 233 insertions, 40 deletions
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..9ece3d6
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,212 @@
+---
+Language: Cpp
+# BasedOnStyle: Chromium
+AccessModifierOffset: -1
+AlignAfterOpenBracket: Align
+AlignArrayOfStructures: None
+AlignConsecutiveMacros: None
+AlignConsecutiveAssignments: None
+AlignConsecutiveBitFields: None
+AlignConsecutiveDeclarations: None
+AlignEscapedNewlines: Left
+AlignOperands: Align
+AlignTrailingComments: true
+AllowAllArgumentsOnNextLine: true
+AllowAllConstructorInitializersOnNextLine: true
+AllowAllParametersOfDeclarationOnNextLine: false
+AllowShortEnumsOnASingleLine: true
+AllowShortBlocksOnASingleLine: Never
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: Inline
+AllowShortLambdasOnASingleLine: All
+AllowShortIfStatementsOnASingleLine: Never
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: true
+AlwaysBreakTemplateDeclarations: Yes
+AttributeMacros:
+ - __capability
+BinPackArguments: true
+BinPackParameters: false
+BraceWrapping:
+ AfterCaseLabel: false
+ AfterClass: false
+ AfterControlStatement: Never
+ AfterEnum: false
+ AfterFunction: false
+ AfterNamespace: false
+ AfterObjCDeclaration: false
+ AfterStruct: false
+ AfterUnion: false
+ AfterExternBlock: false
+ BeforeCatch: false
+ BeforeElse: false
+ BeforeLambdaBody: false
+ BeforeWhile: false
+ IndentBraces: false
+ SplitEmptyFunction: true
+ SplitEmptyRecord: true
+ SplitEmptyNamespace: true
+BreakBeforeBinaryOperators: None
+BreakBeforeConceptDeclarations: true
+BreakBeforeBraces: Attach
+BreakBeforeInheritanceComma: false
+BreakInheritanceList: BeforeColon
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializersBeforeComma: false
+BreakConstructorInitializers: BeforeColon
+BreakAfterJavaFieldAnnotations: false
+BreakStringLiterals: true
+ColumnLimit: 80
+CommentPragmas: '^ IWYU pragma:'
+CompactNamespaces: false
+ConstructorInitializerAllOnOneLineOrOnePerLine: true
+ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: true
+DeriveLineEnding: true
+DerivePointerAlignment: false
+DisableFormat: false
+EmptyLineAfterAccessModifier: Never
+EmptyLineBeforeAccessModifier: LogicalBlock
+ExperimentalAutoDetectBinPacking: false
+FixNamespaceComments: true
+ForEachMacros:
+ - foreach
+ - Q_FOREACH
+ - BOOST_FOREACH
+IfMacros:
+ - KJ_IF_MAYBE
+IncludeBlocks: Preserve
+IncludeCategories:
+ - Regex: '^<ext/.*\.h>'
+ Priority: 2
+ SortPriority: 0
+ CaseSensitive: false
+ - Regex: '^<.*\.h>'
+ Priority: 1
+ SortPriority: 0
+ CaseSensitive: false
+ - Regex: '^<.*'
+ Priority: 2
+ SortPriority: 0
+ CaseSensitive: false
+ - Regex: '.*'
+ Priority: 3
+ SortPriority: 0
+ CaseSensitive: false
+IncludeIsMainRegex: '([-_](test|unittest))?$'
+IncludeIsMainSourceRegex: ''
+IndentAccessModifiers: false
+IndentCaseLabels: true
+IndentCaseBlocks: false
+IndentGotoLabels: true
+IndentPPDirectives: None
+IndentExternBlock: AfterExternBlock
+IndentRequires: false
+IndentWidth: 2
+IndentWrappedFunctionNames: false
+InsertTrailingCommas: None
+JavaScriptQuotes: Leave
+JavaScriptWrapImports: true
+KeepEmptyLinesAtTheStartOfBlocks: false
+LambdaBodyIndentation: Signature
+MacroBlockBegin: ''
+MacroBlockEnd: ''
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: None
+ObjCBinPackProtocolList: Never
+ObjCBlockIndentWidth: 2
+ObjCBreakBeforeNestedBlockParam: true
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: true
+PenaltyBreakAssignment: 2
+PenaltyBreakBeforeFirstCallParameter: 1
+PenaltyBreakComment: 300
+PenaltyBreakFirstLessLess: 120
+PenaltyBreakString: 1000
+PenaltyBreakTemplateDeclaration: 10
+PenaltyExcessCharacter: 1000000
+PenaltyReturnTypeOnItsOwnLine: 200
+PenaltyIndentedWhitespace: 0
+PointerAlignment: Left
+PPIndentWidth: -1
+RawStringFormats:
+ - Language: Cpp
+ Delimiters:
+ - cc
+ - CC
+ - cpp
+ - Cpp
+ - CPP
+ - 'c++'
+ - 'C++'
+ CanonicalDelimiter: ''
+ BasedOnStyle: google
+ - Language: TextProto
+ Delimiters:
+ - pb
+ - PB
+ - proto
+ - PROTO
+ EnclosingFunctions:
+ - EqualsProto
+ - EquivToProto
+ - PARSE_PARTIAL_TEXT_PROTO
+ - PARSE_TEST_PROTO
+ - PARSE_TEXT_PROTO
+ - ParseTextOrDie
+ - ParseTextProtoOrDie
+ - ParseTestProto
+ - ParsePartialTestProto
+ CanonicalDelimiter: pb
+ BasedOnStyle: google
+ReferenceAlignment: Pointer
+ReflowComments: true
+ShortNamespaceLines: 1
+SortIncludes: CaseSensitive
+SortJavaStaticImport: Before
+SortUsingDeclarations: true
+SpaceAfterCStyleCast: false
+SpaceAfterLogicalNot: false
+SpaceAfterTemplateKeyword: true
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeCaseColon: false
+SpaceBeforeCpp11BracedList: false
+SpaceBeforeCtorInitializerColon: true
+SpaceBeforeInheritanceColon: true
+SpaceBeforeParens: ControlStatements
+SpaceAroundPointerQualifiers: Default
+SpaceBeforeRangeBasedForLoopColon: true
+SpaceInEmptyBlock: false
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 2
+SpacesInAngles: Never
+SpacesInConditionalStatement: false
+SpacesInContainerLiterals: true
+SpacesInCStyleCastParentheses: false
+SpacesInLineCommentPrefix:
+ Minimum: 1
+ Maximum: -1
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+SpaceBeforeSquareBrackets: false
+BitFieldColonSpacing: Both
+Standard: Auto
+StatementAttributeLikeMacros:
+ - Q_EMIT
+StatementMacros:
+ - Q_UNUSED
+ - QT_REQUIRE_VERSION
+TabWidth: 8
+UseCRLF: false
+UseTab: Never
+WhitespaceSensitiveMacros:
+ - STRINGIZE
+ - PP_STRINGIZE
+ - BOOST_PP_STRINGIZE
+ - NS_SWIFT_NAME
+ - CF_SWIFT_NAME
+...
+
diff --git a/src/gameplay.cpp b/src/gameplay.cpp
index 3a3d09b..9017de0 100644
--- a/src/gameplay.cpp
+++ b/src/gameplay.cpp
@@ -158,16 +158,6 @@ void Game::draw()
}
-int Game::getDiff(Vector2 pos, Vector2 tip, Vector2 target) const
-{
- if(((tip.x-pos.x)*(target.y-pos.y)-(tip.y-pos.y)*(target.x-pos.x))<0)
- return -1;
- if(((tip.x-pos.x)*(target.y-pos.y)-(tip.y-pos.y)*(target.x-pos.x))>0)
- return 1;
-
- return 0;
-}
-
// progress the game & check for player death
// NEW: go towards player NEXT: spawn at different furyTimes
int Game::tick() const
@@ -222,7 +212,7 @@ int Game::tick() const
if (en->hp != 0 && // check for player death (one shot one kill)
CheckCollisionCircles((Vector2){player->posX, player->posY}, 10,
(Vector2){en->posX, en->posY}, 40)) {
- std::cout << "cool" << std::endl;
+ return (1);
}
}
return (0);
@@ -263,14 +253,7 @@ int Game::getKeys() const
if (IsKeyDown(KEY_TWO)) {
player->currentWeapon = player->wp[1];
}
- if (IsKeyDown(KEY_LEFT)) {
- player->direction = Vector2Rotate(player->direction, -0.1f); // left
- }
- if (IsKeyDown(KEY_RIGHT)) {
- player->direction = Vector2Rotate(player->direction, 0.1f);
- }
- if (IsKeyPressed(KEY_SPACE)) {
- std::cout << "key space";
+ if (IsKeyPressed(KEY_SPACE) || IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
if (shoot()) {
return (0);
}
@@ -280,14 +263,12 @@ int Game::getKeys() const
}
if (player->threshold)
{
- if (GetTime() >= (player->furyTime + 5))
- {
+ if (GetTime() >= (player->furyTime + 5)) {
player->fury = 0;
player->threshold = false;
}
if (oldX != player->posX ||
- oldY != player->posY)
- {
+ oldY != player->posY) {
if (this->tick()) {
return (1);
}
diff --git a/src/gameplay.hpp b/src/gameplay.hpp
index 17a17f4..b379332 100644
--- a/src/gameplay.hpp
+++ b/src/gameplay.hpp
@@ -41,7 +41,7 @@ class Game {
int nWaves; // number of waves in level
int nPerWave; // number of enemies per wave.
- // NOTE : maps are assumed to be correct. tyhus, no
+ // NOTE : maps are assumed to be correct. therefore, no
// checks are made to verify their integrity.
// having wrong maps can (and probably will) result in a crash
@@ -75,8 +75,6 @@ class Game {
int shoot() const;
int hit(Entity en, Vector2 add1, Vector2 add2) const ;
- int getDiff(Vector2 pos, Vector2 tip, Vector2 target) const ;
-
std::string const &getNext() const; // returns next level's string
std::string const &getCurrent() const; // returns next level's string
};
diff --git a/src/wp_assaultrifle.cpp b/src/wp_assaultrifle.cpp
index 1ed9e19..2d4ab0f 100644
--- a/src/wp_assaultrifle.cpp
+++ b/src/wp_assaultrifle.cpp
@@ -7,7 +7,7 @@
#include "entity.hpp"
wp_assaultrifle::wp_assaultrifle(const char *s, const char *r)
- : AWeapon(100, 10, 30, 0.0, s, r)
+ : AWeapon(300.0f, 10, 30, 0.0, s, r)
{}
@@ -18,22 +18,25 @@ int wp_assaultrifle::bang(std::vector<Entity> * enemies, Entity * player)
{
return (1);
} else {
+ Vector2 playerDirection = Vector2Normalize(player->direction);
+ playerDirection.x *= range;
+ playerDirection.y *= range;
+ Vector2 playerPosition = (Vector2){player->posX, player->posY};
+ Vector2 rot1 = Vector2Rotate(playerDirection, -0.2f);
+ Vector2 rot2 = Vector2Rotate(playerDirection, 0.2f);
+
+ Vector2 add1 = Vector2Add(playerPosition, rot1);
+ Vector2 add2 = Vector2Add(playerPosition, rot2);
+
+ Vector2 r;
barrel--;
PlaySound(shot);
+ t = GetTime();
// here
//
- Vector2 playerDirection = player->direction;
- Vector2 playerPosition = (Vector2){player->posX, player->posY};
- auto rot1 = Vector2Rotate(playerDirection, -0.2f);
- auto rot2 = Vector2Rotate(playerDirection, 0.2f);
-
- auto add1 = Vector2Add(playerPosition, rot1);
- auto add2 = Vector2Add(playerPosition, rot2);
-
- auto r = playerDirection;
- r.x *= 4;
- r.y *= 4;
-
+ r = playerDirection;
+ r.x *= 2;
+ r.y *= 2;
for (auto en = enemies->begin(); en != enemies->end(); en++)
{
if (CheckCollisionPointLine((Vector2){en->posX, en->posY}, playerPosition, add1, (en->radius * 2)) ||
diff --git a/src/wp_shotty.cpp b/src/wp_shotty.cpp
index 1b5573a..e60e0aa 100644
--- a/src/wp_shotty.cpp
+++ b/src/wp_shotty.cpp
@@ -35,7 +35,6 @@ int wp_shotty::bang(std::vector<Entity> * enemies, Entity * player)
t = GetTime();
// here
//
- std::cout << "range : " << range << std::endl;
r = playerDirection;
r.x *= 2;
r.y *= 2;