Le jeu du Simon pour la META

Creations

jicehel

NEW 5 years ago

No the both exist: lang_joueur is the const string for 'player' is english, french, spanish and german and lang_jouer is the const string for the rest of the sentence after the number of the player to say that it's his turn to play.

I could do thing another way but i would understand this error because it's a thing i don't know with c (as alot thing atm in this language but i'll try to learn quickly ;) )

Chimrod

5 years ago

You named it lang_tour_jouer not lang_jouer !

Chimrod

NEW 5 years ago

jicehel jicehel

You named it lang_tour_jouer not lang_jouer !

jicehel

NEW 5 years ago

Yes, that's right, it's explain the second error. I'll correct it this night but i don't think that it's the main problem where is an error too in the first one (ChaineJoueur[12]). I have tried first to not limit it (Chainejoueur[]) but it seems not like it.

Chimrod

5 years ago

Je viens de voir à ton premier message que tu parlais français ! 


Je n'ai pas l'environnement Arduino ici pour tester, mais quelque chose me parait bizzare sur ta ligne :

const char ChaineJoueur[12] = gb.language.get(lang_joueur); 

Tu définis ici la variable ChaineJoueur comme constante (ce qui permet certaines optimisations mémoire), mais elle n'est pas constante puisqu'il s'agit du résultat d'une évaluation. Je pense qu'après const char ChaineJoueur[12]le compilateur s'attend à voir = { … } (la définition standard d'un tableau), d'où l'erreur donnée au moment de la compilation.

Si l'hypothèse est juste, il te suffit de retirer le const pour faire compiler le code !

Chimrod

NEW 5 years ago

jicehel jicehel

Je viens de voir à ton premier message que tu parlais français ! 


Je n'ai pas l'environnement Arduino ici pour tester, mais quelque chose me parait bizzare sur ta ligne :

const char ChaineJoueur[12] = gb.language.get(lang_joueur); 

Tu définis ici la variable ChaineJoueur comme constante (ce qui permet certaines optimisations mémoire), mais elle n'est pas constante puisqu'il s'agit du résultat d'une évaluation. Je pense qu'après const char ChaineJoueur[12]le compilateur s'attend à voir = { … } (la définition standard d'un tableau), d'où l'erreur donnée au moment de la compilation.

Si l'hypothèse est juste, il te suffit de retirer le const pour faire compiler le code !

jicehel

NEW 5 years ago

Merci Chimrod, j'essayerais ce soir. En fait je m'étais appuyé sur le tuto: https://gamebuino.com/creations/language

OTHER USES
You can uses these MultiLang variables basically anywhere you'd expect within the library - when printing to the screen, and when using the GUI functions. Should you want to call something that requires a string and doesn't support MultiLang, you can still use gb.language.get like the follows:

const MultiLang lang_fox[] = { { LANG_EN, "Fox" }, { LANG_FR, "Renard" }, { LANG_DE, "Fuchs" }, };
const char* fox = gb.language.get(lang_fox);

And then you can use the variable fox like it is just a normal string and pass it on to other functions etc.

Ca parait simple en lisant le tuto jusqu'à ce que l'on compile et que l'on ait des erreurs...  ;) (D'autant plus quand on oublie des bouts de noms dans les constantes..). A la base, j'étais parti là dessus car après j'avais compris qu'en passant par le pointeur, je pouvais utiliser la chaîne comme n'importe qu'elle autre chaîne, mais voilà, c'est là que je me suis rendu compte de mes lacunes  ;)   Ça m'arrange de pouvoir de l'expliquer en français: comme tu as pu le lire, mon niveau d'anglais est assez approximatif. Je maîtrise un peu mieux les nuances en français  :D


Je ne peux pas tester non plus ici. Si quelqu'un peu faire le test et vérifier que l'on obtient bien le message:

En français: "Joueur  1, c'est ton tour de jouer"

ou en anglais:  "Player 1, it's your turn to play"


Bon j'espère que malgré tout  ma méconnaissance de l'usage du c aidera certains débutant comme moi à utiliser ces outils qui permettent quand même simplement de gérer les messages en fonction de la langue de l'utilisateur et si vous parlez une langue et que vous souhaitez rajouter la traduction des messages pour celle ci (ou la corriger), n'hésitez pas... 

Si je n'arrive pas à faire marcher ce message comme ça ce soir, je ferais l'autre méthode qui est plus simple à priori au moins dans mon cas mais ça voudrait dire que je garderais un truc incompris, ce que je n'aime pas trop dans le principe (Je m'en remettrais quand même, rassurez-vous  ;) )

Gamebuino_Meta::LangCode langCode = gb.language.getCurrentLang();
if (langCode == LANG_EN) { // our language is English
} else if (langCode == LANG_DE) { // our language is German
}


Sorunome

NEW 5 years ago

Disclaimer: I haven't read all the french text.

That being said, you seem to want to do something like "Hello <name>, how are you?" and thus decided to split the string into two parts. That is easily possible when printing to the screen:

const MultiLang lang_part_1[] = {
    {LANG_EN, "Hello "},
    {LANG_DE, "Hallo "},
};
const MultiLang lang_part_2[] = {
    {LANG_EN, ", how are you?"},
    {LANG_DE, ", wie geht es Ihnen?"},
};

// print the stuff
gb.display.print(lang_part1);
gb.display.print(name); // name of the person
gb.display.print(lang_part2);

You can easily make this a lot simpler by using printf in the following way:

const MultiLang lang_hi[] = {
    {LANG_EN, "Hello %s, how are you?"},
    {LANG_DE, "Hallo %s, wie geht es Ihnen?"},
};

// now pring it!
gb.display.printf(lang_hi, name); // have the name of the person as second argument, it will be inserted where the %s is

Now, it seems you wanted to pass it to gb.gui.popup which, in itself, doesn't have printf. However, you can use it externally to create the string:

const MultiLang lang_hi[] = {
    {LANG_EN, "Hello %s, how are you?"},
    {LANG_DE, "Hallo %s, wie geht es Ihnen?"},
};

char popupText[40]; // have this in the global scope, else you'll get errors, as popup needs to reference this some time later

// now inside a function
sprintf(popupText, gb.language.get(lang_hi), name);
gb.gui.popup(popupText, 50); // 2 seconds long popup


For numbers you can use %d etc. you can see alist of what printf can do over here: www.cplusplus.com/reference/cstdio/printf/


I hope i could help a bit, if you have any more questions, just ask! ^.^

jicehel

NEW 5 years ago

Extra, it seems so easy when you explain it Sorunome... that sometimes i think i could find it alone until i try  ;)  

But i will make this program and make some progress and in 2 ou 3 programs i'll ask you less questions (So, i hope it anyway... :D)

I'll try that tonight. Thanks both and i hope to be able to make an update of the source and the bin tonight to let players be able to play at 4 max as in original game.

jicehel

NEW 5 years ago

I had errors but i have search and i found my errors and now multiplayer mode, menu and messages works fine (even it's a little bad that popup don't restore background by himself when it disappear). Next time i'll let a little band at bottom.

But you can download bin now to play up to 4 players. 

I have test english and french language. I have seen deutsch in language selection but not spanish. So i don't know if you'll add more possible language. As you can't add all language, you maybe have to think to a system of optional languages  to add (italian, spanish, japaneese, chineese, ...) 

So now i'll make a break on this game (except if you have some ideas of code optimisation, corrections, bugs, ....) and i'll add later a high score storage with a high score screen.

Have fun with this game and many thanks for simonbuino author as i have use his method to restart my code when my first try wasn't making what i would and to Sorunome for all the informations given.

Sorunome

5 years ago

You should probably update your loader.bin - there is spanish there!

Sorunome

NEW 5 years ago

jicehel jicehel

You should probably update your loader.bin - there is spanish there!

jicehel

NEW 5 years ago

Done, dutch is not implemented yet, so if someone can translate the message in dutch, i'll add them into the game.

I don't know if you will do specific bootloader.bin after to add more languages as italien, polish, chineese, japaneese but if you add them and if someone translate the messages i'll add them too.

If someone see bugs, possible things to adjust or add, please tell. ATM, i have just in mind to had a highscore screen later.

If you make a tuto to make a anim for animation screen like in the start menu of your game Sorunome, i'll probably add one too to make the first menu nicer. I'll maybe change pictures too to let a little space at bottom for popups as i don't like how they disapear (they don't restore the background)

Sorunome

5 years ago

If you re-drew the entire screen each frame it would play nice with the popup. OFC you'll have to check if you have enough CPU power available.

As for animations, i did touch that in the images tutorial, including example with the cat from cats&coins

Sorunome

NEW 5 years ago

jicehel jicehel

If you re-drew the entire screen each frame it would play nice with the popup. OFC you'll have to check if you have enough CPU power available.

As for animations, i did touch that in the images tutorial, including example with the cat from cats&coins

jicehel

NEW 5 years ago

OK, thanks , I'll have a look later on that. If there is no bug, i'll let this game a few to have comment asw and i'll take back the program i had start: parachutes to complete it and  have another experience of making a game. (And because i want complete it before making a shoot them up using the program created by others to adpat them and understand the mechanicals).

jicehel

NEW 5 years ago

Version updated with score save

BatterieMeta

NEW 5 years ago

ce serait parfait si le pixel art du simon était légèrement plus revisité en simple pour la META.


jicehel

NEW 5 years ago

OK, je vais en faire une autre version plus simple. Ca va me permettre de me remettre tranquillement à la programmation.