Restarting the Code, Beginning the Game

After we had worked on making some more assets for the game, we were ready to begin coding properly as no we actually had the real assets to use. This would make testing things a lot easier, as I have obstacles that will be used in the game, and I know how high they are going to be and where they are going to be placed.

Screen Shot 2015-05-04 at 15.20.02
Implementing the running animation I coded earlier to the Elias Sprite

First off I needed to update the testing code I already started to use the new assets we had created. I actually found it easier to just start again, as the code I had before was not really efficient. I had also done some further reading, most particularly a platforming game tutorial for Swift (Online 2015), which although was a little dated was very helpful.

First I created an instance of the player as I had before and linked the Elias’ walk loop pictures together to create a running animation.

It was then time to add the jumping function to Elias, before I used a function that just added an upwards velocity vector each time the screen was tapped. However this did not create a natural jumping movement as it was too sudden and jerky and I instead found a better Sprite Kit function to use applyImpulse. This makes Elias move upwards more slowly, in a more natural arcing fashion (the reason for this is that whilst my previous function was just adding a vector to Elias, this function is instead using a constant which increases and decrease influence over time.)

iOS Simulator Screen Shot 11 May 2015 15.06.37
Adding in the background to the scene

Next was to add in the background function I had created before to add in the new backgrounds we had created.

To make sure the background scrolled consistently over time, I needed to calculate any drops in frames. To do this I needed to update the MyUtils file in Swift which deals with mathematical operations. I changed it different types of variables (such as vectors and floats) can be used together. For example now I can times a vector by a float without having to isolate the x and y values of that vector. This means a lot of operations I need to use will be a lot quicker and this will make the coding process more efficient.

Next I need to add in the objects ti the scene and handle Elias’ interaction with them.

Online, S., 2015. 3. Introduction to Sprite Kit. [online] Safari. Available from: https://www.safaribooksonline.com/library/view/learning-swift-building/9781939902115/ch03.html [Accessed 5 May 2015].

Wenderlich, R., 2014. IOS Games by Tutorials. Virginia: Razeware.