Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y cmake make
sudo apt-get install -y libsdl2-dev libsdl2-mixer-dev
sudo apt-get install -y libsdl2-dev libsdl2-mixer-dev libsdl2-ttf-dev

- name: Install clang
run: |
Expand Down
Binary file added Assets/Fonts/comic.ttf
Binary file not shown.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ option(USE_CONAN
if(USE_CONAN)
find_package(SDL2 REQUIRED CONFIG)
find_package(SDL2_mixer REQUIRED CONFIG)
find_package(SDL2_ttf REQUIRED CONFIG)
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(SDL2 REQUIRED sdl2 SDL2_mixer)
pkg_check_modules(SDL2 REQUIRED sdl2 SDL2_mixer SDL2_ttf)
endif()

set(CMAKE_CXX_STANDARD 11)
Expand Down Expand Up @@ -80,7 +81,7 @@ if(LINUX)
endif()

if(USE_CONAN)
target_link_libraries(${LIRI_EXECUTABLE_NAME} PRIVATE SDL2::SDL2 SDL2_mixer::SDL2_mixer)
target_link_libraries(${LIRI_EXECUTABLE_NAME} PRIVATE SDL2::SDL2 SDL2_mixer::SDL2_mixer sdl_ttf::sdl_ttf)
else()
target_include_directories(${LIRI_EXECUTABLE_NAME} PUBLIC ${SDL2_INCLUDE_DIRS})
target_link_libraries(${LIRI_EXECUTABLE_NAME} PRIVATE ${SDL2_LINK_LIBRARIES})
Expand Down
1 change: 1 addition & 0 deletions android/app/src/main/java/org/liri/app/LiRi.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ protected String[] getLibraries() {
return new String[] {
"SDL2",
"SDL2_mixer",
"SDL2_ttf",
"main"
};
}
Expand Down
3 changes: 2 additions & 1 deletion android/app/src/main/jni/src/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ SDL_PATH := ../SDL2

LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/ \
$(LOCAL_PATH)/../SDL2_mixer \
$(LOCAL_PATH)/../SDL2_ttf \
$(LOCAL_PATH)/../simpleini \

# Add your application source files here...
Expand All @@ -25,7 +26,7 @@ LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.c \
../../../../../../src/sprite.cc \
../../../../../../src/utils.cc \

LOCAL_SHARED_LIBRARIES := SDL2 SDL2_mixer
LOCAL_SHARED_LIBRARIES := SDL2 SDL2_mixer SDL2_ttf

LOCAL_LDLIBS := -lGLESv1_CM -lGLESv2 -llog

Expand Down
2 changes: 1 addition & 1 deletion android/src/org/libsdl/app/SDLActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class SDLActivity extends Activity {
//System.loadLibrary("SDL2_image");
System.loadLibrary("SDL2_mixer");
//System.loadLibrary("SDL2_net");
//System.loadLibrary("SDL2_ttf");
System.loadLibrary("SDL2_ttf");
System.loadLibrary("main");
}

Expand Down
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

class LiRi(ConanFile):
settings = "os", "compiler", "build_type", "arch"
requires = "sdl/2.32.10", "sdl_mixer/2.8.1", "openssl/1.1.1w"
requires = "sdl/2.32.10", "sdl_mixer/2.8.1", "sdl_ttf/2.24.0", "openssl/1.1.1w"
tool_requires = "cmake/4.2.1"

def layout(self):
Expand Down
2 changes: 1 addition & 1 deletion src/editor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ void Editor::Draw() const
}

// Displays the level number
DrawNumber(740, 130, NumN + 1);
// DrawNumber(740, 130, NumN + 1);

// Display possible sprites
for (i = 0; i < LT * HT; i++) {
Expand Down
21 changes: 15 additions & 6 deletions src/game.cc
Original file line number Diff line number Diff line change
Expand Up @@ -359,12 +359,15 @@ bool Game::DrawLevel(int LevelN)
#endif

// Displays texts for selected language
DrawText(740, 110, T_level, Sprites[fgame].Image[0]);
DrawText(740, 180, T_score, Sprites[fgame].Image[0]);
DrawText(740, 260, T_options, Sprites[fgame].Image[0]);
DrawText(740, 340, T_lives, Sprites[fgame].Image[0]);
m_screen.ChangeFontSize(20);
m_screen.ChangeFontColor(255, 255, 0);
m_screen.PrintText("Level", 740 - m_screen.TextLength("Level") / 2, 110);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

we should avoid to have to repeat the text in all of the PrintText calls. I would suggest to add a enum parameter to the function: TextAlignment with 2 possible values AlignLeft and AlignCenter. If AlignLeft is set we don't do anything, if AlignCenter is set we compute the shift inside the PrintText method

m_screen.PrintText("Score", 740 - m_screen.TextLength("Score") / 2, 180);
m_screen.PrintText("Options", 740 - m_screen.TextLength("Options") / 2, 260);
m_screen.PrintText("Lives", 740 - m_screen.TextLength("Lives") / 2, 340);
m_screen.ChangeFontColor(255, 255, 255);

DrawNumber(740, 140, Pref.Level + 1, Sprites[fgame].Image[0]);
m_screen.PrintText(std::to_string(Pref.Level + 1), 740 - m_screen.TextLength(std::to_string(Pref.Level + 1)) / 2, 140);

return true;
}
Expand Down Expand Up @@ -548,7 +551,13 @@ void Game::DisplayScreen()

// When paused, asks for a key press
if (Pause) {
m_screen.PrintText(T_press_any_key, LT * D_Case / 2, 300);
m_screen.ChangeFontSize(60);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I like this shadowing. I think it can potentially be used in other places so it would be better to have a method PrintShadowedText in Screen that will call internally twice the PrintText method: one for the black shadow text and one for the text with the wanted color

m_screen.ChangeFontColor(0, 0, 0);
m_screen.PrintText("Press any key", 341 - m_screen.TextLength("Press any key") / 2, 271);
m_screen.ChangeFontColor(255, 255, 0);
m_screen.PrintText("Press any key", 340 - m_screen.TextLength("Press any key") / 2, 270);
m_screen.ChangeFontColor(255, 255, 255);
m_screen.ChangeFontSize(14);
}

// Prints a dashboard
Expand Down
2 changes: 2 additions & 0 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <SDL2/SDL_video.h> // for SDL_CreateWindow, SDL_DestroyWindow
#include <SDL2/SDL.h>
#include <SDL2/SDL_mixer.h>
#include <SDL2/SDL_ttf.h>

#include "config.h"
#include "preference.h"
Expand Down Expand Up @@ -97,6 +98,7 @@ int main(int narg, char *argv[])
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to initialize SDL: %s", SDL_GetError());
exit(-1);
}
TTF_Init();
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

we should probably call TTF_Quit at the end but for now it segfaults (probably because we call it before the destructor of Screen is called)

// Close the program properly when quitting
atexit(SDL_Quit);

Expand Down
Loading
Loading