Sunday, 7 September 2014

Bug Fixing

 The first issue to be addressed is the issue of the character returning to the screen after running out and ending the game.

to fix this all was required was to change the variable for Stop to 0 this ensures that the character could no longer run. Whilst fixing this bug another was located, when the player ran out the score would still accumulate points therefore a the value for ScoreAdd was changed to 0. These changes were made to the Sprite Limits action and are shown below with the changes highlighted

private action SpriteLimits ()
This limits the sprite the the confines of the screen. If the sprite leaves the screen the game finishes.
if  sprite → x >  board → width or  sprite → x < 0 then
 scoreadd := 0
 Awww2 → play
 sprite → hide
 sprite → set x( board → width / 2)
 sprite → set speed x(0)
 Stop := 0
 gameOver
else do nothing end if
end action

The next bug to fix is that of the score after the play again has been run. This is caused because the main is restarting and therefore doubles the timer set for accumulating score. to fix this the game needs to be reset without replaying the main therefore the Restart action was created This action, as shown below, is called in Endgame in place of Main.


private action Restart ()
This resets the game to be played again and as such all the required variables and animations have been reset and the game over text hidden from view
wall → clear
 Stop := 1
 game → set score(0)
 scoreadd := 1
 SpawnGears(3)
 GameOver → hide
 sprite → create animation → play frames("Idle")
 sprite → set x( board → width / 2)
The re-posting of the board to the wall resets the page without rerunning main
 board → post to wall
end action

The third major bug to be fixed is that of the game difficulty. to fix this the  gear speed will be lowered making it easier for players to dodge them. As players have more difficulty with the large gears it is only their speed that will be altered and the speed of the small gears will remain the same. The highlighted section changed from 100 to 50 significantly lowering the speed.

private action SpawnLGear ()
This declares the Large Gear as well as determining it's trajectory each time it is spawned
 Lsprite :=  board → create picture( Large Gear)
 Lsprite → set width(100)
 Lsprite → set pos( board → width + 2, math → random( board → height -  Lsprite → height / 2))
 Lsprite → set angular speed(400)
 Lsprite → set speed( - 50 - math → random(50), - 150 - math → random(50))
 bounce sound → play
 Gears → add( Lsprite)

end action

Next is the small matter of rewording the Instructions page as mentioned by Isaac.
Therefore the Instructions page now reads

"Something has gone very wrong with the professors latest invention and Widget is caught in the middle.
Help Widget to avoid the flying gears by tapping the screen. Tap on the  left side of the screen to move him left and tap on the right side of the screen to move him right. 
Good Luck

(Tap Screen to Start)"


However whilst fixing these bugs another arose. by adding the restart action the gears that hadn't left the screen before Endgame finished where still present after the user clicked play again resulting in as many as 6 gears happening at any one time. Therefore to ensure that all gears have left the screen on time a fade out feature was added to the GameOver action that sets the remaining gears to fade out ensuring that they are gone by the time Endgame activates. Changes to the code are highlighted here:

private action gameOver ()
This declares and sets the position of the game over text as well as calling the End Game
 GameOver :=  board → create text(100, 20, 40, "Game Over")
 GameOver → show
 GameOver → set pos( board → width / 2 - 40,  board → height / 2 -  GameOver → height)
for each sprite in  Gears
where true
do
sprite → create animation → fade out(6, "cubic")
end for each
 Gears → clear
 EndGame
end action


As the fade out effect worked well it was also added to the Menu so that instead of the menu abruptly disappearing it would fade out the new code is shown below:

private action MenuHide ()
This hides the menu during the game
 Title2 → create animation → fade out(0.5, "cubic")
 InstructionsTitle → create animation → fade out(0.5, "cubic")
 Instructions → create animation → fade out(0.5, "cubic")
 board → update on wall
end action

This is all of the bugs found in the game at this current time and they have all been addressed. Now the game is fully functioning with little to no errors.

1 comment:

  1. Great testing and fixing to come up with a suitable solution

    ReplyDelete