// main global script file
// D'abord on crée des fonctions qui vont nous permettre
// de traiter les tableaux comme des piles, c'est-à-dire ajouter des entrées
// au fur et à mesure, de façon dynamique. Voir le sujet correspondant.
int[] IntPile(int tableau[], int taille, int valeur) {
if (taille < 0) taille = 0;
int tmp[] = new int[taille+1];
int i = 0;
while (i < taille) {
tmp[i] = tableau[i];
i++;
}
tmp[i] = valeur;
return tmp;
}
String[] StringPile(String tableau[], int taille, String valeur) {
if (taille < 0) taille = 0;
String tmp[] = new String[taille+1];
int i = 0;
while (i < taille) {
tmp[i] = tableau[i];
i++;
}
tmp[i] = valeur;
return tmp;
}
// Les variables globales dont on aura besoin
// Questions[] va contenir la liste des questions
// ReponsesX[] vont contenir les listes des réponses correspondant aux questions dans Questions[]
String Questions[], ReponsesA[], ReponsesB[], ReponsesC[], ReponsesD[];
// BonnesRespones[] va contenir les listes des bonnes réponses (1,2,3,4 pour A,B,C,D)
// Seq[] va contenir la liste des ID des questions, qu'on va mélanger aléatoirement
int BonnesReponses[], Seq[];
// QuestionEnCours permet de parcourir Seq[] pour récupérer la question et les réponses en cours
// Total représente le nombre total de questions
int QuestionEnCours = -1, Total;
// Fonction qui charge chaque ligne de chaque groupe de 6 lignes dans la variable correspondante
// chargeFichierQuizz("nomdefichier.txt") retourne true si tout s'est bien passé, false sinon
bool chargeFichierQuizz(String nomfichier) {
// Si le fichier n'existe pas, erreur
if (!File.Exists(nomfichier)) return false;
// On ouvre le fichier en lecture
File* fquizz = File.Open(nomfichier, eFileRead);
// On initialise Total à 0
Total = 0;
String stmp; // Pour AsInt, voir plus bas
// On parcourt le fichier dans fquizz
while (!fquizz.EOF) {
// On ajoute la première ligne qu'on lit à la pile des questions
Questions = StringPile(Questions, Total, fquizz.ReadRawLineBack());
// On ajoute les 4 lignes suivantes aux piles des réponses respectives
ReponsesA = StringPile(ReponsesA, Total, fquizz.ReadRawLineBack());
ReponsesB = StringPile(ReponsesB, Total, fquizz.ReadRawLineBack());
ReponsesC = StringPile(ReponsesC, Total, fquizz.ReadRawLineBack());
ReponsesD = StringPile(ReponsesD, Total, fquizz.ReadRawLineBack());
// On récupère la 6ème ligne
stmp = fquizz.ReadRawLineBack(); // La propriété AsInt ne peut pas directement s'accoler à ReadRawLineBack
// On vérifie que c'est bien un nombre entre 1 et 4
if (stmp.AsInt < 1 || stmp.AsInt > 4 || fquizz.Error) {
// Si on n'a pas de nombre ou s'il y a eu une erreur de lecture auparavant,
// on ferme le fichier et on retourne FALSE
fquizz.Close();
return false;
}
// Si on a bien affaire à un nombre entre 1 et 4, on l'ajoute à la pile des bonnes réponses
BonnesReponses = IntPile(BonnesReponses, Total, stmp.AsInt);
// On indique qu'on vient d'ajouter une question en augmentant Total
Total++;
}
// On a finit de parcourir le fichier, on le ferme
fquizz.Close();
// On remplit Seq avec les ID des questions
Seq = new int[Total];
int i = 0;
while (i < Total) {
Seq[i] = i;
i++;
}
// Puis on mélange les ID dans Seq avec l'algorithme de Fisher-Yates
int j = 0, x = 0;
while (i > 0) {
i--;
j = Random(i-1);
x = Seq[i];
Seq[i] = Seq[j];
Seq[j] = x;
}
// Tout s'est bien passé, on retourne TRUE
return true;
}
// A function that initializes a bunch of stuff.
function initialize_control_panel() {
// Centre the control panel
gPanel.Centre();
// Centre the Restart dialog as well
gRestartYN.Centre();
if (!IsSpeechVoxAvailable()) {
// If there is no speech-vox file, and therefore no speech,
// disable all the controls related with speech.
lblVoice.Visible = false;
btnVoice.Visible = false;
sldVoice.Visible = false;
}
else {
// If there *is*, then set it to voice and text. It's best to use
// both whenever possible, for the player's sake.
SetVoiceMode(eSpeechVoiceAndText);
// And reflect this in the control panel.
btnVoice.Text = "Voice and Text";
}
if (!System.SupportsGammaControl) {
// If we can't change the gamma settings, disable the relevant options.
sldGamma.Visible = false;
lblGamma.Visible = false;
}
//And now, set all the defaults
System.Volume = 100;
sldAudio.Value = System.Volume;
SetGameSpeed(40);
sldSpeed.Value = 40;
if (IsSpeechVoxAvailable()) {
SetVoiceMode(eSpeechVoiceAndText);
btnVoice.Text = "Voice and Text";
sldVoice.Value = 255;
SetSpeechVolume(255);
}
if (System.SupportsGammaControl) {
System.Gamma = 100;
sldGamma.Value = 100;
}
}
// Called when the game starts, before the first room is loaded
function game_start() {
// Put the code all in a function and then just call the function.
// It saves cluttering up places like game_start.
initialize_control_panel();
// Use the KeyboardMovement module to, per default, replicate the standard
// keyboard movement of most Sierra games. See KeyboardMovement.txt for more info
KeyboardMovement.SetMode(eKeyboardMovement_Tapping);
if (player.Room==2) {
Total = chargeFichierQuizz("SG1.dat");
}
if (player.Room==3) {
Total = chargeFichierQuizz("SGA.dat");
}
if (player.Room==4) {
Total = chargeFichierQuizz("SGU.dat");
}
}
// Une fonction qui permet de passer à la question suivante
bool questionSuivante() {
// Si on a déjà affiché la dernière question, on retourne FALSE
if (QuestionEnCours+1 == Total) return false;
// On passe à la question suivante
QuestionEnCours++;
// On affiche la question dont l'ID est le QuestionEnCours-ième élément de Seq
question.Text=Questions[Seq[QuestionEnCours]];//question
// Puis les réponses
BtnRep1.Text=ReponsesA[Seq[QuestionEnCours]];//reponse1
BtnRep2.Text=ReponsesB[Seq[QuestionEnCours]];//reponse2
BtnRep3.Text=ReponsesC[Seq[QuestionEnCours]];//reponse3 bonne
BtnRep4.Text=ReponsesD[Seq[QuestionEnCours]];//reponse4
// On stocke dans "bonne" l'ID de la bonne réponse (= 1, 2, 3 ou 4)
bonne=BonnesReponses[Seq[QuestionEnCours]]; //N° de la bonne reponse
// On retourne TRUE
return true;
}
function repeatedly_execute() {
// Put here anything you want to happen every game cycle, even when
// the game is paused. This will not run when the game is blocked
// inside a command like a blocking Walk()
if (IsGamePaused() == 1) return;
// Put here anything you want to happen every game cycle, but not
// when the game is paused.
}
function repeatedly_execute_always() {
// Put anything you want to happen every game cycle, even
// when the game is blocked inside a command like a
// blocking Walk().
// You cannot run blocking commands from this function.
}
function show_inventory_window ()
{
http://gInventory.Visible = true;
// switch to the Use cursor (to select items with)
mouse.Mode = eModeInteract;
// But, override the appearance to look like the arrow
mouse.UseModeGraphic(eModePointer);
}
function show_save_game_dialog()
{
gSaveGame.Visible = true;
// Get the list of save games
lstSaveGamesList.FillSaveGameList();
if (lstSaveGamesList.ItemCount > 0)
{
// If there is at least one, set the default text
// to be the first game's name
txtNewSaveName.Text = lstSaveGamesList.Items[0];
}
else
{
// No save games yet, default empty text.
txtNewSaveName.Text = "";
}
mouse.UseModeGraphic(eModePointer);
http://gIconbar.Visible = false;
}
function show_restore_game_dialog()
{
gRestoreGame.Visible = true;
lstRestoreGamesList.FillSaveGameList();
mouse.UseModeGraphic(eModePointer);
http://gIconbar.Visible = false;
}
function close_save_game_dialog()
{
gSaveGame.Visible = false;
mouse.UseDefaultGraphic();
http://gIconbar.Visible = true;
}
function close_restore_game_dialog()
{
gRestoreGame.Visible = false;
mouse.UseDefaultGraphic();
// gIconbar.Visible = true;
}
// Called when a key is pressed. keycode holds the key's ASCII code
function on_key_press(eKeyCode keycode) {
// The following is called before "if game is paused keycode=0", so
// it'll happen even when the game is paused.
if ((keycode == eKeyEscape) && gRestartYN.Visible) {
//Use ESC to cancel restart.
gRestartYN.Visible = false;
// gIconbar.Visible = true;
// If the panel's not ON, then the player must have gotten here by tapping F9,
// therefore his cursor needs restoring. If the panel IS on, then it doesn't,
// because it's already a pointer. Get used to thinking like this!!
if (!gPanel.Visible) mouse.UseDefaultGraphic();
return;
}
if ((keycode == eKeyEscape) && gPanel.Visible) {
// Use ESC to turn the panel off.
gPanel.Visible = false;
mouse.UseDefaultGraphic();
// gIconbar.Visible = true;
return;
}
if ((keycode == eKeyEscape) && (gSaveGame.Visible))
{
// Use ESC to close the save game dialog
close_save_game_dialog();
return;
}
if ((keycode == eKeyEscape) && (gRestoreGame.Visible))
{
// Use ESC to close the restore game dialog
close_restore_game_dialog();
return;
}
if (keycode == eKeyReturn) {
// ENTER, in this case merely confirms restart
if (gRestartYN.Visible) RestartGame();
}
if (IsGamePaused() || (IsInterfaceEnabled() == 0))
{
// If the game is paused with a modal GUI on the
// screen, or the player interface is disabled in
// a cut scene, ignore any keypresses.
return;
}
// FUNCTION KEYS AND SYSTEM SHORTCUTS
if (keycode == eKeyEscape) {
// ESC
gQuestions.Visible= false ;
gReponses.Visible= false ;
gSoldat.Visible=false ;
gPanel.Visible = true;
http://gIconbar.Visible = false;
mouse.UseModeGraphic(eModePointer);
}
if (keycode == eKeyCtrlQ) QuitGame(1); // Ctrl-Q
// if (keycode == eKeyF5) show_save_game_dialog(); // F5
// if (keycode == eKeyF7) show_restore_game_dialog(); // F7
if (keycode == eKeyF9) {
// F9, asks the player to confirm restarting (so much better to always confirm first)
gRestartYN.Visible = true;
http://gIconbar.Visible = false;
mouse.UseModeGraphic(eModePointer);
}
if (keycode == eKeyF1) {
gAide.Visible=true ;
}
if (keycode == eKeyF12) SaveScreenShot("SG1Quiz.bmp"); // F12
if (keycode == eKeyTab) show_inventory_window(); // Tab, show inventory
if (keycode == eKeyF10) {
gPanel.Visible= false ;
gQuestions.Visible=false ;
gReponses.Visible=false ;
cEgo.ChangeRoom(1) ;
}
// GAME COMMAND SHORTCUTS
if (keycode == 'W') mouse.Mode=eModeWalkto; //Notice this alternate way to indicate keycodes.
if (keycode == 'L') mouse.Mode=eModeLookat; //Note that all we do here is set modes.
if (keycode == 'U') mouse.Mode=eModeInteract; //If you want something else to happen, such as GUI buttons highlighting,
if (keycode == 'T') mouse.Mode=eModeTalkto; //you'll need some more scripting done.
if (keycode == 'I') mouse.Mode=eModeUseinv; //But this will, as-is, give you some standard keyboard shortcuts your players will very much appreciate.
// For extra cursor modes, such as pick up, feel free to add as you will.
// Uncomment the line below if you use the "Pick Up" mode.
//if (keycode == 'P' || keycode == 'G') mouse.Mode=eModePickup;
// DEBUG FUNCTIONS
if (keycode == eKeyCtrlS) Debug(0,0); // Ctrl-S, give all inventory
if (keycode == eKeyCtrlV) Debug(1,0); // Ctrl-V, version
if (keycode == eKeyCtrlA) Debug(2,0); // Ctrl-A, show walkable areas
if (keycode == eKeyCtrlX) Debug(3,0); // Ctrl-X, teleport to room
if (keycode == eKeyCtrlW && game.debug_mode)
player.PlaceOnWalkableArea(); //Ctrl-W, move to walkable area
}
function on_mouse_click(MouseButton button) {
// called when a mouse button is clicked. button is either LEFT or RIGHT
if (IsGamePaused() == 1) {
// Game is paused, so do nothing (ie. don't allow mouse click)
}
else if (button == eMouseLeft) {
ProcessClick(mouse.x, mouse.y, mouse.Mode );
}
else if (button == eMouseRight || button == eMouseWheelSouth){
// right-click our mouse-wheel down, so cycle cursor
mouse.SelectNextMode();
}
else if (button == eMouseMiddle) {
// Middle-button-click, default make character walk to clicked area (a little shortcut)
// Could have been just "player.Walk(mouse.x,mouse.y)", but it's best to
// leave our options open - what if you have a special script triggered
// on "walking" mode?
ProcessClick(mouse.x, mouse.y, eModeWalkto);
}
else if (button == eMouseWheelNorth) {
// Mouse-wheel up, cycle cursors
// If mode isn't WALK, set the previous mode (notice usage of numbers instead
// of eNums, when it suits us)...
if (mouse.Mode>0) mouse.Mode=mouse.Mode-1;
else
{
// ...but if it is WALK mode...
if (player.ActiveInventory!=null)
{
//...and the player has a selected inventory item, set mouse mode to UseInv.
mouse.Mode=eModeUseinv;
}
else
{
// If they don't, however, just set it to mode TALK (change this line if you add more cursor modes)
mouse.Mode=eModeTalkto;
}
}
}
}
function interface_click(int interface, int button) {
// This function is obsolete, from 2.62 and earlier versions.
}
function btnInvUp_Click(GUIControl *control, MouseButton button) {
// invCustomInv.ScrollUp();
}
function btnInvDown_Click(GUIControl *control, MouseButton button) {
http://invCustomInv.ScrollDown();}
function btnInvOK_Click(GUIControl *control, MouseButton button) {
// They pressed the OK button, close the GUI
//gInventory.Visible = false;
mouse.UseDefaultGraphic();
}
function btnInvSelect_Click(GUIControl *control, MouseButton button) {
// They pressed SELECT, so switch to the Get cursor
mouse.Mode = eModeInteract;
// But, override the appearance to look like the arrow
mouse.UseModeGraphic(eModePointer);
}
function btnIconInv_Click(GUIControl *control, MouseButton button) {
show_inventory_window();
}
function btnIconCurInv_Click(GUIControl *control, MouseButton button) {
if (player.ActiveInventory != null)
mouse.Mode = eModeUseinv;
}
function btnIconSave_Click(GUIControl *control, MouseButton button)
{
show_save_game_dialog();
}
function btnIconLoad_Click(GUIControl *control, MouseButton button)
{
show_restore_game_dialog();
}
function btnIconExit_Click(GUIControl *control, MouseButton button) {
QuitGame(1);
}
function btnIconAbout_Click(GUIControl *control, MouseButton button) {
gPanel.Visible=true;
// gIconbar.Visible=false;
mouse.UseModeGraphic(eModePointer);
}
function cEgo_Look()
{
Display("Damn, I'm looking good!");
}
function cEgo_Interact()
{
Display("You rub your hands up and down your clothes.");
}
function cEgo_Talk()
{
Display("Talking to yourself is a sign of madness!");
}
//START OF CONTROL PANEL FUNCTIONS
function btnSave_OnClick(GUIControl *control, MouseButton button)
{
gPanel.Visible = false;
mouse.UseDefaultGraphic();
http://gIconbar.Visible = true;
Wait(1);
gSaveGame.Visible= true ;
// btnIconSave_Click(btnIconSave, eMouseLeft);
}
function gControl_OnClick(GUI *theGui, MouseButton button)
{
}
function btnAbout_OnClick(GUIControl *control, MouseButton button)
{
gPanel.Visible=false ;
SoldLabel.Text= ("2014");
Bienvenue.Text=("Stargate Quizz");
Sold2.Text=("Graphisme G.Ferre Programmation G.Ferre , Kitai");
gSoldat.Visible= true ;
//Display("Stargate Quizz G.Ferre 2014.");
}
function btnQuit_OnClick(GUIControl *control, MouseButton button)
{
gPanel.Visible = false;
Wait(1);
gQuitGame.Visible=true;
//QuitGame(1);
http://gPanel.Visible = true;
// gIconbar.Visible = false;
mouse.UseModeGraphic(eModePointer);
}
function btnLoad_OnClick(GUIControl *control, MouseButton button)
{
gPanel.Visible = false;
mouse.UseDefaultGraphic();
http://gIconbar.Visible = true;
Wait(1);
gRestoreGame.Visible=true ;
// btnIconLoad_Click(btnIconLoad, eMouseLeft);
}
function btnResume_OnClick(GUIControl *control, MouseButton button)
{
if ((player.Room==2)||(player.Room==3)||(player.Room==4)) {
gQuestions.Visible= true ;
gReponses.Visible= true ;
}
gPanel.Visible = false;
mouse.UseDefaultGraphic();
http://gIconbar.Visible = true;
}
function sldAudio_OnChange(GUIControl *control)
{
System.Volume = sldAudio.Value;
}
function sldVoice_OnChange(GUIControl *control)
{
// Sets voice volume. Note that we don't check for the existence of speech.vox -
// we did that in game_start, so if it's not there the slider won't even be available.
SetSpeechVolume(sldVoice.Value);
}
function btnVoice_OnClick(GUIControl *control, MouseButton button)
{
// Note that we don't check for the existence of speech.vox - we did that in game_start,
// so if it's not there the button won't even be available.
if (btnVoice.Text == "Voice and Text") {
SetVoiceMode(eSpeechVoiceOnly);
btnVoice.Text = "Voice only";
}
else if (btnVoice.Text == "Voice only") {
SetVoiceMode(eSpeechTextOnly);
btnVoice.Text = "Text only";
}
// else if (btnVoice.Text == "Text only") {
// SetVoiceMode(eSpeechVoiceAndText);
// btnVoice.Text = "Voice and Text";
// }
}
function sldGamma_OnChange(GUIControl *control)
{
// Set the gamma. Note there's no need to check for anything else, as we ensured,
// in game_start, that the slider won't even appear if it's not possible to do this.
System.Gamma = sldGamma.Value;
}
function btnDefault_OnClick(GUIControl *control, MouseButton button)
{
// Reset everything to default. You'll have to edit these as well as the sliders
// if you'd rather have different default parameters.
System.Volume = 100;
sldAudio.Value = System.Volume;
sldSpeed.Value = 40;
SetGameSpeed(40);
if (IsSpeechVoxAvailable()) {
SetVoiceMode(eSpeechVoiceAndText);
btnVoice.Text = "Voice and Text";
sldVoice.Value = 255;
SetSpeechVolume(255);
}
if (System.SupportsGammaControl) {
System.Gamma = 100;
sldGamma.Value = 100;
}
}
//END OF CONTROL PANEL FUNCTIONS
function dialog_request(int param)
{
// This is used by the dialog text parser if you need to process
// text that the player types in to the parser.
// It is not used by default.
}
function sldSpeed_OnChange(GUIControl *control)
{
SetGameSpeed(sldSpeed.Value);
}
function btnRestart_OnClick(GUIControl *control, MouseButton button)
{
gRestartYN.Visible=true;
// gIconbar.Visible=false;
}
function btnRestartYes_OnClick(GUIControl *control, MouseButton button)
{
RestartGame();
}
function btnRestartNo_OnClick(GUIControl *control, MouseButton button)
{
gRestartYN.Visible = false;
http://gIconbar.Visible = true;
// If the panel's not ON, then the player must have gotten here by tapping F9,
// therefore his cursor needs restoring. If the panel IS on, then it doesn't,
// because it's already a pointer. Get used to thinking like this!!
if (!gPanel.Visible) mouse.UseDefaultGraphic();
}
function btnCancelSave_OnClick(GUIControl *control, MouseButton button)
{
close_save_game_dialog();
gPanel.Visible=true ;
}
function btnSaveGame_OnClick(GUIControl *control, MouseButton button)
{
int gameSlotToSaveInto = lstSaveGamesList.ItemCount + 1;
int i = 0;
while (i < lstSaveGamesList.ItemCount)
{
if (lstSaveGamesList.Items[i] == txtNewSaveName.Text)
{
gameSlotToSaveInto = lstSaveGamesList.SaveGameSlots[i];
}
i++;
}
SaveGameSlot(gameSlotToSaveInto, txtNewSaveName.Text);
close_save_game_dialog();
}
function btnCancelRestore_OnClick(GUIControl *control, MouseButton button)
{
close_restore_game_dialog();
gPanel.Visible=true ;
}
function btnRestoreGame_OnClick(GUIControl *control, MouseButton button)
{
if (lstRestoreGamesList.SelectedIndex >= 0)
{
RestoreGameSlot(lstRestoreGamesList.SaveGameSlots[lstRestoreGamesList.SelectedIndex]);
}
close_restore_game_dialog();
}
function lstSaveGamesList_OnSelectionCh(GUIControl *control)
{
txtNewSaveName.Text = lstSaveGamesList.Items[lstSaveGamesList.SelectedIndex];
}
function txtNewSaveName_OnActivate(GUIControl *control)
{
// Pressing return in the text box simulates clicking the Save button
btnSaveGame_OnClick(control, eMouseLeft);
}
function btnDeleteSave_OnClick(GUIControl *control, MouseButton button)
{
if (lstSaveGamesList.SelectedIndex >= 0)
{
DeleteSaveSlot(lstSaveGamesList.SaveGameSlots[lstSaveGamesList.SelectedIndex]);
lstSaveGamesList.FillSaveGameList();
}
}
function Entrer_OnClick(GUIControl *control, MouseButton button)
{
Bienvenue.Text=("...BIENVENUE...");
gEnterNom.Visible= false ;
SoldLabel.Text=Nom.Text ;
gSoldat.Visible=true ;
}
function Button2_OnClick(GUIControl *control, MouseButton button)
{
gQuitGame.Visible=false;
gPanel.Visible = true;
}
function Button1_OnClick(GUIControl *control, MouseButton button)
{
QuitGame(0);
}
function Button3_OnClick(GUIControl *control, MouseButton button)
{
gAide.Visible=false ;
}
function BtMenu_OnClick(GUIControl *control, MouseButton button)
{
gPanel.Visible= false ;
cEgo.ChangeRoom(1) ;
}
function gSoldat_OnClick(GUI *theGui, MouseButton button)
{
if ((player.Room==2)||(player.Room==3)||(player.Room==4)) {
gQuestions.Visible= true ;
gReponses.Visible= true ;
}
gSoldat.Visible = false ;
}
function cPorteSGC_AnyClick()
{
chargeFichierQuizz("SG1.dat") ;
gQuestions.Visible= true ;
gReponses.Visible= true ;
gSoldat.Visible= false ;
}
function cPorteAtlantis_AnyClick()
{
chargeFichierQuizz("SGA.dat") ;
gQuestions.Visible= true ;
gReponses.Visible= true ;
gSoldat.Visible=false ;
}
function cPorteUnivers_AnyClick()
{
chargeFichierQuizz("SGU.dat") ;
gQuestions.Visible= true ;
gReponses.Visible= true ;
gSoldat.Visible= true ;
}
function BtnRep3_OnClick(GUIControl *control, MouseButton button)
{
// Si on a cliqué sur le bouton dont l'ID est 1 (par exemple, mais tu auras sûrement des ID différents), on indique qu'on a cliqué sur la réponse 1
if (control.ID == 3) bt = 3;
else if (control.ID == 2) bt = 2;
else if (control.ID == 1) bt = 1;
else if (control.ID == 4) bt = 4;
// Si on a appuyé sur la bonne réponse
if (bt == bonne) {
aYes.Play(); // Le son qui va bien
GiveScore(25) ; // Des sous-sous
// On essaye de passer à la question suivante
if (!questionSuivante()) {
// Si questionSuivante a retourné FALSE, c'est qu'on est à la fin
// ... code ce que tu veux qu'il se produise quand on a gagné ...
}
}
// Sinon, si on a donné une mauvaise réponse
else {
aNo.Play(); // Le son qui va bien
GiveScore(-50) ; // On retire des sous-sous
}
}
function BtnRep4_OnClick(GUIControl *control, MouseButton button)
{
// Si on a cliqué sur le bouton dont l'ID est 1 (par exemple, mais tu auras sûrement des ID différents), on indique qu'on a cliqué sur la réponse 1
if (control.ID == 4) bt = 4;
else if (control.ID == 2) bt = 2;
else if (control.ID == 3) bt = 3;
else if (control.ID == 1) bt = 1;
// Si on a appuyé sur la bonne réponse
if (bt == bonne) {
aYes.Play(); // Le son qui va bien
GiveScore(25) ; // Des sous-sous
// On essaye de passer à la question suivante
if (!questionSuivante()) {
// Si questionSuivante a retourné FALSE, c'est qu'on est à la fin
// ... code ce que tu veux qu'il se produise quand on a gagné ...
}
}
// Sinon, si on a donné une mauvaise réponse
else {
aNo.Play(); // Le son qui va bien
GiveScore(-50) ; // On retire des sous-sous
}
}
function BtnRep2_OnClick(GUIControl *control, MouseButton button)
{
// Si on a cliqué sur le bouton dont l'ID est 1 (par exemple, mais tu auras sûrement des ID différents), on indique qu'on a cliqué sur la réponse 1
if (control.ID == 2) bt = 2;
else if (control.ID == 1) bt = 1;
else if (control.ID == 3) bt = 3;
else if (control.ID == 4) bt = 4;
// Si on a appuyé sur la bonne réponse
if (bt == bonne) {
aYes.Play(); // Le son qui va bien
GiveScore(25) ; // Des sous-sous
// On essaye de passer à la question suivante
if (!questionSuivante()) {
// Si questionSuivante a retourné FALSE, c'est qu'on est à la fin
// ... code ce que tu veux qu'il se produise quand on a gagné ...
}
}
// Sinon, si on a donné une mauvaise réponse
else {
aNo.Play(); // Le son qui va bien
GiveScore(-50) ; // On retire des sous-sous
}
}
function BtnRep1_OnClick(GUIControl *control, MouseButton button)
{
// Si on a cliqué sur le bouton dont l'ID est 1 (par exemple, mais tu auras sûrement des ID différents), on indique qu'on a cliqué sur la réponse 1
if (control.ID == 1) bt = 1;
else if (control.ID == 2) bt = 2;
else if (control.ID == 3) bt = 3;
else if (control.ID == 4) bt = 4;
// Si on a appuyé sur la bonne réponse
if (bt == bonne) {
aYes.Play(); // Le son qui va bien
GiveScore(25) ; // Des sous-sous
// On essaye de passer à la question suivante
if (!questionSuivante()) {
// Si questionSuivante a retourné FALSE, c'est qu'on est à la fin
// ... code ce que tu veux qu'il se produise quand on a gagné ...
}
}
// Sinon, si on a donné une mauvaise réponse
else {
aNo.Play(); // Le son qui va bien
GiveScore(-50) ; // On retire des sous-sous
}
}
function Button4_OnClick(GUIControl *control, MouseButton button)
{
gAide.Visible= true ;
}