Saturday 25 October 2014

Prehistoric Game [Dev Chapter 5]

[Update]


I began work on creating a script for the player movement. My goal was to create a 3 lane movement where the player could jump from lane to lane but only those adjacent to the one the player was currently in preventing the player from skipping over an entire lane. I did this by using if statements to check the position of the player and identifying if they could go left or right and then move them to the next lane in that direction if it existed.


I originally ran into a bug that when the player pressed a key to change lanes it would occasionally change lanes twice in the direction the player wanted to go. This bug puzzled me as the type of input I was using was get mouse button down which would return true when the key is pressed and would not repeat itself until it was pressed once again. Although i found no real solution to this i decided that the game would benefit from being harder than it was as it was too easy to dodge the dinosaur at this point due to the player being able to jump from each lane as fast as they could push buttons.


I made the game more challenging by adding a cool down between lane changes. The cool down lasted for one second and would make the player attempt to time his lane changes perfectly to dodge the dinosaurs attack. This also served as a solution to the bug earlier with the player changing lanes twice when the button was pressed only once.


After finishing the players movement between each lane I shifted my focus to the dinosaurs movement. At the current time the dinosaur stayed in the centre lane and didn't follow the players lane changes. Left like this the game would have been too easy. To make the dinosaur move with the player I amended my player movement script and added the dinosaur movement to it instead of having to write more lines of code by using a separate script. This is because since I was already checking lanes in the players movement script I could use the same checks to see where the player was and make the dinosaur move to the players position a few seconds after the player had moved there.



No comments:

Post a Comment