- Notifications
You must be signed in to change notification settings - Fork 8
[NEW] New ttf system#115
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
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
[NEW] New ttf system #115
Changes from all commits
f11a127e88be20df3c6ce863b7e5d7b2984bbc9f5d81f0c6755b23494ec861c919ea48a32856dFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -39,6 +39,7 @@ protected String[] getLibraries() { | ||
| return new String[] { | ||
| "SDL2", | ||
| "SDL2_mixer", | ||
| "SDL2_ttf", | ||
| "main" | ||
| }; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); | ||
| 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; | ||
| } | ||
| @@ -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); | ||
Owner There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
| 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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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" | ||
| @@ -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(); | ||
Owner There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should probably call | ||
| // Close the program properly when quitting | ||
| atexit(SDL_Quit); | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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:
TextAlignmentwith 2 possible valuesAlignLeftandAlignCenter. IfAlignLeftis set we don't do anything, ifAlignCenteris set we compute the shift inside thePrintTextmethod