Steady Drop – Log #5

 

Gyroscope handling

I want to talk a little bit about the first things I developed when I got the idea for Steady Drop. Just from the beginning I had this idea to use the gyroscope data from a mobile device and to do something with it. I started developing a first prototype which uses the gyroscope quaternion given by the “attitude” property and elaborating it to get the gravity direction using euler angles. The class doing all this stuff was (and is) called GyroTilt and for some time the name of the game/project was GyroTilt until I came up with Steady Drop. For a prototype it worked fine, and I started developing the game on top of this logic. At the time I wasn’t testing everything so often on a real device and for a reason or another I finished up screwing part of the logic and all the rotations were broken.

Recently I’ve changed the method to compute the gravity direction by simply getting the gravity directly from the the gyroscope class. This property returns a vector (with magnitude one) with the direction of the gravity in world space. I can take this vector and go on and use it with the rest of the logic which wants only the gravity direction and ignores how it is computed. Unexpectedly this gravity vector is much more stable that the attitude and I think it is not more CPU expensive that the other.

One issue I will have to resolve will probably be the device compatibility, since I’m developing this game for Android, there are hundreds of different devices with different mounted sensors. I haven’t tested my game on different devices yet, so I’m thinking to give the game build to some friends and people who can test it out, a sort of “closed alpha”.

 

Gravity direction, now what?

Ok, now that I have the gravity direction I use it for adding the increasing force (like I said in devlog #4) with its logic ruled by user inputs, and for rotating the object. To rotate the object correctly, I tried in the first place to use the RigidBody rotation caused by the force I add, which is nice but I could not find the right level of responsiveness I want. So I decided to freeze the rotation on the RigidBody component and to apply the rotation manually to the Transform. In this way the rotations are very responsive and the fact that I’m not using the rotation from the RigidBody is not a problem, since the physic system is all custom and ruled from my scripts.

 

Future uses

Since now the gravity direction seems stable I’m thinking to use the gravity for different purposes that can add gameplay variationsRight now the only object that react to gravity is the avatar of the player, what about some special enemy that reacts to gravity? I’m not sure to use the pendulum that I have right now, but I’m thinking a new type of walls maybe, that reacts to gravity. Maybe the gravity can affect some physics parameters of an object or an obstacle. I will decide what to do about this matter in the future, surely after the beta release.
Stay tuned for future posts 🙂

Game developer & designer. Unity 3D lover. Movie fanatic.

RaspberryBoy – BuildLog #1

Discover the Raspberries

Recently I’ve bought a Raspberry Pi 3 and I started to play with it and installing some dedicated operating systems and doing some researches on what could be done with this tiny machines. The model I bought is not even the smallest one. If I have to describe it in one word, it would definitely be amazinglySmall 🙂 .

I also came across the vast set of projects done with the Raspberries (here) and I’ve found a lot of interesting projects of different genres and purposes. Finally I discovered the branch of projects about retro modding, in which this tiny machines are used to create custom retro consoles with an operating system containing lots of emulators of retro consoles. You can either use a plain Raspberry Pi to play with this emulators or you can put it in a case, portable or not.

There are a lot of good projects like the ones proposed in the Adafruit (here) with detailed circuit diagrams and high res photos. The projects are mostly created with 3D printed cases for portable consoles similar to different Game Boy versions.

By the way, Adafruit is the best place to go if you want to create any type of project with Raspberry and other similar devices. They have a lot of products and kits that can avoid a lot of headaches if you don’t know much about electronics and you have to build some parts by yourself.

Starting my build

I finally found this video with this guy showing his project to take an existing Game Boy DMG-01 and modify it and he did a pretty good job. He used a Raspberry Pi 0 and several other parts. He also posted a series of video like a step by step guide and his site has a very useful wiki section and a forum as well.

I have a little knowledge of electronics and a propension to use screwdrivers and tools so why not! I started to look around and try to find all the components I need to make my version of his Game Boy Zero, called RasperryBoy. I’m planning not to do everything he did but I will take his tutorials as inspiration. After several hours of research I found almost everything I need, or at least all the sites to find the parts. I live in Italy so to contain the shipment costs, I searched for italians or europeans retailer of Adafruit.

While the parts was on its way, I started with disassembling the case and make practice using a rotary tool. I think modifying the case is the most difficult part for the project because it’s visible. I had an old original DMG-01 and I started to modifying its case with the rotary tool nut I’m not sure if this case will be on the final build. I will post periodic updates on this project. Stay tuned 🙂

Game developer & designer. Unity 3D lover. Movie fanatic.

Steady Drop – Log #4

 

Like I said in the last post, this one is about game logic.

I think games can be a pretty good simulation of the real world, and so far they do a really good job in this, even if most of the times there are only approximation of physics rules. Again, they CAN be a simulation but they do not HAVE to. So, in my case, I choose not to follow the stricts physics rules of gravity but I defined my own one.

 

Gravity logic

What I have at this point is only the gravity direction ruled by the device orientation. The amount of gravity force is determined by a simple algorithm: starting from a base multiplier, I add a certain value to this multiplier every N crossed unit and then I multiply the gravity vector for this multiplier.  In this way the speed increases in a sort of exponential way.

When the player stops the gravity, current force and speed are saved and they are applied once the player release the stop.

 

Point Logic

Let’s start with explaining the basic idea. I wanted a scoring system based on the distance that increases the points every N crossed game unit. The amount of increase depends on different factors. It depends on the gravity multiplier explained above and on a point multiplier that is progressively lerped to zero when the player stops the gravity and lerped to a maximum value when the player doesn’t stop the gravity. In this way a long stop equals to a smaller point increase, especially for high gravity multipliers. If you stop at the beginning there’s no big deal because the gravity multiplier is still low.

To do a recap:

  • Increase points every N crossed game unit .
  • The increase depends on the gravity multiplier and the elapsed time .
  • The gravity causes speed, which implies that the points are added more often.

 

Obviously, user-side the only things to be told are to keep falling as smoothly as possible and try to avoid to stopping too often. It seems a complex system but it’s not and it adds a certain level of unpredictability for the player.

The health is the maximum gravity stop time

The game world:

  • leaves room to the player to do basically whatever he wants
  • it’s “analogic”: the actions are not sampled or fixed

 

I need a system to connect all the aspects (gravity, health, score) together. I started to think about something that can affect the gravity, the points and the gameplay as well, and I think to bring in the time, too. We can stop the gravity with all the effects on point multiplier discussed earlier. But for how long we can stop it? Well…for a time related to the remaining health of the player! When stopping the gravity, a bar shows the player that the time is decreasing. When the available time is zero the time it starts to load but the player can stop the gravity again only when the time reaches the maximum value (the remaining health). I came up with this idea pretty far in the development but it is something that connects everything and I developed it.

This kind of relationship between stop time and health holds up everything giving importance to every aspects of the gameplay.

For visualization I choose two overlaid bars. When the time is increasing or decreasing the player sees the above bar that scales down or up revealing the bottom bar that represents health. In the image you can see the bar that represents health (green) and the stop time bar (lime-yellow) when the time is decreasing.

Schermata 2016-07-10 alle 14.03.30

 

This covers pretty much everything on game logics and since this time was a lot talking, I decided to give something visual as well. These are the current versions of the game actors. I think they will be the final ones, more or less. You can see the color palette I decided to use too.

actorScreen

 

 

Game developer & designer. Unity 3D lover. Movie fanatic.

Steady Drop – Log #3

 

It’s been a while since the last devlog. I had some other projects to follow and a lot of stuff to do, but here I am. Let’s jump right into the subject: this post is about level design and my approach to level design in Steady Drop.

 

Level procedural creation

In this I started to think about full procedural generation where I put the rules into the algorithm and the level are generated with no manual level design at all. Sure, great approach, but I’ve found is not really suitable for what I wanted to do. Since the only level I have is potentially infinite I though more like a sequential loading.

Eventually I came out with a type of sequential loading where the level is loaded from basic parts that I call “slot”. The slots are loaded when needed progressively as long as the character falls down and are deleted/disabled when are offscreen because they are not usable anymore. The main operations of loading and deleting is shown in this code snippets below.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
public void spawnNext(float fallObjYOffset){
    if (fallObjYOffset > m_CurrentYOffset - 10) //if I'm almost there
    {
        //pick the right pool
        List<Env> currDiffEnvs = m_OrderedEnvs[m_CurrDiff.ToString()];
       
        //pick a random slot of the pool
        int eIndex;
        do{
            eIndex = Random.Range(0, currDiffEnvs.Count);
        } while(eIndex == m_LastIndex && currDiffEnvs.Count > 1);
        m_LastIndex = eIndex;
       
        //load the slot
        GameObject env = GameObject.Instantiate(currDiffEnvs[eIndex].gameObject,
                                                new Vector3(0f, -m_CurrentYOffset, -3f),
                                                Quaternion.identity) as GameObject;
        m_SpawnedObj.Add(env);
        env.transform.SetParent(transform);
        m_CurrentYOffset += envs[eIndex].offset;
        m_Spawns++;
    }
    if(m_Spawns == m_DiffSpawnSlot)
    {
        modifyDiff(1);
        m_Spawns = 0;
    }
    disableVeryFar(fallObjYOffset);
}

Basically, the slots are divided by difficulty in different pools and since the difficulty is progressively increased as the player goes down, a random slot are picked from a pool of the current difficultyIn this way each slot has to be independent from others and still give a sense of flow and continuity when put in a slot chain, so I had to find a easy method to create a set of separate slots that convey flow.

 

Level design

In the last couple of months I started to read about different techniques of level design along with image composition, functional level design, “level design has to serve the gameplay” and others best practices and tips on the matter.

Finally, I found that this approach on Gamasutra could be very suitable for what I was trying to achieve, and you will find references of it in the following explanation of my level design pipeline.

Basically what I’ve done are very simple few steps.

  1. Defining the component palette: all the enemies, obstacles and even the player.
  2. Divide a blank sheet on three and drawing a curved path on each part. This is my ideal falling path, my flow.
  3. Mark the points of the path that are on the center and draw a horizontal line. In this way the horizontal line delineate a slot.
  4. Populate every slot with components of my palette in a way that makes sense along with the curved line of the flow

In the slide-show you can find an example of what I’ve done.

ld0ld1ld2ld3

 

I chose to divide the vertical column when the flow pass through the center because in this way every slot has its flow starting and ending in the same area and they can be put in random order and still maintain a pretty consistent flowIn this way during the game, each slot can be randomly loaded as needed from a set of independent slots (like shown above).

 

 

I hope you liked this post :-). The next post I will explain the point system and the overall logic, stay tuned for more devlogs and other articles.

 

Game developer & designer. Unity 3D lover. Movie fanatic.

Blur effect shader

 

This is a post-process shader that I wrote to apply a simple blur effect on a video source on Panda3D engine. The related manager class (written in Python) adds more control and customizability to the shaders, but if you want, you could use just the plain shaders. I used GLSL and the shaders are supported on most of the existing graphics cards. Follow the link down below and happy blurring! 🙂

Blur on Gist

 

Game developer & designer. Unity 3D lover. Movie fanatic.

Texture2D Extension

 

Recently I had to work on Unity with Texture2D taken from a camera and for some reasons they came out flipped in strange ways. So, I had the need to rotate or flip the textures and I realized that Unity doesn’t have this function ready to use.

This is Texture2DExtensions (here). As the name suggest is a little tool made for resizing, cropping, mirroring and flipping Unity’s Texture2D. It uses basics algorithms to iterate through the textures and set the right pixels.

You can use it right away into your projects to manipulate any Texture2D you want 🙂 Keep in mind though that It’s a little heavy computationally speaking so, don’t use it to manipulate in the update cycle.

Texture2DExtensions on Gist

 

Game developer & designer. Unity 3D lover. Movie fanatic.

Steady Drop – Log #2

Improvements

In the last post (here) I forgot to mention that the inputs of the game are both the gyroscope and the touch screen: by holding the finger on the screen you can stop the gravity force.
I have to make a short document with a more detailed description of the game. I will post it soon.

In the last few weeks I converted all the logic of the game to be strictly 2D. Before I had some legacy of a 3D prototype that I made for the initial tests. I had to convert Rigidbodies, Colliders and stuff to the 2D version of the components. No big deal.

Beside that, I created a state machine that goes through the game states (like pause, loose, play, etc…) with a menu system that can load a menu based on the state of the game. I have to refine the transitions a bit and it’s perfect 🙂

Component pallette

I’m also working on creating my pallette of components that will compose the levels on two different layers: design aspects on one hand and graphics style on the other.

Desing & technical
Currently I have:

  • the player: the object that is falling down (triangle).
  • a wall: an obstacle that cause immediate death to the player if the player touch it (square).
  • a gravity magnet: it can pull towards or push away the character while is falling (circle).

Every object can move around or not, for example we can have movable walls. I’m planning to have a discontinuous laser and a pendulum object.

Graphics style
Here some examples of the concepts so far

steady drop actors

Once I have a concept and behaviour that I like for every component I will start to create some levels for testing the overall result. [SPOILER] The next post will be on level design 😛

Game developer & designer. Unity 3D lover. Movie fanatic.

Unity 5 – Custom Event System

The Unity built-in event system is good for simple stuff and basic message sending. But when it comes to sending complex data or deactivate listeners it doesn’t fit well for that.

If you want a more customizable system you could use my event system:

EventNotification

I developed it (in C#) starting from the following class, than I extended it to satisfy my needs:

NotificationCenter

This event system allows you to define a specific event class (with all the benefits of encapsulated data), to add and remove listeners from a specific event and to define a callback for that event.

It’s safer than the Unity standard system, since it uses a delegate (like a function pointer) to specify callbacks, instead of strings (typo unsafe). It also uses the class name to differentiate events, and a listener has to use the type of the event to which it wants to react.

Use it freely on your projects. Happy coding!

Game developer & designer. Unity 3D lover. Movie fanatic.

Steady Drop – Log #1

This is the first post of Steady Drop dev log. I’m going to start this dev log maybe a little too late (my bad), but I’m going to do a recap. First of all, what is Steady Drop? Steady Drop is a 2D game about controlling the gravity by tilting your mobile device while, your character is falling down.

Starting development

The development started in summer 2015 when I had the idea that the input on a mobile phone can be given in several different ways other than the classic input methods (swipe and tap). At the time I choose the gyroscope to be the main input that served the gameplay and I imagined  a game that could satisfy this paradigm. So I grabbed my sketchbook and after some sketching session and I came up with a falling game. (Only recently I realize that Ridicolous Fishing has similar inputs, but the gameplay is pretty different). Then I passed into Unity 5 and started the development.I had the vision of the game pretty fixed in my head, so the first couple of weeks I worked on to get the input controls right. The gyroscope attribute is very easily achievable in Unity without requiring any native plugin for the devices, so I used that to create a first prototype and I was pretty happy about it.Then I thought about structure of the game, level organization, menus and so on. I came up with something similar to Cut the rope 2 or Two Dots in term of level selection but with down scrolling (since is a falling game). I started to develop the architecture for the game actors and all the managers and the level handling. At the time I was thinking of a playful graphic style and some themes for level groups (like space, sky with clouds, ground and underground. I was planning to release the themes on regular time spans. I also studied  the character design and a little bit of the game plot placed in a believable world and environment.

Change of direction

To make it short, I was planning to add a lot of things (maybe more) and after a period of time where the things was stalling, I decided to cut the fat of the project and resize it a bit. Instead of having multiple levels I choose  one infinite level. Also because a continuous fall divided into levels maybe was not a great design idea. I also redesigned the graphic style choosing a more minimalistic style with flat 2D shapes and no themes at all. So I had to go through some refactoring sessions to change direction and to get to the point where I am now. I regret a little bit this change of direction but without it the project would fail.

Current state

I’m currently working on the visual style and on the tools to make the things looking good on different screen resolution. I’m thinking of using svg format for images and I found this plugin on the assets store, I will try it out soon. I’m also planning to integrate an analytics framework and a life system based on how many add you watch (like Threes game), we’ll see. Since is a side project, I’m working on it in the spare time, so be gentle with me if it’s taking me a lot of time to finish. I will post other previous and present development stuff in future posts. Stay tuned!

Game developer & designer. Unity 3D lover. Movie fanatic.