Friday, 19 June 2015

Questions

To start off with I have created a script called randomizeQuestion which will make the answers random. I am showing the debug message of the question object which i have created which will show the questions. In this script I have written it out so that the questions will be displayed and the answers will be randomized and the correct answer will also be shown. I have included a for loop which will show the answer and I have set it up so it will assign and display the answers and question. 
On the answer pellets I have added a create event which assigns that pellet an answer number for example answer pellet A will have an answer pellet number of 0. B will have 1, C will have 2 and D will have 3.


The answer pellet has a pacman collision so when pacman eats the pellet i have code to check to make sure it is the right answer, if it is then it will go to the next level, if it isnt then it will show an error message syaing its wrong. There is also an if statement stating that the control object and the current question will be equal to the number of questions which will end the game or else it will execute the script.  This event is on all the answers pellets.
On the control object it will be controlling and displaying the questions, answers and right answer code. It will load the questions file which has 3 questions in it as well as the answers. It will read the file and add the question on the room as well as the number of questions. It then closes the file and shows the number of questions when you come out of the menu page. It will creare the question object and execute the script.
Also in the create event is setting the lives to 3 so pacman has 3 lives, setting the score to 0 and the variables global.gameover and global.can_move to false as well as setting the variable global.extra_life to 1 although the lives system doesn't seem to work, I'm not sure why.
I have set an alarm up to create and display the message object.

I have set up a draw event and in there i have drawn the lives as a pacman image, set the font to score which is a font i added in the font section which displays all characters. I have set the colour to green and drawn the score in the top right corner which is an x of 630 and y of 1 and the caption is "Score:".

In the pacman object i have created a collision for each answer pellet which all have the pellet object as the parent. If the answer objects are collided with the pacman it will add 50 to the score, i have tested the variable score larger than global.extra_life * 100 then it will add a life and set the variable to 1. If the pellet object is equal to 1 then set the variable global.gameover to true and global.can_move to false which will destroy the parent alien and create the message object. Lastly it will destroy the pacman.

I have created a question object which i have added a create event which I have execute code to display the questions,answers and correct answers.
I have also added a draw event with the actions of setting the colour to red and the font to the score font. Then I have execute code which is the exact placing of the questions and answers text including the correct answer.


No comments:

Post a Comment