Skip to content
Closed
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 modified data/sprites.dat
Binary file not shown.
24 changes: 12 additions & 12 deletions src/audio.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
#include "utils.h"
#include "preference.h"

/*** Variable globales ***/
/*** Global varibles ***/
Copy link
Owner

Choose a reason for hiding this comment

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

variables

/*************************/
extern sNewPreference Pref;
extern int Horloge;

/*** Constructeur et Destructeur ***/
/*** Contructor and Destructor ***/
Copy link
Owner

Choose a reason for hiding this comment

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

constructor / destructor

Copy link
Owner

Choose a reason for hiding this comment

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

but for me, we can delete them

/***********************************/
Audio::~Audio()
{
Expand All @@ -51,7 +51,7 @@ Audio::~Audio()
Mix_CloseAudio();
}

/*** Initialise l'Audio ***/
/*** Audio initialization***/
/**************************/
bool Audio::Init()
{
Expand All @@ -62,11 +62,11 @@ bool Audio::Init()
return false;
}

/*** Allocation de la mémoire ***/
/*** Memory allocation ***/
N = sFin;
Son = new Mix_Chunk *[sFin];

/*** Chargement des sons ***/
/*** Loading sounds ***/
strcpy(PathFile, "Sounds/clic.wav");
Utils::GetPath(PathFile);
Son[sClic] = Mix_LoadWAV(PathFile);
Expand Down Expand Up @@ -110,7 +110,7 @@ bool Audio::Init()
return true;
}

/*** Charge une music 0=menu 1,2,3,4 = game ***/
/*** Load music 0=menu 1,2,3,4 = game ***/
/**********************************************/
void Audio::LoadMusic(int Num)
{
Expand All @@ -124,12 +124,12 @@ void Audio::LoadMusic(int Num)

if (Music) {
PauseMusic(true);
Mix_HaltMusic(); // Arrete la music
Mix_HaltMusic(); // Stop music
Copy link
Owner

Choose a reason for hiding this comment

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

not really useful, the function name is already comprehensive enough

Mix_FreeMusic(Music);
Music = nullptr;
}

if (Num == 0) { // Si music du menu
if (Num == 0) { // If music from the menu
strcpy(Provi, "Sounds/menu.mod");
Utils::GetPath(Provi);
Music = Mix_LoadMUS(Provi);
Expand All @@ -142,7 +142,7 @@ void Audio::LoadMusic(int Num)
PlayMusic();
}

/*** Passe à la music de jeu suivante ***/
/*** Skip to the next game music ***/
/****************************************/
void Audio::NextMusic()
{
Expand All @@ -153,7 +153,7 @@ void Audio::NextMusic()
LoadMusic(NMus);
}

/*** Fait la lecture d'un son ***/
/*** Plays a sound ***/
/********************************/
void Audio::Play(eSon So)
{
Expand All @@ -171,7 +171,7 @@ void Audio::Play(eSon So)
Mix_PlayChannel(-1, Son[So], 0);
}

/*** Joue la music ***/
/*** Play music ***/
Copy link
Owner

Choose a reason for hiding this comment

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

same, it's just repeating the method name

/*********************/
void Audio::PlayMusic() const
{
Expand All @@ -195,7 +195,7 @@ void Audio::PauseMusic(bool Et) const
}
}

/*** Valide les Volumes ***/
/*** Validates Volumes ***/
/**************************/
void Audio::DoVolume() const
{
Expand Down
30 changes: 15 additions & 15 deletions src/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

#include <SDL2/SDL_mixer.h>

/*** Enumération des sons ***/
/*** Enumeration of sounds***/
/****************************/
enum eSon {
sClic = 0,
Expand All @@ -41,33 +41,33 @@ enum eSon {
sFin
};

/*** Définition de la classe Audio ***/
/*** Audio class define ***/
/*************************************/
class Audio
{
public:
Audio() = default;
~Audio();

/*** Fonctions ***/
bool Init(); // Initialise et charge les fichiers audio
void LoadMusic(int Num); // Charge une music, 0 = music du menu 1,2,3,4=Jeu
void NextMusic(); // Passe à la music suivante
/*** Functions ***/
bool Init(); // Initialization of audio
void LoadMusic(int Num); // Load music, 0 = music for menu 1,2,3,4=Jeu
void NextMusic(); // Skip to the next game music

void Play(eSon); // Joue un son
void PlayMusic() const; // Joue la music
void Play(eSon); // Plays a sound
void PlayMusic() const; // Plays a music

void PauseMusic(bool Etat) const; // Met ou no la music en pause
void PauseMusic(bool Etat) const; // Pause music

void DoVolume() const; // Valide les volumes audio
Mix_Music *Music { nullptr }; // Pointe sur les musics
void DoVolume() const; // Validates Volumes
Mix_Music *Music { nullptr }; // Music pointer

private:
/*** Variables ***/
int N { 0 }; // Nombre d'échantillon audio
int NMus { 0 }; // Numéro de la music en cours
int MemoHorloge { 0 }; // Mémorise l'horloge pour les clics
Mix_Chunk **Son { nullptr }; // Pointe sur les sons
int N { 0 }; // Number of audio samples
int NMus { 0 }; // Current music number
int MemoHorloge { 0 }; // Remembers the time for clicks
Mix_Chunk **Son { nullptr }; // Sound pointer
};

#endif
60 changes: 30 additions & 30 deletions src/editor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include "gamepad.h"
#include "mouse.h"

/*** Variables globales ***/
/*** Global varibles ***/
/**************************/
extern SDL_Renderer *sdlRenderer;

Expand All @@ -62,17 +62,17 @@ eMenu Editor::SDLMain(int NumNiv)

NumN = NumNiv;

Affiche(); // Charge le tableau
Affiche(); // Load the table
SDL_RenderPresent(sdlRenderer);

Horloge = SDL_GetTicks(); // Prend l'horloge
Horloge = SDL_GetTicks(); // Clock

Option = rail;

// Initialise la sourie
// Initialize the mouse
m_mouse.Init(nullptr);

// Prend les evenements
// Event listener
do {
SDL_Event event;
while (SDL_PollEvent(&event)) {
Expand Down Expand Up @@ -112,15 +112,15 @@ eMenu Editor::SDLMain(int NumNiv)
}
}

// Gère l'appuis du boutton de la sourie
// Manages mouse button presses
cx = m_mouse.Px / D_Case;
cy = m_mouse.Py / D_Case;

if (Boutton && cx < LT) {
switch (Option) {
case deco:
if (TypeB == -1) { // Si première fois que appuis sur la touche
for (i = 0; i < level.T[NumN].NDeco; i++) { // Recherche si décoration proche du clic
if (TypeB == -1) { // If it's the first time you press the key
for (i = 0; i < level.T[NumN].NDeco; i++) { // Search for decoration near the click
dx = level.T[NumN].Deco[i].x - m_mouse.Px;
dy = level.T[NumN].Deco[i].y - m_mouse.Py;
d = dx * dx + dy * dy;
Expand All @@ -135,7 +135,7 @@ eMenu Editor::SDLMain(int NumNiv)
level.T[NumN].Deco[(level.T[NumN].NDeco - 1)].y = m_mouse.Py;
TypeB = 1;
}
else { // Fait passe la selection au premier plan
else { // This brings the selection to the front
level.T[NumN].Deco[level.T[NumN].NDeco].NumSpr = level.T[NumN].Deco[TypeB].NumSpr;
level.T[NumN].Deco[level.T[NumN].NDeco].x = level.T[NumN].Deco[TypeB].x;
level.T[NumN].Deco[level.T[NumN].NDeco].y = level.T[NumN].Deco[TypeB].y;
Expand All @@ -147,7 +147,7 @@ eMenu Editor::SDLMain(int NumNiv)
NumDeco = level.T[NumN].Deco[(level.T[NumN].NDeco - 1)].NumSpr;
}
}
else { // Si pas la première fois remplace
else { // If not the first time replace
level.T[NumN].Deco[(level.T[NumN].NDeco - 1)].NumSpr = NumDeco;
level.T[NumN].Deco[(level.T[NumN].NDeco - 1)].x = m_mouse.Px;
level.T[NumN].Deco[(level.T[NumN].NDeco - 1)].y = m_mouse.Py;
Expand Down Expand Up @@ -192,7 +192,7 @@ eMenu Editor::SDLMain(int NumNiv)
}
}

// Gère les Horloges et la pose
// Manages the clocks and the installation
HorlogeAvant = Horloge;
Horloge = SDL_GetTicks();
Sleeping();
Expand All @@ -206,20 +206,20 @@ eMenu Editor::SDLMain(int NumNiv)
return mQuit;
}

/*** Charge un tableau ***/
/*** Load the table ***/
/*************************/
void Editor::Affiche() const
{
int i, x, y, m, cx, cy;
unsigned char *T;

// Prend l'adresse du niveau
// Takes the level address
T = level.T[NumN].T;

// Fabrique le fond du jeu
// Create the game background
Sprites[fond].Affiche(400, 300, 0);

// Affiche le circuit
// Draw circuit
for (i = 0; i < LT * HT; i++) {
if (T[i] >= C_Rail && T[i] < C_Fin) {
y = i / LT * D_Case + D_Case / 2;
Expand All @@ -245,36 +245,36 @@ void Editor::Affiche() const
}
}

// Affiche les décorations
// Draw decorations
for (i = 0; i < level.T[NumN].NDeco; i++) {
Sprites[deco].Affiche(level.T[NumN].Deco[i].x, level.T[NumN].Deco[i].y, level.T[NumN].Deco[i].NumSpr);
}

// Affiche numero du niveau
// Draw level number
AfficheChiffre(740, 130, NumN + 1);

// Affiche les options
for (i = 0; i < LT * HT; i++) {
switch (T[i]) {
case C_Wagon: // Si un loco
case C_Wagon: // If wagon
Sprites[wagon].Affiche(i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2, 25);
break;
case C_Allonge: // Si plus long
case C_Allonge: // If long bonus
Sprites[pluslong].Affiche(i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2, 25);
break;
case C_Reduit: // Si plus court
case C_Reduit: // If short bonus
Sprites[pluscourt].Affiche(i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2, 25);
break;
case C_Speed: // Si plus vite
case C_Speed: // If speed bonus
Sprites[vitesse].Affiche(i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2, 25);
break;
case C_Live: // Si une vie
case C_Live: // If live bonus
Sprites[vie].Affiche(i % LT * D_Case + D_Case / 2, i / LT * D_Case + D_Case / 2, 25);
break;
}
}

// Affiche le départ de la locomotive
// Display locomotive direction
switch (level.T[NumN].DepDir) {
case D_Top:
Sprites[locomotive].Affiche(level.T[NumN].DepX * D_Case + D_Case / 2, level.T[NumN].DepY * D_Case + D_Case / 2, 0);
Expand All @@ -290,7 +290,7 @@ void Editor::Affiche() const
break;
}

// Affiche l'option choisi dans le menu
// Displays the option selected in the menu
switch (Option) {
case rail:
case wagon:
Expand Down Expand Up @@ -319,7 +319,7 @@ void Editor::Affiche() const
break;
}

// Affiche le curseur
// Show cursor
if (Option != deco) {
Sprites[curseur].Affiche(m_mouse.Px, m_mouse.Py, 0);
}
Expand All @@ -328,7 +328,7 @@ void Editor::Affiche() const
}
}

/*** Prend les touches enfoncées ***/
/*** Keyboard callback ***/
/***********************************/
void Editor::PrendTouche(int Tou)
{
Expand Down Expand Up @@ -392,23 +392,23 @@ void Editor::PrendTouche(int Tou)
level.Clear(NumN);
break;
case '$':
// test si le dernier niveau est vide
// test if the last level is empty
for (j = i = 0; i < LT * HT; i++) {
j += level.T[level.N - 1].T[i];
}
if (j == 0) {
if (NumN < level.N - 1) {
level.N--; // Si vide ne le compte pas
level.N--; //If empty, don't count it.
}
}

// Sauve le niveau
// Save the level
if (level.Save() == false) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Error while saving levels");
exit(-1);
}

// test le niveau
// Test the level
Pref.Niveau = NumN;
m_game.SDLMain();
m_mouse.Init(nullptr);
Expand Down
12 changes: 6 additions & 6 deletions src/editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Mouse;
class Game;
class Gamepad;

/*** Définition de la class ***/
/*** Editor class define ***/
/******************************/
class Editor
{
Expand All @@ -40,15 +40,15 @@ class Editor
m_mouse(mouse), m_game(game), m_gamepad(gamepad) { };
~Editor() = default;

/*** Fonctions ***/
/*** Functions***/
/*****************/
eMenu SDLMain(int NumNiveau); // Boucle principale
void Affiche() const; // Charge un tableau
void PrendTouche(int Touche); // Prend les touches enfoncées
eMenu SDLMain(int NumNiveau); // Mainloop
void Affiche() const; // Load a table
void PrendTouche(int Touche); // Takes pressed keys

private:
/*** Variables ***/
int N { 0 }; // Numero du tableau à éditer
int N { 0 }; // Table number to be edited
e_Sprite Option { locomotive };
int NumDeco { 0 };
int NumN { 0 };
Expand Down
Loading