Merge pull request 'develop' (#55) from develop into master

Reviewed-on: #55
This commit is contained in:
Chris Cromer 2022-10-10 21:57:13 -03:00
commit 298a21d516
36 changed files with 390 additions and 168 deletions

220
.clang-format Normal file
View File

@ -0,0 +1,220 @@
---
AccessModifierOffset: 0
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: Always
IndentAccessModifiers: true
TabWidth: 4
UseTab: Never
UseCRLF: false
Language: Cpp
IndentWidth: 4
AlignAfterOpenBracket: DontAlign
AlignArrayOfStructures: Left
AlignConsecutiveAssignments: AcrossComments
AlignConsecutiveBitFields: AcrossComments
AlignConsecutiveDeclarations: None
AlignConsecutiveMacros: AcrossComments
AlignEscapedNewlines: Left
AlignOperands: AlignAfterOperator
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: None
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: No
BinPackArguments: false
BinPackParameters: false
AttributeMacros:
- __capability
BitFieldColonSpacing: Both
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: true
BeforeWhile: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBraces: Custom
BreakAfterJavaFieldAnnotations: false
BreakBeforeBinaryOperators: All
BreakBeforeConceptDeclarations: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterColon
BreakStringLiterals: false
ColumnLimit: 0
CommentPragmas: "^ IWYU pragma:"
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Regroup
IncludeCategories:
- Regex: ^<ext/.*\.h>
Priority: 2
CaseSensitive: false
SortPriority: 0
- Regex: ^<.*\.h>
Priority: 1
CaseSensitive: false
SortPriority: 0
- Regex: ^<.*
Priority: 2
CaseSensitive: false
SortPriority: 0
- Regex: .*
Priority: 0
CaseSensitive: false
SortPriority: 0
IncludeIsMainRegex: ([-_](test|unittest))?$
IncludeIsMainSourceRegex: ""
IndentCaseBlocks: true
IndentCaseLabels: true
IndentExternBlock: Indent
IndentGotoLabels: false
IndentPPDirectives: BeforeHash
IndentRequires: true
IndentWrappedFunctionNames: true
InsertTrailingCommas: None
JavaScriptQuotes: Double
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
LambdaBodyIndentation: OuterScope
MacroBlockBegin: ""
MacroBlockEnd: ""
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 4
ObjCBreakBeforeNestedBlockParam: false
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PPIndentWidth: 4
PackConstructorInitializers: Never
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyIndentedWhitespace: 0
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
QualifierAlignment: Left
RawStringFormats:
- Language: Cpp
BasedOnStyle: google
Delimiters:
- cc
- CC
- cpp
- Cpp
- CPP
- c++
- C++
CanonicalDelimiter: ""
- Language: TextProto
EnclosingFunctions:
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
- PARSE_TEST_PROTO
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
- ParseTestProto
- ParsePartialTestProto
BasedOnStyle: google
Delimiters:
- pb
- PB
- proto
- PROTO
CanonicalDelimiter: pb
ReferenceAlignment: Left
ReflowComments: false
RemoveBracesLLVM: false
SeparateDefinitionBlocks: Always
ShortNamespaceLines: 0
SortIncludes: CaseSensitive
SortJavaStaticImport: Before
SortUsingDeclarations: true
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: true
SpaceBeforeCpp11BracedList: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: Custom
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: false
AfterFunctionDeclarationName: false
AfterFunctionDefinitionName: false
AfterIfMacros: false
AfterOverloadedOperator: true
BeforeNonEmptyParentheses: false
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: 1
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
WhitespaceSensitiveMacros:
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
- NS_SWIFT_NAME
- CF_SWIFT_NAME

View File

@ -8,7 +8,7 @@
[node name="Main" type="Node"]
pause_mode = 2
script = ExtResource( 1 )
game_version = "1.0.0"
game_version = "1.1.0"
level = ExtResource( 2 )
[node name="Level" type="Node" parent="."]

View File

@ -2,6 +2,7 @@ extends Node
export var monitor_enabled: bool = false
export var anonymous: bool = true
export var debug: bool = false
export var development_url: String = "http://localhost:4050/api/v1"
var url_real: String = "https://alai.cromer.cl/api/v1"
@ -58,6 +59,7 @@ func _ready() -> void:
game_version = get_parent().game_version
if not anonymous:
player["rut"] = ""
player["name"] = ""
player["email"] = ""
@ -82,6 +84,7 @@ func _ready() -> void:
else:
os_id = 0
if not anonymous:
game["player"] = player
game["level_id"] = 0
game["os_id"] = os_id
@ -108,6 +111,12 @@ func _ready() -> void:
func _physics_process(_delta: float) -> void:
if monitor_enabled:
if anonymous and has_node("MonitorGUI"):
$MonitorGUI.queue_free()
Event.emit_signal("monitor_loaded")
get_tree().paused = false
start_monitor()
else:
if has_node("MonitorGUI") and not $MonitorGUI.visible:
$MonitorGUI.visible = true
Event.emit_signal("monitor_loaded")
@ -124,11 +133,11 @@ func _physics_process(_delta: float) -> void:
frames.append(frame)
if Input.is_action_just_pressed("Send"):
if debug and Input.is_action_just_pressed("Send"):
stop_monitor()
send_data()
else:
if Input.is_action_just_pressed("Send"):
if debug and Input.is_action_just_pressed("Send"):
start_monitor()
else:
get_tree().paused = false
@ -137,11 +146,13 @@ func _physics_process(_delta: float) -> void:
func _on_input_validated(validated_player: Dictionary) -> void:
if not anonymous:
$MonitorGUI.queue_free()
get_tree().paused = false
Event.emit_signal("game_started")
player = validated_player.duplicate(true)
game["player"] = player
start_monitor()
func _object_created(name: String, state: String, position: Vector2, velocity: Vector2) -> void:

View File

@ -49,5 +49,5 @@ namespace alai
*/
void _ready();
};
}
} // namespace alai
#endif

View File

@ -12,7 +12,6 @@ void alai::Event::_register_methods()
godot::register_signal<Event>("player_died");
godot::register_signal<Event>("player_won");
godot::register_signal<Event>("player_touched", "damage", GODOT_VARIANT_TYPE_INT);
}
alai::Event::Event()

View File

@ -15,6 +15,7 @@ namespace alai
class Event : public godot::Node
{
GODOT_CLASS(Event, godot::Node)
public:
/**
* @brief This method registers classes with Godot.
@ -42,6 +43,6 @@ namespace alai
*/
void _init();
};
}
} // namespace alai
#endif

View File

@ -1,6 +1,5 @@
#include "Main.h"
#include "Event.h"
#include "Main.h"
#include <SceneTree.hpp>
@ -66,8 +65,7 @@ void alai::Main::_ready()
{
_os->set_window_size(window_size);
_os->set_window_position(
_os->get_screen_position(get_launch_screen()) + _os->get_screen_size() * 0.5 - _os->get_window_size() * 0.5
);
_os->get_screen_position(get_launch_screen()) + _os->get_screen_size() * 0.5 - _os->get_window_size() * 0.5);
}
success = _project_settings->load_resource_pack("crt.pck");

View File

@ -1,7 +1,6 @@
#ifndef ALAI_MAIN_H
#define ALAI_MAIN_H
#include <string>
#include <Godot.hpp>
#include <Input.hpp>
#include <Node.hpp>
@ -10,6 +9,7 @@
#include <ProjectSettings.hpp>
#include <Ref.hpp>
#include <ResourceLoader.hpp>
#include <string>
/**
* @brief This is the alai namespace for all the code included in the game.
@ -227,6 +227,6 @@ namespace alai
*/
void load_level();
};
}
} // namespace alai
#endif

View File

@ -1,9 +1,8 @@
#include "Event.h"
#include "coin/CoinCollected.h"
#include "Event.h"
#include <AudioStreamPlayer.hpp>
#include <AnimationPlayer.hpp>
#include <AudioStreamPlayer.hpp>
void alai::CoinCollected::_register_methods()
{

View File

@ -68,6 +68,6 @@ namespace alai
*/
void _on_animation_finished(godot::String anim_name);
};
}
} // namespace alai
#endif

View File

@ -1,6 +1,5 @@
#include "coin/CoinCounter.h"
#include "Event.h"
#include "coin/CoinCounter.h"
#include <String.hpp>
@ -43,7 +42,8 @@ void alai::CoinCounter::_on_coin_collected(int amount)
{
coin_string = "0" + godot::String::num(coins);
}
else{
else
{
coin_string = godot::String::num(coins);
}
set_text(coin_string);

View File

@ -52,9 +52,8 @@ namespace alai
void _on_CoinHUD_ready();
void _on_coin_collected(int amount);
void _ready();
};
}
} // namespace alai
#endif

View File

@ -69,6 +69,6 @@ namespace alai
*/
void _on_body_entered(Node *node);
};
}
} // namespace alai
#endif

View File

@ -69,6 +69,6 @@ namespace alai
*/
void _on_Goal_body_entered(Node *node);
};
}
} // namespace alai
#endif

View File

@ -1,6 +1,5 @@
#include "goal/GoalReached.h"
#include "Event.h"
#include "goal/GoalReached.h"
#include <Area2D.hpp>

View File

@ -67,6 +67,6 @@ namespace alai
*
*/
};
}
} // namespace alai
#endif

View File

@ -1,22 +1,22 @@
#include <Godot.hpp>
#include "Event.h"
#include "state_machine/StateMachine.h"
#include "state_machine/State.h"
#include "Main.h"
#include "CameraLimit.h"
#include "player/Player.h"
#include "player/states/PlayerIdle.h"
#include "player/states/PlayerMove.h"
#include "player/states/PlayerJump.h"
#include "player/states/PlayerFall.h"
#include "coin/CoinNotCollected.h"
#include "Event.h"
#include "Main.h"
#include "coin/CoinCollected.h"
#include "coin/CoinCounter.h"
#include "goal/GoalReached.h"
#include "coin/CoinNotCollected.h"
#include "goal/GoalNotReached.h"
#include "goal/GoalReached.h"
#include "gui/game_over/GameOverScreen.h"
#include "gui/game_won/GameWonScreen.h"
#include "player/Player.h"
#include "player/states/PlayerFall.h"
#include "player/states/PlayerIdle.h"
#include "player/states/PlayerJump.h"
#include "player/states/PlayerMove.h"
#include "state_machine/State.h"
#include "state_machine/StateMachine.h"
#include <Godot.hpp>
/**
* @brief This function connects the gdnative init function.

View File

@ -1,6 +1,5 @@
#include "gui/game_over/GameOverScreen.h"
#include "Event.h"
#include "gui/game_over/GameOverScreen.h"
#include <AudioStreamPlayer.hpp>
#include <PackedScene.hpp>

View File

@ -5,7 +5,6 @@
#include <Godot.hpp>
#include <ResourceLoader.hpp>
namespace alai
{
/**
@ -57,6 +56,6 @@ namespace alai
void connect_signal();
void _on_visibility_changed();
};
}
} // namespace alai
#endif

View File

@ -1,6 +1,5 @@
#include "gui/game_won/GameWonScreen.h"
#include "Event.h"
#include "gui/game_won/GameWonScreen.h"
#include <AudioStreamPlayer.hpp>
#include <SceneTree.hpp>

View File

@ -47,6 +47,6 @@ namespace alai
void connect_signal();
void _on_visibility_changed();
};
}
} // namespace alai
#endif

View File

@ -1,6 +1,5 @@
#include "player/Player.h"
#include "Event.h"
#include "player/Player.h"
#include <AudioStreamPlayer.hpp>
#include <Camera2D.hpp>
@ -83,7 +82,8 @@ void alai::player::Player::_ready()
}
}
void alai::player::Player::_on_level_loaded() {
void alai::player::Player::_on_level_loaded()
{
auto state = get_node("StateMachine")->get_child(0);
if (state != nullptr)
{
@ -176,7 +176,8 @@ void alai::player::Player::_physics_process(float delta)
position.x = godot::Math::clamp((float) position.x, (float) camera->get_limit(0), (float) camera->get_limit(2) - sprite_node->get_sprite_frames()->get_frame("idle", 0)->get_size().x);
position.y = godot::Math::clamp((float) position.y, (float) camera->get_limit(1), (float) camera->get_limit(3) + sprite_node->get_sprite_frames()->get_frame("idle", 0)->get_size().y);
}
else {
else
{
WARN_PRINT("Could not clamp player based on sprite frame size!");
position.x = godot::Math::clamp((float) position.x, (float) camera->get_limit(0), (float) camera->get_limit(2));
position.y = godot::Math::clamp((float) position.y, (float) camera->get_limit(1), (float) camera->get_limit(3));
@ -196,11 +197,13 @@ void alai::player::Player::_physics_process(float delta)
{
// The first time the notifier is checked always returns false in the first frame
// So skip the check from the first frame
if (notifier_initialized) {
if (notifier_initialized)
{
auto event = get_node<alai::Event>("/root/Event");
event->emit_signal("player_died");
}
else {
else
{
notifier_initialized = true;
}
}

View File

@ -291,7 +291,7 @@ namespace alai
*/
void _on_level_loaded();
};
}
}
} // namespace player
} // namespace alai
#endif

View File

@ -1,6 +1,5 @@
#include "player/states/PlayerFall.h"
#include "player/Player.h"
#include "player/states/PlayerFall.h"
void alai::player::PlayerFall::_register_methods()
{

View File

@ -78,7 +78,7 @@ namespace alai
*/
void _physics_process(float delta);
};
}
}
} // namespace player
} // namespace alai
#endif

View File

@ -1,6 +1,5 @@
#include "player/states/PlayerIdle.h"
#include "player/Player.h"
#include "player/states/PlayerIdle.h"
void alai::player::PlayerIdle::_register_methods()
{

View File

@ -77,7 +77,7 @@ namespace alai
*/
void _physics_process(float delta);
};
}
}
} // namespace player
} // namespace alai
#endif

View File

@ -1,6 +1,5 @@
#include "player/states/PlayerJump.h"
#include "player/Player.h"
#include "player/states/PlayerJump.h"
#include <AudioStreamPlayer.hpp>

View File

@ -85,7 +85,7 @@ namespace alai
*/
void _physics_process(float delta);
};
}
}
} // namespace player
} // namespace alai
#endif

View File

@ -1,6 +1,5 @@
#include "player/states/PlayerMove.h"
#include "player/Player.h"
#include "player/states/PlayerMove.h"
void alai::player::PlayerMove::_register_methods()
{

View File

@ -3,9 +3,9 @@
#include "state_machine/State.h"
#include <AnimatedSprite.hpp>
#include <Godot.hpp>
#include <Input.hpp>
#include <AnimatedSprite.hpp>
namespace alai
{
@ -77,7 +77,7 @@ namespace alai
*/
void _physics_process(float delta);
};
}
}
} // namespace player
} // namespace alai
#endif

View File

@ -98,6 +98,6 @@ namespace alai
*/
virtual StateMachine *get_state_machine() final;
};
}
} // namespace alai
#endif

View File

@ -1,6 +1,5 @@
#include "state_machine/StateMachine.h"
#include "state_machine/State.h"
#include "state_machine/StateMachine.h"
void alai::StateMachine::_register_methods()
{
@ -83,7 +82,8 @@ void alai::StateMachine::setup()
{
this->call("_state_enter", get_current_state());
}
else {
else
{
WARN_PRINT("The state " + get_current_state() + " doesn't have a _state_enter method!");
}
}

View File

@ -257,6 +257,6 @@ namespace alai
return _call(method, godot::Array::make(args...));
}
};
}
} // namespace alai
#endif