Today's i added the Ball Taco is running after! Player's score is the number of Ball Taco has catch without hitting an obstacle. Each time Taco catch a ball, the re-start with a more challenging run. If Taco hit a small wall, the game re-start from the beginning and score is reset to 0.
Each "Run to the ball" has a length equal to the number of obstacle sequences (ie. 1 to 3 small wall).
Run 1 (ID = 1) has length = ID + 1. So Run 5 has 6 obstacle sequences to jump over to reach the ball.
I searched a lot about sprite animation in Unity to finally use the simplest approach : 2d sprite frames. I discovered and used Pixelmator to edit my drawings. This app is really powerful: it's as good as Photoshop but for only something like 30$ ^^
Taco's run is made of only 2 differents sprites:
Next time, i'll add other states like jump and hit. I'll also add the other game ingredients : bush and bonus bone.
I've list what's left to do to complete this little game :
Day 22 - Ball Objective + Ball-Run Score
Day 23 - Score Screen
Day 24 - Save Game
Day 25 - Intro Screen
Day 26 - Background Scrolling + Menu Screen
Day 27 - Taco sprites + New ingredients: Bush & Bone
Day 28 - Sounds Effects
Day 29 - Playtest + Bug Fix
Day 30 - Build Package + Put Online
April 8th, the game is complete, and i celebrate =)
Today's goal was to generate procedurally increasing challenge : spawn forever more and more small walls with progressively less space between them. When Taco hit a small wall, i also properly restart the game from the beginning difficulty.
I has some trouble with Array (apparently there's no basic push() or pop(0 function in c#), so i tried to use List. I almost succeed but there was too much references errors, which i don't want to put time in because i won't learn much... so i fixed by using static multiple variables rather than a list (sigh...). It's crappy, but it works! so everything's fine =)
Today i've made the jumping behavior better. Taco (the dog) was not feeling responsive and his jump speed was not feeling fast enough. There was a bug on the control : sometime it misses a keyboard input, so pressing SPACE was doing nothing. i fixed that. I also increased the gravity to -20 (instead of -9.81) and adjusted the jumping force applied on Taco. I increased a bit the speed of obstacle. Taco jumping feels better now.
As soon as Taco collided with an obstacle, it was game over. This was ok most of the time... but not ok when Taco just landed a jump on a small wall... he should have been able to jump again instead of being hit... To make that happen, i changed a bit the way collision detection happen. I added a ray cast to detect collision in front of Taco (the red thin line in the video). Only an obstacle in front of Taco stop him. An obstacle below him is just like the ground, he can jump on it. This is true for the small wall, but maybe not true for the slowing bushes. Anyway, i'll check that another day. Today, Taco has a much better behavior =)
So what does "refactoring" means for game development? Basically it means that before the programmer (me) was not knowing what he was doing =) ... And so i need to "refactor" my code as an attempt to organise it in a simple and clear way, because now, i KNOW what i'm doing =) ... So that's what "refactoring" means.
I clarified my structure to follow the component-based simple structure principles. As you may see in the video, i now instantiate the player and obstacle during run-time. Before, they were just a bunch of prefabs in the scene. I'll be able to start on the procedural level design now, or maybe tweak the jumping behavior.
Today, i've build & run the project as a stand alone App on Mac. The process is again quite simple to have a version built. What took most of my time was the adjustment of resolution. I wanted to have some kind of "long format", like 16:9, to give player some time to anticipate obstacle movement.
Today, i designed the screen flow for the game. I kept it as simple as possible. While doing it, i adjusted the ingredient design. I was not completely happy with the idea of Taco having hit points. It was adding a resource to manage, which could be cool, but it was not satisfying that a bush ingredient remove 1 HP and a solid wall kill you. In fact player were managing only the resource to survive bush, but it had no value in front of wall. So i simplified, by removing the management of Hit Point. I instead focus on making ingredients related only to movement. A bush slow you. A wall stop (kill) you. A bonus increase temporarily your speed.
I'm a huge fan of automatically generating levels. Because, well done, it keeps thing unpredictable. Each time you play, it might be different. Also, it's possible to generate more content in less time. So i designed a simple level design principle : player encounter a challenge, with obstacles, then player has a rest moment where he might find a bonus. These challenge and rest moments always alternate until the player hit a wall or reach the ball. Then as the player progress toward the ball the difficulty of the challenge rise progressively. An algorithm increase the difficulty parameters steadily and insert a bit of randomness. Between "run" (each time taco catch a ball, we start a new run), the algorithm increase the number of challenges and overall challenge difficulty. here it is! procedural level design!
While searching about the best ways to structure my code in Unity for further refactoring, i discovered the component-based architecture. Being used so far to object-oriented programming and some coding patterns (singleton, etc.), this was quite a surprise, but a good one!
Component based architecture has its pro and cons, but basically it seems appropriate to game development. When you develop a game, you usually come up with ideas on the ways to make your game better. OOP actually make this process tedious because you always needs to re-think/re-organise your class structure. Component-based architecture aim to avoid that workload, by thinking differently.
Now that i know that, i'm going to explore and experiment with that approach :)
Hey, sorry for the video quality. I'm using quicktime to capture my screen and i'm not sure how to get the best results yet. I'll look into that eventually.
Today, i've made the background sprites (trees and grass) scroll. All thoses objects are contained in a game object named "Background". I've attached a dedicated script to this game object. This script apply a constant translation to the left to make the background move. I've made it loop, so it's never ending.
Then i ran into a common issue : how may i structure my code properly? I have 3 game objects : Taco, SmallWall, Background. When Taco hit a SmallWall, the Background has to stop scrolling. But as, i've attached scripts to each objects, i have no "main loop" which knows all the object in the scene and so can't communicate with all of them to synchronize them.
Rather than setting up a "main loop", i used TAGS and MESSAGES... which allows me to stays more object oriented =)
In Unity, you may define and set "tags" to objects. I set the tag of my background as "Background". This allows me to find it from the SmallWall script, using the function FindGameObjectsWithTag("Background"). Then i sent a message to my Background object: SendMessage("Scroll", false). It actually execute a function ("Scroll") and pass it some parameters ("false").
Basic Newtonian physics: constant force results constant acceleration, zero force results constant velocity. I was applying a constant force to the small wall. It was accelerating like crazy and was going out of control. So i made sure to rather update its velocity, so i can control how fast it goes and if it should accelerate to increase the challenge. Now each time taco jump over the small wall, it comes back a bit faster, giving the impression that taco run faster. I explored a bit collision. On collision with the small wall, Taco fall through the ground and the small wall stop moving. Just hit SPACE again the reset the game and start again. But as you may see at the end of the video, there's a bug... the small wall continue to move although Taco has been hit. Let's fix that next time and maybe scroll the background =)
Today, i changed TACO's behaviour to make him jump when SPACE is pressed. I added the first level ingredients : the solid obstacle. After setting up this ingredient as a prefab and adding a script to make it move from right to left, i can *play* TACO RUN! for the first time. Not so bad for day 7 =).
There's still work to be done, but i have 23 days ahead of me. I'm confident i'll have TACO RUN! working well at the end of this 30 days run!
Alright. Today i added some movement control to Taco. It quite easy to setup the collisions and physics, as Unity manage them directly. I mean there's no need to code or import a 2D collision or 2D physic system. it's already there by default, which is great! So i added a Box Collider to the Grass to have a ground for Taco to run on. Then i added a Box collider and a 2D Rigidbody to Taco for him to collide and be able to move (thanks to the rigdbody).
Last i've write some code to make him move when SPACE is pushed down and stop if space is released.
voidUpdate () { if (Input.GetKeyDown("space")){ Debug.Log("space down : Taco Run."); isRunning = true; movement.Set(1, 0); } if (Input.GetKeyUp("space")){ Debug.Log("space up : Taco Stop."); isRunning = false; movement.Set(0, 0); } if (isRunning){ myBody.AddForce(movement * speed * Time.deltaTime); } }
You can see the *amazing* result in the video. I'm please at how it goes. it's quite simple to setup those basic components.
Today i created my first ATLAS sprite sheet : it's basically an image containing multiples sprites. Unity can process those image automatically to create multiple sprite images. Still you have some constraints to respect, but it's pretty simple to do. I used SEASHORE, a free image editing software to create an alpha layer.
Then i created some sprites objects : Taco, Tree and Grass. I transformed each sprite object into a prefab (which is as simple as drag droping the game object into the project window. I wonder how i may set the screen pixel size of the game. Probably by adjusting the camera. I'll look into that tomorrow.
I like the simple editor interface, the prefab system, the c-sharp editor and the documentation. Everything works well together and it's a pleasure to work with this editor so far.
I like to have an idea of what kind of graphic the game would have from the start. It ties the setting with the game ingredients together. It's motivating, as i can picture the game better now. Also it gives a good sens of scale and rise some question for later about Unity, like how work the 2D art import flow? How do we create 2D animation?
I want to learn the basics of Unity. I'll use this blog to track my day by day progress. Let's define a simple achievable goal... 30 days to make my very simple first game with Unity. I won't commercialize this game... it's a personal project to get a good idea of how work the Unity 2D Editor. I'll probably put the game on download here eventually. So on Tuesday April 8th, i'll have complete my first game with Unity. Wish me good luck ^^
Here's the design overview :
TACO RUN!
A girl at the park play with her dog. She throws him a ball. TACO, her dog, run and jumps over obstacles to catch it. The girl throw the ball further. How far TACO can go?
Features
2D Side scrolling Runner
2D graphics and animations (free-hand drawing)
One button Interface (play, jump, continue)
Dog behavior : run normal, run fast, analogic jump, HitPoints
Procedural level design, with a few ingredients : fragil obstacle (HP Dmg), Solid obstacle (Death), HP bonus (+HP or speed boost when HP full)