problems with game state and clicking mouse
Posted: Thu Jan 12, 2017 9:32 am
This post is about 2 problems I’m having with a game I’m developing. I have attached the project directory as a .zip file.
I am an ESL teacher (English as a Second Language) in Brazil teaching English to native Portuguese speakers. This game is to be a listening exercise for the students. They will listen to an audio clip (which I may eventually add to the game, but not at this time) and then they will play this game.
The objective of the game is to complete the text of the audio clip. The game starts with the splash screen where they can choose to see instructions or start the game. When they start the game, they are shown the play screen which presents 3 sprites, each of which are “saying” something in a text balloon. The player clicks on the sprite they think is saying the first words of the text (in subsequent rounds they choose the next text).
If they choose the correct text, they get the correctClick screen which tells them they were correct and adds their selected text to the text box. There’s a button on this screen for them to click to continue playing, which increments the phrase and returns them to the joga (play) screen, This continues until all of the text is completed. (This game has 26 phrases to complete the text.) If they complete the text before making 3 mistakes, they win and this screen will tell them they’ve won and there will be buttons to either quit or play again.
If they choose the wrong sprite, they get a wrong answer screen, which tells them their answer was wrong and tells them how many more mistakes they can make (a total of 3) before they lose the game. If they’ve made 3 mistakes, this screen will tell them they’ve lost and there will be buttons to either quit or play again.
The game has 5 games states and a screen to go with each. These games states and screens (represented by files) are:
splash (splash.lua)
instrucoes (instructions – instrucoes.lua)
play (joga – joga.lua)
cliqueCerto (correctClick – cliqueCerto.lua)
cliqueErrado (wrongClick – cliqueErrado)
Debugging tools:
I added a few things to help with debugging that will be removed when the game is finished. In main.lua I added code so I can click left ctrl + left shift + a letter to switch to each game state.
In the mousereleased function in theMouse.lua I added print() statements in each section so I would know when each section was run and what the game state was when that section started to run.
Problems I can’t figure out:
1. In the splash screen, when you click the bottom button to start playing the game you should ALWAYS go to the play (joga) screen. Sometimes it takes me to the correct screen, meaning the game state (estadoJogo) is joga. Sometimes it INCORRECTLY takes me to the correctClick screen (meaning the game state is cliqueCerto), without getting any input to know if it was a correct click or not. And sometimes it INCORRECTLY takes me to the wrongClick screen (meaning the game state is cliqueErrado), without getting any input to know if it was a correct click or not.
2. Sometimes, when I’m in the game playing screen, I click on the correct sprite it just updates the joga game state. What it should do (and frequently does) is go to the correctClick screen to show me I answered correctly. Then, when I click on the button, it should increment to the next round of the game and take me back to the play screen. It appears to be doing all of the processes I just described, I mean, it appears to be moving to the next round as it should, but it doesn’t show me the correctClick screen. Frequently it DOES show the correctClick screen, but sometimes it doesn’t and I can’t figure out why?
I am an ESL teacher (English as a Second Language) in Brazil teaching English to native Portuguese speakers. This game is to be a listening exercise for the students. They will listen to an audio clip (which I may eventually add to the game, but not at this time) and then they will play this game.
The objective of the game is to complete the text of the audio clip. The game starts with the splash screen where they can choose to see instructions or start the game. When they start the game, they are shown the play screen which presents 3 sprites, each of which are “saying” something in a text balloon. The player clicks on the sprite they think is saying the first words of the text (in subsequent rounds they choose the next text).
If they choose the correct text, they get the correctClick screen which tells them they were correct and adds their selected text to the text box. There’s a button on this screen for them to click to continue playing, which increments the phrase and returns them to the joga (play) screen, This continues until all of the text is completed. (This game has 26 phrases to complete the text.) If they complete the text before making 3 mistakes, they win and this screen will tell them they’ve won and there will be buttons to either quit or play again.
If they choose the wrong sprite, they get a wrong answer screen, which tells them their answer was wrong and tells them how many more mistakes they can make (a total of 3) before they lose the game. If they’ve made 3 mistakes, this screen will tell them they’ve lost and there will be buttons to either quit or play again.
The game has 5 games states and a screen to go with each. These games states and screens (represented by files) are:
splash (splash.lua)
instrucoes (instructions – instrucoes.lua)
play (joga – joga.lua)
cliqueCerto (correctClick – cliqueCerto.lua)
cliqueErrado (wrongClick – cliqueErrado)
Debugging tools:
I added a few things to help with debugging that will be removed when the game is finished. In main.lua I added code so I can click left ctrl + left shift + a letter to switch to each game state.
In the mousereleased function in theMouse.lua I added print() statements in each section so I would know when each section was run and what the game state was when that section started to run.
Problems I can’t figure out:
1. In the splash screen, when you click the bottom button to start playing the game you should ALWAYS go to the play (joga) screen. Sometimes it takes me to the correct screen, meaning the game state (estadoJogo) is joga. Sometimes it INCORRECTLY takes me to the correctClick screen (meaning the game state is cliqueCerto), without getting any input to know if it was a correct click or not. And sometimes it INCORRECTLY takes me to the wrongClick screen (meaning the game state is cliqueErrado), without getting any input to know if it was a correct click or not.
2. Sometimes, when I’m in the game playing screen, I click on the correct sprite it just updates the joga game state. What it should do (and frequently does) is go to the correctClick screen to show me I answered correctly. Then, when I click on the button, it should increment to the next round of the game and take me back to the play screen. It appears to be doing all of the processes I just described, I mean, it appears to be moving to the next round as it should, but it doesn’t show me the correctClick screen. Frequently it DOES show the correctClick screen, but sometimes it doesn’t and I can’t figure out why?