Wednesday, 6 January 2016

Where to start?

So where to start building a game? There are two approaches to take 1) being the brute force method of coding by just diving straight in or 2) plan out accordingly what needs to be done and how to do it. I normally go for option 2 but since I already built this game I went with the first option. The first and most obvious step was to get the player movement implemented. This was easy enough as I already had the code for 2D movement in vertical and horizontal directions coded from a different game I was working on awhile back. (Which I will finish....eventually). So with this code I only had to remove the vertical movement as we will only want to move left to right and add a jump function. I set up the scene and there you have it player movement and jumping. Below you will see the scene I went with the original coloring of Blockizor just for nostalgia purposes but will no doubting make my own sprites later on. I should mention that I changed the games name to "Blockzor" and not "Blockizor" so I just dropped the "i" for two reasons. One I think it sounds better and two Blockizor is already something in France and that's about it. Like all games I will probably change its name a few times during development.


So with this in place I decided it was a good idea to add in mobile controls so I can test it on mobile devices and see how it feels. I knew of two ways to do this and wasn't sure which was better. The first method was controlling the player with joystick and constraining to the horizontal axis using Unity's cross platform controller. If you have not looked at Unity's cross platform controllers before I would highly recommend it as it has some useful scripts for tilt controls and other various button controllers.
I tried the game with joystick on both my phone and tablet to see the difference. The joystick worked fine there were no real issues with but I felt that two movement buttons would be a better fit as I was sliding a bit too much. So I moved onto the second version by using just buttons. From my movement script this was already implemented previously for my other game so it only acquired setting up the buttons the way I wanted and testing it out. So I just needed to set the pointer up and down to my movement functions.
 The touch controls made a huge difference on mobile and made it much easier to control the character so I will stick with this button layout for the time being unless something changes.

Last thing I wanted to get working for the day was the randomize power to move the platforms and make it so that when you land on one they no longer move. Making the platforms spawn randomly was done by getting a min and max value for x and y of the where the platforms could go and then just use Math.RandomRange and set the platform to its new position. At this point I wasn't worried about overlapping platforms as I have yet to decide to keep that in the game or take it out.

So for checking if the player landed on top on the platform I researched a view ways to do it and ended up using the linecast method. The linecast is drawn to the ground and checks to see if it hits and object tagged is a platform and then the platform sets itself to be landed on so when we use our power we only move the ones that haven't been landed on. This method was also used to check if we were grounded in order for us to be able to jump.

That does for the first day of development it is going pretty well so far the next thing on the agenda is making a win condition and fixing the overlapping problem. I have a few ideas about how to do it and I will see if any of them work.

No comments:

Post a Comment