
-----------------------------------
programmerNeedsHelp2.0
Thu Jun 08, 2017 7:42 pm

Turing program won't run; gives error message &quot;Syntax error at 'loop'. expected 'end if'
-----------------------------------
Along with programmer_needs_help (my friend, who is also a member on compsci.ca), we are making a Turing game for our final school summative in Computer Science. I am currently programming a start screen which transitions to a main menu when the user presses "s" on the keyboard. The main menu contains four buttons. These four buttons include an "About Game" button, "Game Controls" button, "Start Game Button" and "Quit Game" button. When you click on the "About Game" button, it leads to a screen which talks about the game (a game overview.) Then, by clicking a "next arrow" on that screen, it leads to a second screen which continues on the description of the game overview. Then, once again, by clicking an arrow on this screen, it leads to the final screen that talks about the game overview. Now on each of these "game overview" screens, there is a button displaying "Back", in which when the user clicks it, it goes back to the main menu. When you click the "Game Controls" button on the main menu, it leads to a new screen, which obviously talks about game controls. Then, by clicking on the "back" button located on that screen, it leads back to the main menu. By clicking the "quit game" button, the execution window closes. I am not worrying too much about the "start game" button yet. Regardless of all this, the program is not running, and I believe that this is due to a mix up in my loops and if statements. Here is the code:

% Zaid Omer and Chabeshan Kandiah
% June 7th 2017
% SwordQuest.t

% Indicate Screen Size and Background Image
View.Set ("graphics,offscreenonly")
var window : int := Window.Open ("graphics:930;605,nobuttonbar")

% Indicate Variables
var swordQuestLogoImage : int
var forestBackground : int
const CENTREX : int := maxx div 2
const CENTREY : int := maxy div 2
var msSerifFont : int
var startOption : char
var pressSToStartPic : int
var pressSToStartSprite : int
var arrowInput : array char of boolean
var mainMenu : int
var levelOneBackground : int
var aboutGameButtonPic : int
var controlsButtonPic : int
var startButtonPic : int
var quitGameButtonPic : int
var aboutGameScreenOne : int
var aboutGameScreenTwo : int
var aboutGameScreenThree : int
var controlsScreen : int
var backButtonPic : int

% Import Start Screen Music
Music.PlayFileLoop ("StartOfGameSoundtrack.mp3")

% Start Screen

% Import Forest Background
forestBackground := Pic.FileNew ("StartScreenForestBackground.bmp")
forestBackground := Pic.Scale (forestBackground, 930, 605)
Pic.Draw (forestBackground, 0, 0, picMerge)

% Import Game Logo/Title
swordQuestLogoImage := Pic.FileNew ("SwordQuestLogo.bmp")
swordQuestLogoImage := Pic.Scale (swordQuestLogoImage, 430, 270)
Pic.Draw (swordQuestLogoImage, CENTREX - 220, CENTREY - 120, picMerge)

% Start Option
pressSToStartPic := Pic.FileNew ("pressSToStart.bmp")
pressSToStartPic := Pic.Scale (pressSToStartPic, 500, 200)
pressSToStartSprite := Sprite.New (pressSToStartPic)
Sprite.Show (pressSToStartSprite)
for startLocation : 0 .. 40
    Sprite.SetPosition (pressSToStartSprite, CENTREX, startLocation - 25, true)
    View.Update
    delay (20)
end for
loop
    startOption := getchar
    if startOption = "s" or startOption = "S" then
        Sprite.Hide (pressSToStartSprite)
        cls
        exit
    end if
end loop

var playGame, aboutGame, exitAboutGame, exitAbout, gameControls, exitGameControls, menuDraw : boolean
var buttonX, buttonY, button : int
var buttonXOne, buttonYOne, buttonOne : int
var buttonXTwo, buttonYTwo, buttonTwo : int
var buttonXThree, buttonYThree, buttonThree : int
var buttonX1, buttonY1, button1 : int


loop
    exitAboutGame := false
    playGame := false
    gameControls := false
    exitGameControls := false
    menuDraw := false
    if menuDraw = false then

        % Main Menu
        mainMenu := Pic.FileNew ("mainMenu.bmp")
        mainMenu := Pic.Scale (mainMenu, 930, 605)
        Pic.Draw (mainMenu, 0, 0, picMerge)

        % Create the pictures for main menu buttons
        aboutGameButtonPic := Pic.FileNew ("aboutGameButtonPic.bmp")
        Pic.Draw (aboutGameButtonPic, 8, 202, picMerge)
        controlsButtonPic := Pic.FileNew ("controlsButtonPic.bmp")
        Pic.Draw (controlsButtonPic, 319, 202, picMerge)
        startButtonPic := Pic.FileNew ("startButtonPic.bmp")
        Pic.Draw (startButtonPic, 630, 202, picMerge)
        quitGameButtonPic := Pic.FileNew ("quitGameButtonPic.bmp")
        Pic.Draw (quitGameButtonPic, 650, 20, picMerge)
        menuDraw := true
    end if

    loop
        mousewhere (buttonX, buttonY, button)

        % In-game buttons

        % Start Game Button
        if (buttonX >= 631 and buttonX = 205 and buttonY = 652 and buttonX = 21 and buttonY = 321 and buttonX = 202 and buttonY = 602 and buttonX1 = 38 and buttonY = 8 and buttonX = 202 and buttonY = 594 and buttonXOne = 98 and buttonYOne = 489 and buttonXOne = 92 and buttonYOne = 594 and buttonXThree = 98 and buttonYThree 