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
Binary file added Assets/Fonts/comic.ttf
Binary file not shown.
File renamed without changes.
File renamed without changes.
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 SDL2_ttf::SDL2_ttf)
else()
target_include_directories(${LIRI_EXECUTABLE_NAME} PUBLIC ${SDL2_INCLUDE_DIRS})
target_link_libraries(${LIRI_EXECUTABLE_NAME} PRIVATE ${SDL2_LINK_LIBRARIES})
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Copyright (c) 2006
Dominique Roux-Serret: design & programming & graphics & website.
Maf464: musics

Copyright (c) 2006 (for "menu.mod", "jeu1.xm", "jeu2.xm") MAF464 (email charcosset.b@free.fr; website http://maf464.free.fr). This music licensed under GPL license. See COPYING for details
Copyright (c) 2006 (for "menu.mod", "ingame1.xm", "ingame2.xm") MAF464 (email charcosset.b@free.fr; website http://maf464.free.fr). This music licensed under GPL license. See COPYING for details

[<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png"
alt="Get it on F-Droid"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file removed data/language.Ar
Binary file not shown.
Binary file removed data/language.Br
Binary file not shown.
Binary file removed data/language.Cn
Binary file not shown.
Binary file removed data/language.De
Binary file not shown.
Binary file removed data/language.Du
Binary file not shown.
Binary file removed data/language.En
Binary file not shown.
Binary file removed data/language.Eo
Binary file not shown.
Binary file removed data/language.Es
Binary file not shown.
Binary file removed data/language.Fr
Binary file not shown.
Binary file removed data/language.Hu
Binary file not shown.
Binary file removed data/language.It
Binary file not shown.
Binary file removed data/language.Jp
Binary file not shown.
Binary file removed data/language.Ko
Binary file not shown.
Binary file removed data/language.Pl
Binary file not shown.
Binary file removed data/language.Po
Binary file not shown.
Binary file removed data/language.Ru
Binary file not shown.
Binary file removed data/language.Se
Binary file not shown.
Binary file removed data/language.Sl
Binary file not shown.
Binary file removed data/language.Tu
Binary file not shown.
Binary file removed data/language.dat
Binary file not shown.
2,207 changes: 2,207 additions & 0 deletions gamecontrollerdb.txt

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/audio.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ bool Audio::Init()
Utils::GetPath(PathFile);
Sound[sExpand] = Mix_LoadWAV(PathFile);

strcpy(PathFile, "Sounds/car.wav");
strcpy(PathFile, "Sounds/wagon.wav");
Utils::GetPath(PathFile);
Sound[sCar] = Mix_LoadWAV(PathFile);
Sound[sWagon] = Mix_LoadWAV(PathFile);

strcpy(PathFile, "Sounds/shrink.wav");
Utils::GetPath(PathFile);
Expand All @@ -108,7 +108,7 @@ bool Audio::Init()
/*********************************************************************/
void Audio::LoadMusic(int Num)
{
char Provi[512] = "Sounds/jeu1.xm";
char Provi[512] = "Sounds/ingame1.xm";

if (!N) {
return;
Expand All @@ -129,7 +129,7 @@ void Audio::LoadMusic(int Num)
Music = Mix_LoadMUS(Provi);
}
else {
Provi[10] = (char)(Num) + '0';
Provi[13] = (char)(Num) + '0';
Utils::GetPath(Provi);
Music = Mix_LoadMUS(Provi);
}
Expand Down
2 changes: 1 addition & 1 deletion src/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ enum eSound {
sEnd,
sLose,
sExpand,
sCar,
sWagon,
sShrink,
sLive,
sSize
Expand Down
15 changes: 6 additions & 9 deletions src/editor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ eMenu Editor::SDLMain(int LevelNumber)
}
m_level.T[NumN].T[cy * LT + cx] = TypeB;
break;
case car:
m_level.T[NumN].T[cy * LT + cx] = C_Car;
case wagon:
m_level.T[NumN].T[cy * LT + cx] = C_Wagon;
break;
case expander:
m_level.T[NumN].T[cy * LT + cx] = C_Expand;
Expand Down Expand Up @@ -243,14 +243,11 @@ void Editor::Draw() const
Sprites[deco].Draw(m_level.T[NumN].Deco[i].x, m_level.T[NumN].Deco[i].y, m_level.T[NumN].Deco[i].NumSpr);
}

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

// Display possible sprites
for (i = 0; i < LT * HT; i++) {
switch (T[i]) {
case C_Car: // Car sprite
Sprites[car].Draw(i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2, 25);
case C_Wagon: // Wagon sprite
Sprites[wagon].Draw(i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2, 25);
break;
case C_Expand: // Expand sprite
Sprites[expander].Draw(i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2, 25);
Expand Down Expand Up @@ -286,7 +283,7 @@ void Editor::Draw() const
// Displays selected option in the menu
switch (Option) {
case rail:
case car:
case wagon:
case expander:
case shrinker:
case speed:
Expand Down Expand Up @@ -411,7 +408,7 @@ void Editor::GetKeyPress(int Key)
Option = rail;
break;
case 'z':
Option = car;
Option = wagon;
break;
case 'e':
Option = expander;
Expand Down
25 changes: 17 additions & 8 deletions src/game.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

#define DCHILDREN
#include <SDL2/SDL_events.h> // for SDL_PollEvent, SDL_PRESSED, SDL_Event
#include <SDL2/SDL_keycode.h> // for SDLK_DOWN, SDLK_LEFT, SDLK_RIGHT, SDLK_UP
#include <SDL2/SDL_render.h> // for SDL_RenderPresent, SDL_RenderClear
Expand Down Expand Up @@ -359,12 +360,14 @@ 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.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("Config", 740-m_screen.TextLength("Config")/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 @@ -528,8 +531,8 @@ void Game::DisplayScreen()
// Display options
for (i = 0; i < LT * HT; i++) {
switch (T[i]) {
case C_Car: // if car sprite
m_screen.PrintSprite(car, (GameClock * 40 / 1000 + i * 7) % 50, i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2);
case C_Wagon: // if wagon sprite
m_screen.PrintSprite(wagon, (GameClock * 40 / 1000 + i * 7) % 50, i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2);
break;
case C_Expand: // if expander sprite
m_screen.PrintSprite(expander, (GameClock * 40 / 1000 + i * 7) % 50, i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2);
Expand All @@ -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);
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: 1 addition & 1 deletion src/level.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ bool Level::Load()
unsigned char *Buf;
long L, P = 2;
int i, j;
char NameLevelFile[512] = "levels.dat";
char NameLevelFile[512] = "Assets/Levels.dat";

Utils::GetPath(NameLevelFile);
L = Utils::LoadFile(NameLevelFile, Buf);
Expand Down
20 changes: 10 additions & 10 deletions src/loco.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ void Loco::Display(Screen &screen)
int cdx, cdy, cfx = 0, cfy = 0; // Attachment point for cables
float lv;

// Display all wagon/(cars)
// Display all wagon
for (i = 0; i < NWagon; i++) {
// Search wagon points
switch (Wagon[i]) {
Expand All @@ -135,7 +135,7 @@ void Loco::Display(Screen &screen)
lv = 20;
}

// Calculate cars point's position
// Calculate wagons point's position
FindPoint(D - p1, x1, y1);
FindPoint(D - p2, x2, y2);

Expand Down Expand Up @@ -186,7 +186,7 @@ void Loco::Display(Screen &screen)
// Displays the cable
screen.PrintCable(cdx, cdy, cfx, cfy);
}
// Calculate the attachment point for the next Wagon/car
// Calculate the attachment point for the next Wagon
cfx = x1 - (int)(sin(ar + M_PI) * lv);
cfy = y1 - (int)(cos(ar + M_PI) * lv);

Expand Down Expand Up @@ -222,7 +222,7 @@ void Loco::Display(Screen &screen)
}
}

// Add gap between the wagons/cars
// Add gap between the wagons
ltrain += Pref.WagonGap;
}
}
Expand All @@ -240,15 +240,15 @@ void Loco::TestTile(float Dist, long GameDuration, int *Level)
if (D <= DMoy && D + Dist >= DMoy) {
// Check if on an item
switch (Level[T[LocoPos].P]) {
case C_Car: // New wagon/car
m_audio.Play(sCar);
case C_Wagon: // New wagon
m_audio.Play(sWagon);
Level[T[LocoPos].P] = 1; // Remove item from level
Pref.Score += 5;
AddLoco(); // Add a random wagon

Win = true; // Check if it was the last wagon for win condition
for (i = 0; i < LT * HT; i++) {
if (Level[i] == C_Car) {
if (Level[i] == C_Wagon) {
Win = false;
}
}
Expand Down Expand Up @@ -291,7 +291,7 @@ void Loco::TestTile(float Dist, long GameDuration, int *Level)
break;
}

// Collision check with another wagon/car
// Collision check with another wagon
for (i = 1; i < NWagon; i++) {
vx = (float)(PosWagon[i].dx - PosWagon[0].dx);
vy = (float)(PosWagon[i].dy - PosWagon[0].dy);
Expand Down Expand Up @@ -663,9 +663,9 @@ void Loco::FindPoint(float Dist, int &x, int &y)
/*********************************************/
void Loco::AddLoco()
{
Wagon[NWagon] = (e_Sprite)(rand() % (car - logs_wagon) + logs_wagon);
Wagon[NWagon] = (e_Sprite)(rand() % (wagon - logs_wagon) + logs_wagon);
if (Wagon[NWagon] == Wagon[NWagon - 1]) { // Avoids adding the same sprite twice
if (Wagon[NWagon] + 1 == car) {
if (Wagon[NWagon] + 1 == wagon) {
Wagon[NWagon] = logs_wagon;
}
else {
Expand Down
2 changes: 1 addition & 1 deletion src/loco.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class Loco
void MoveForward(int Duration, long GameDuration, int *Key, int *Level); // Makes locomotive move forward for Duration in ms
void FindArrow(int *Level, int *Key); // Search the position of the next intersection
bool TestDir(int FDir, int *Level); // Check if a direction/turn is possible
void AddLoco(); // Adds a random car to the locomotive
void AddLoco(); // Adds a random wagon to the locomotive

inline bool Go(int FutureDirection); // Move the locomotive
inline void FindPoint(float Dist, int &x, int &y); // Searching a point on the map
Expand Down
10 changes: 3 additions & 7 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();
// Close the program properly when quitting
atexit(SDL_Quit);

Expand Down Expand Up @@ -142,20 +144,14 @@ int main(int narg, char *argv[])
previousTime = currentTime = SDL_GetTicks();
srand(SDL_GetTicks());

// ask locale if first run
if (Pref.Language == -1) {
RetMenu = MainMenu.SDLMain_Language();
LoadLanguage();
}

// menu switch
do {
switch (RetMenu) {
case mMenu:
RetM = MainMenu.SDLMain();
break;
case mLanguage:
RetM = MainMenu.SDLMain_Language();
//RetM = MainMenu.SDLMain_Language();
break;
case mOption:
RetM = MainMenu.SDLMain_Options();
Expand Down
Loading