Tuesday 8 December 2015

Assignment 2: Unit 1/Unit 72/Unit 22: Computer Games Design

Task 1 (1.1): Initial Sketch



Task 1 (1.2): Sprites 


My sprites consist of the shapes that are involved within the game, the invisible walls which let the enemies out, the moving walls, the shop animation, walls, collectible and background. The screenshots above show the editor that I have used to create the sprites and they contain a number of tools in which I have used. Tools such as the circle tool, the pen tool, the fill tool etc. The screenshots which show the image index of the sprite shows how the animation works. Each image has something different about it. This could be a changing glow colour or blinking eyes or it rotates and so on. The other sprites such as wall, wallmove, push, wall invisible all have only one image in their image index. 

Task 1 (1.3) Objects:



Object Player (obj_player):

The object player has a lot of events in. The keyboard events “Left”, “Right”, “Up” and “Down” all control how the player moves the object player in the room. There are many collision events associated with the main player. Within the collision events for the different shapes the player can change into, are 3 actions which are played through; Change sprite, code and then alarm. The change sprite action allows the player to change into the shape sprite of which it has collided with, the coding includes code of the vspeed and hspeed which created when in contact with the shape object and the alarm is an alarm which is set to turn on after 1 tick. The coding, which includes a set vspeed and hspeed is there so that whatever vspeed and hspeed the player is moving at will then be reversed and the player will be pushed away from the object. The reason why I have done this is so that the player does not get stuck within the shape object. The alarm is then set after the code has been executed and then the alarm will turn on. In the first alarm which is set is friction and then another alarm which is set to turn on after 10 ticks. The friction slows down the player and then once that has been executed, after 10 ticks alarm 1 will turn on. Alarm 1 contains a drag and drop which turns the friction off. The reason for this was so that it wouldn’t be buggy. The bug was that leaving the friction on would mess up the movement of the player. The collision event with the walls, invisible walls, moving walls and the “push” objects is there so that the player can’t go through them. The final event is the collision with the enemy. Inside the enemy collision event is an action which executes a code. Within the code, are two if statements. The first if statement defines, if the object player is the same sprite as the enemy sprite then what happens is the enemy sprite is destroyed and then 20 score is added onto your score you have got. Otherwise you die (the player). The second if statement happens when you die. So, if the player dies then your lives are reduced by 1, an explosion is then carried out, your player gets destroyed and then gets spawned back in the original spawn point. Within this second if statement is a nested if statement which defines what happens when you have less than 0 lives. What happens is that a message pops up and the game restarts. This including a fresh set of lives, new score and the game ticks are reset.

Object Enemy (obj_enemy):

Within the create event are two actions. The first action is the “start moving in a direction” action and I have set this so that the enemy moves in a certain direction on its own. The code action after the direction one includes code which links in with the “frozen” element I have within my game. (The code is setting “frozen” as a variable). The step event has only coding tied in with it. The code has 3 if statements in and a switch statement. The first if statement is defining what happens when the frozen variable is 0. Within this if statement is a nested if statement which explains, if the moveto variable and the player does NOT have the same sprite as the enemy and the enemy doesn’t move towards the player then moveto is false. The next if statement is similar however if the variable moveto and the player is the same sprite as the enemy and the enemy doesn’t move towards the player then moveto is false again.
The switch statement is set to work with the variable “spriteto”. The sprite_index is the list of sprites I have. Therefor what the switch statement is doing is going through the list until it has found what it is meant to equal to. So if it is “case 0” then the sprite will flick to the “Circle” sprite I have. If the case is 3 then the sprite will change to the “Square” sprite and so on.
Right at the bottom of the code is an if statement which basically means if the variable “freeze” is set to 1 then perform a specific event which has been defined within the enemy and then turn the global variable freeze off (to 0). The specific event which is being called within the if statement is actually calling the user defined 0 event. Within this event are 3 actions. The action stops the motion of the enemy, it puts it to a complete standstill. Then an alarm 2 (another event) is set to go off after 200 ticks and then a piece of code is executed after the second action has been carried out. Within the code is the global variable “frozen” being set to 1. Alarm 2 activates after 200 ticks. What alarm 2 does after 200 ticks is allows the enemy to move again and then the code sets the variables “freeze” and “frozen” to 0 which essentially means turning them off.
The next events are collision events. The collision event with the player is the same as the player collision with the shapes it can change into. What happens in the code is that the player is flung reverse to where it was going. For example, if it was hitting the enemy from above (so going down) it would be flung back up. Then an alarm is set to go off after 10 ticks. What this alarm does is sets the friction of the player down to 0.5 and sets another alarm to go off after 5 ticks have gone by. In the next alarm it sets the friction to 0 and then allows the player to start moving in any direction.
The collision with the first “obj_wall” allows the enemy to bounce off of the wall object and then move in any random direction. This the same for “obj_wall_1” however advanced bounce is set to true. The collision with the push objects basically pushes the newly spawned enemies out in a certain direction. So for the “push_l” they get pushed in the left direction and for “push_r” they get pushed out in the right direction. This is the same for the invisible wall collision. When the enemies collide with the invisible walls they get bounce back dependent on which wall they are colliding with. If they are colliding with “obj_wall_invisible_r” then the enemy get pushed in the right direction as they were currently moving in the left direction.



Controller:

The controller only have 4 events within the object. The create event holds a execute code action. Within this action are a bunch of global variables which have been set. In the alarm 0 event is a code which has set another global variable. However the reason why it is in the alarm event is so that it can be called upon at a certain time.
Within the step event there is only 1 action event, execute the code. There are 5 if statements and 1 switch statement within this action. The first if statement defines if the variable “frozen” is set to 0 and a random integer is equal to 1 then the countdown is reduced by 1 each time instead. The next 3 if statements work together. The first “cycle” if statement basically means if the cycle is equal to 0 then a lot of the invisible walls are created in specific locations and then 1 is added onto the current cycle count which at this point is 0 so it will equal to 1. Then in the second if statement, if the countdown is less than around 5/8 and times the amount of gameticks and the cycle is equal to 1 then what will happen is it will destroy the invisible walls and then create a lot of walls in a specific location and then 1 is added onto the current cycle amount (thus equal to 2). The final if statement which links with the cycle explains that if the countdown is ¼ of the gameticks and the cycle is equal to 2 and there are only 2 or less enemies alive then it will spawn in 6 enemies in specific areas. Then 1 is added onto the current cycle value. Those 3 if statements sum up how the enemies spawn in, how the walls work with letting the enemies get out and how the game knows when to spawn in more enemies. The last if statement has a nested if statement involved. If the countdown is less than 2 then, if the gameticks are more than 50 the gameticks will be reduced by 5, the countdown will equal the gameticks (which means that will also be reduced by 5) and the cycle is reset back to 0. Other than that, if the gameticks are not more than 50 then countdown equals what the gameticks are currently are and the cycle is still set back to 0. Then the spriteto variable will equal the spritenext variable. What the spritenext variable is equal to is a random integer which it selects a number out of 5. The final part of the code is the switch statement. What this switch statement does is basically works as a playlist. The cases work in pairs. So case 0 and 1 works for one sound that is created. The first case plays the sound which is has been set to play and then the second case checks whether song is still playing. If the sound is not playing then it will play the second sound (or in this case the second song) and then so on.
The last event is the draw event, within this event are 3 actions. The first action draws the score on the game, which at the start is 0. Then the second action draws how many lives you have, which at the start of the game you have 5. The last action is executable code which has 15 if statements and few other pieces of code. The first 5 if statements cover how the numbers appear in the middle of the room and it associates the numbers with the shape of what is going to show next. Then the next if statement is the checking whether the backspace key has been pressed. If the backspace key has been pressed then the variable “menutoggle” will be set to -1. Then the menutoggle if statement checks whether menutoggle is more than 0, if it is then it will create the sprite of “obj_shop”. The sprite “obj_shop” is an animation of a purple dropdown. The “draw_set_halign” and “draw_set_valign” sets the positioning of the sprite and then another if statement is carried out. If the variable of “shopdraw” is equal to 1 (so turned on) then font used, white will be the colour of the font that is drawn and used and 4 lots of text appears on screen. The rest of the text that is on screen is set to the colour red and uses a different font. Then another menutoggle if statement is carried out. If the menutoggle variable is less than 0 then the shopdraw variable is equal to 0. What this means is that shopdraw will be turned off. The next few keyboard if statements all link in with shop and buying mechanism. The keyboard check, checks whether numpad 1 and the score is more than or equal to 100, if both of those conditions are met then the 100 is took away from your current score and life is added to your current amount of lives and the menutoggle = -1. The next keyboard check, checks whether the numpad 2 has been pressed and whether the score is more than or equal to 100, if both of these conditions are met then the global variable “freeze” is turned on (changed to 1) and menutoggle is equal to -1. The following keyboard check, checks whether numpad 3 has been pressed and the score is more than or equal to 50, if both of these conditions are met then 50 score is taken away from your current score and you will gain double the amount of speed that you have (in this case, your playerspeed is equal to 6) and then an alarm is set so that after 100 ticks the menutoggle is set to -1 and the effect is turned off. The final if statement within executable code action is a menutoggle if statement. If the menutoggle is less than 0 (in which its usual state is -1) then the number is drawn in the middle (the one that changes), the gameticks show and the countdown shows.

Object Wallmove 1 and 2:

Both of the object wallmoves have similar coding but both working in the same way. The only difference in the coding is the positioning of where the wall is being moved to and the score they are set to move on. Obj_wallmove only has one event in which is a step event. Within the code of the step event are 3 if statements. What the if statements do, they check if the score has reached a certain amount and then once it has reached a certain amount the path starts to stop. However, once it has reached certain co-ordinates, the path ends. Then when the score has reached a higher number, the path starts again, reaches a point and then the path ends.

Object Collectables:

Similar to the wallmove, it only has one event. The only event this has is a collision event with the player. Once the player has collided with the collectible 2 actions are played through. An additional 5 points is added when the player has collided with the collectible and then the instance is destroyed.

Object Menu:

The object menu is the menu that you first encounter when you load up the game. This object consists of 3 events. The create event holds some code which is run as soon as soon you have loaded up the game. The code is set out as a list (an array) and to whatever number is set text of what will appear. Then the amount of space between them is 64 pixels. In the step event, it holds the code for the movement of your arrow keys. The variable move is set to 0. The “+=” and “-=” both either increase or decrease from 0. Every time you either press the up/down arrow or the W/S key then each time it will add 1 or – 1 from 0. This then sets off a chain reaction for the next if statement. After that, if move is not equal to 0 then the next piece of code explains that if you move up it will curl back around and appear at the bottom and vice versa. The final piece of code is that, if you push the enter key, the shift key or the spacebar key then the script menu is used. The “scr_menu” contains a switch statement that works with the variable “mpos”. Basically, it checks through what you have pressed enter, shift or spacebar on. The case numbers link with the menu array list that I set up at the beginning in the create event.

Object Shop:

The object shop consists of 2 events, a create event and a step event. In the create event is code which defines the variables of “yup”, “nope” and “image_speed”. What happens in the step event is how the image_index appears when global variable shopdraw is turned on (equal to 1). If the image_index is equal to 7 and the nope variable is equal to 0 then what happens is the speed is equal to 0 and the image_index is equal to 8 and it plays the animation and the shopdraw is turned on (equal to 1). However, if the global shopdraw is turned off and yup equals 1 then the image_speed is reduced to -1 which means reversing the animation and making it close. Then in the nested if statement the image_index is destroyed, this making it disappear.

Object Pause:

There are 2 events in object pause, create and <any key>. In the create event is a piece of code which declares the global variable “pause1” to 0. Then in the any key event is code which contains 2 if statements. The first if statement check whether the variable pause1 is equal to 0 and the spacebar has been pressed and it deactivates the controller, the enemies and player. By deactivating those means removing them whist the variable is set to 1. Then the code is executed. Then the last if statement checks whether the spacebar has been pressed and the variable pause1 is equal to 1, if both conditions are met then the player, enemies and the controller are all activated again and you can continue the game from where you left off. Then the variable is set back to 0 which means turning it off.

Object Pause Draw:

This object links in with pause object. What happens in the draw event is that when the variable pause is equal to 1 (turned on) then text is drawn.

Object Background:

An object background was created so that I could have an animated background. In the draw event is a piece of code. It just stretches the sprite to fit the room height and width. Otherwise it just plays through the image index the size it is.


Task 1 (1.4) Rooms and Task 4: Improvements : 


Task 5: Game Manual (Documentation):




Task 2 and 3: Testing the game

https://youtu.be/wqZpCIOOFMs

https://www.youtube.com/watch?v=S5CgCNkUK9g&feature=youtu.be