Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring + rework of saving process #32

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

ohol-vitaliy
Copy link

What was done

  • overhauled saving data to files (simplified, changed it to more-or-less "C/C++ way")
  • fixed: the game does not save progress after the first save
  • fixed: saving high scores
  • overhauled controls logic (simplified, per key setting instead of predefined key sets)
  • added fullscreen and proper scaling for different aspect ratios
  • added command line options
  • renamed portions of a code to something meaningful

@ohol-vitaliy ohol-vitaliy marked this pull request as ready for review November 17, 2024 16:27
@mxlgv
Copy link
Collaborator

mxlgv commented Nov 17, 2024

@ohol-vitaliy Thanks for your contribution. I request that you use git rebase to remove the garbage commits related to README edits.

project(gravity_defied_cpp C CXX)
set(CMAKE_VERBOSE_MAKEFILE TRUE)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to force this option. You can pass it via -D on the command line.

@@ -13,14 +14,18 @@ if(WIN32)
endif()

find_package(PkgConfig REQUIRED)
find_package(OpenSSL REQUIRED)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenSSL, just for the sake of md5 hash, is redundant. Can we use a lighter implementation or another algorithm like crc32. Are there any analogs in the standard c++ library?

@@ -77,7 +82,7 @@ endif()
add_executable(GravityDefied ${SOURCES})

target_compile_features(GravityDefied PRIVATE cxx_std_17)
target_compile_options(GravityDefied PRIVATE -Wall -Wextra)
target_compile_options(GravityDefied PRIVATE -Wall -Wextra -fsigned-char)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this option for?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is it different from what it was?

{
field_232 = var1;
}
// void GameCanvas::method_163(int var1)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this commented? Please leave a comment why this can't be removed.

int menuOffsetY;
int menuSpacing;
int menuOffsetX;
// int itemsToShowWindowStart;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this commented? Please leave a comment why this can't be removed.

@mxlgv
Copy link
Collaborator

mxlgv commented Nov 17, 2024

@ohol-vitaliy Please check everywhere in your code for extra/missing spaces/new lines.And also justify the commented out pieces of code that should not be removed.

{
int var1;
for (var1 = 0; var1 < 10; ++var1) {
activeKeys[var1] = false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this no longer required? std::vector<bool> activeKeys = std::vector<bool>(10) still exists.

if (field_95 > field_106) {
++field_105;
++field_106;
if (static_cast<int>(menuItems.size()) <= numberOfItemsToFit) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems static_cast is redundant. I think when comparing, there will be an indirect type conversion. Perhaps numberOfItemsToFit should be size_t. It seems that there is similar code in this PR.

loadedTrack = track;

const MRGLoader::LevelTracks l = trackHeaders.at(level);
const int tracksCount = static_cast<int>(l.tracks.size());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sizet_t ? Remove static_cast?

#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_ttf.h>
#include <stdexcept>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Group headers (standard, sdl, internal)

@@ -3,8 +3,10 @@
#include <string>
#include <SDL2/SDL.h>
#include <SDL2/SDL_ttf.h>
#include <stdexcept>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Group headers


va_list args;
va_start(args, szFormat);
vprintf(szFormat, args);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend disabling buffering for stdout. If the application crashes, we may not see the entire log.

@@ -1,34 +0,0 @@
#include "test_rms.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't the test need to be rewritten?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants