As I’m really bad at self-promotion, I don’t think these projects reached too many people. That’s why I decided to compile this list to make them more discoverable.
Note: Some of these samples were created in older Godot versions and may not be working anymore. Let me know if you find something broken and I might find some time to fix it.
https://github.com/viniciusgerevini/godot-aseprite-wizard
This is by far my most popular and useful project. Aseprite Wizard helps to import animations from Aseprite to Godot. It supports AnimatedSprite, AnimationPlayer and SpriteFrames. The video above is slightly outdated when it comes to configuration, but the usage is pretty much the same.
https://github.com/viniciusgerevini/godot-clyde-dialogue
Clyde is a language I created to allow me to write my game dialogues more simply. Stop the JSON file madness!!!
It’s supposed to be closer to normal writing and it supports branching dialogues, translations and interfacing with the game through variables and events.
This plugin adds an importer so you can load .clyde files directly, and also exposes the interpreter as ClydeDialogue.
In the video above, I quickly go through the main features. I’ve got feedback that the video was a little bit rushed, so I’m intending to create a better tutorial which covers even the interface part.
https://github.com/viniciusgerevini/godot-behavior-tree-example
This is pretty close to the Behaviour Tree implementation I use in my own game. My idea here was to foster Godot’s node tree structure to implement my behaviour tree, without needing extra visual tools.
This boilerplate is in fact a plugin that adds some custom nodes that can be used to build your tree. There are also some examples included showing the trees in action.
The video above is a simple introduction to behaviour trees and how I implemented them in Godot.
https://github.com/viniciusgerevini/godot-goap
Following the AI subject, this was an experiment I made building my own Goal Oriented Action Planner. I wanted to validate this AI pattern because I felt most of the examples I found online were incomplete or not realistic.
As opposed to the behaviour tree sample, this is not battle-tested, so you probably should not use it as is. The video above works as an intro to GOAP, but keep in mind my experience with it is limited to experiments only.
https://github.com/viniciusgerevini/godot-color-replacement-example
This example includes 3 different ways to change colours in an image. Using shaders, the modulate property and changing the pixel colour directly. This came from a real use case where I needed to change the skin colours of characters in my game. The shader method is what I use currently.
The video goes through the three methods and the pros and cons of each one.
https://github.com/viniciusgerevini/godot-boids
Boids is an artificial life program, developed by Craig Reynolds in 1986, which simulates the flocking behaviour of birds.
This is a simple and naive Boids implementation. It does not include collision avoidance and other fancy features, but I know it works as this is exactly the code I use in my game.
The video talk about the 3 simple rules that make it work and how I implemented them.
https://github.com/viniciusgerevini/godot-navigation-2d-example
This example is kind of outdated now that Godot 3.5 includes the new and improved Navigation Server. However, if you are curious about how I implemented pathfinding for a 2D Platformer and the challenges I faced, you might want to take a look at the video above.
I hope you found something useful on this list. Please, if you have any interesting topic or subject, let me know in the comments. I’m always looking for new ideas.
If you like this kind of stuff, you might want to consider subscribing to my Youtube channel. The channel is mostly focused on my projects, but I try to balance it with tutorials and other things.
For latest updates, messages or comments, I'm on Twitter as @vini_gerevini.
You can also support me by wishlisting my game, Far Star, on Steam.
]]>Every time I have the chance, I like to give back to the community. Most of the software I use in the day-to-day is open source. As I don't have enough time or energy to contribute to these open source projects, every time I have the chance I squeeze in an update to the projects I maintain, release some useful sample or tutorial that might help others.

My year started with a pull request fixing and improving Aseprite Wizard, a plugin I created for Godot to help import animations from Aseprite to the game engine.
This plugin started as a bash script, which I realised could be useful for other people. So I translated it to Godot’s GDScript and released it as an editor plugin. Since then, I received positive feedback from the community, many suggestions and bug fixing contributions.
This week I'm going to release a new version that supports a more powerful animation node, a feature that was asked a few times in the past.

Also related to open source projects, back in January, I released the first version of Clyde, a scripting language I developed for creating game dialogues.
Besides the language specs, I created a parser and an interpreter in Javascript, also a CLI tool for executing Clyde files and an online editor for people to test the language. By the end of the month, I also released a plugin for Godot, with a native parser, interpreter and importer in GDScript, so I could use the language in my own game.
I also played around developing syntax support for VSCode and Vim. This was a fun project, as I was able to play around with language lexers, parsers and interpreters. Something I haven’t looked into since my times at Uni.

In 2021, I also resumed my project of creating my own mechanical keyboard. This was a split keyboard using some Gatheron Brown switches, a Bluefruit Feather and a Pro Micro. Instead of creating a PCB, I wired the switches manually.
After soldering everything and spending some weeks playing around with C and Arduino board deployment issues, I managed to make it work.
It did work, but it was far from being good. Some bugs with layers and at the end, that Frankenstein felt a little bit too weird to type. Mission accomplished anyway.

My main side project and hobby is Game Development. I’m currently working on my first game called Far Star. In 2020, I started a Youtube channel to log my progress, and I kept doing it in 2021.
In 2021, The Far Star repository received 571 commits across 195 days. This doesn’t say much, as the size of my commits vary depending on what I’m working on, and also when working on animations, sounds and other assets I usually don’t commit often.
When it comes to Youtube, I released 14 videos in 2021. Mostly dev logs, but I also released a few tutorials with subjects such as Behaviour Trees, Goal Oriented Action Planning, Boids and color replacement. In my github you can find a bunch of sample projects I used for my videos.
When it comes to subscribers, my channel reached 600 subscribers after one year alive. That’s not much for youtube standards, but I’m happy with the result anyway, as I never actively promoted my videos anywhere, besides eventually posting on my Twitter account, which only contains a handful of people.
Well, I don’t talk about work in my personal stuff, and also I don’t think I can share externally details on what I work on during the day. It's not top-secret, it's just that I don't want to spend cognitive energy thinking on what may be under NDA.
I’m a Software Developer, so what I can say is that I worked on a bunch of projects related to scaling and performance. I had the chance to lead a few projects, code a little bit and be paged overnight for some wrong metric we setup. he he.

Well, that's not really the focus of these posts, but thanks for asking. My plants grew like crazy, I spent most of the time in lockdowns because of the current thingy happening with the world and I completed a few series and games (mostly indies, but I did complete everything on Metroid Prime and Jedi Fallen Order).
Yep, I think this pretty much sums up the highlights of the year. Hopefully, I get the motivation to share things more often here this year. If I don't, see you in the 2022 review :D.
]]>I managed to make it 10 minutes long, but to be honest I'm not satisfied with how it turned. Here in this post, I'll try to summarise the topics covered in the video and hopefully, they will be clearer and easier to understand.
Behavior Tree is a common pattern used on game AIs. It makes it possible to create complex behaviors by using smaller, independent tasks.
To understand how Behavior Trees work, we need to talk about the different elements that compose a Behavior Tree.
For my examples, I'll be using GDScript, the default language in Godot. It was inspired by Python, but even if you are not familiar with it, having a basic programming knowledge is enough to understand the examples.
With exception of the root node, nodes in a behavior tree have a common contract. A node may return one of the following states: running if its execution has not finished in the current call, success if it has achieved its goal, or failure otherwise.
In my implementation, nodes also have a tick method. This method is called by the node's parent and receives two arguments: an actor, which is the element which the behavior is applied to, and a blackboard, which is a type of dictionary where data may be stored for later use.
Behavior Tree's implementation and naming may change wildly, but I will stick with a simple implementation, to make things easier to understand.
# task node pseudo implementation
func tick(actor, blackboard):
if actor.attack(blackboard.get("target")):
return SUCCESS
return FAILURE
The root node is responsible for controlling the execution of the behavior tree. It has only one child and calls it with a certain frequency.
Here is an example of implementation for a root node:
# root node example
onready var blackboard = Blackboard.new()
onready var child = self.get_child(0)
onready var actor = get_parent()
func _process(delta):
blackboard.set("delta", delta)
child.tick(actor, blackboard)
Let me clarify a few details from the example above.
If you are used to game development, you already know about something called the game loop. Most game engines expose a function which is called on each loop, so you can implement your game logic in it. Godot calls it _process, (there is also a _physics_process method, but this is not important for this subject). As my root node uses the _process function, it guarantees that the tree will be executed once every loop.
This function receives an argument, called delta. This is the time elapsed since the last time this function was executed. This is useful for calculations in general. For convenience, I'm adding the delta value to the blackboard, so other nodes can use it if needed.
This implementation also assumes that the Behavior Tree is a child of the actor, as you can see on line 4.
Finally, on line 8, it calls its child, passing the actor and the blackboard.

Control flow nodes are the branches of the tree. They are used to control which tasks should be executed. The two most common implementations are sequences and selectors.
A sequence executes its children one by one, in order. In case one of its children returns failure or running, it stops the execution and returns the same status. If all of its children succeed, it returns success.
# sequence composite example
func tick(actor, blackboard):
for c in get_children():
var response = c.tick(actor, blackboard)
if response != SUCCESS:
return response
return SUCCESS
A selector also executes its children one by one, in order. However, it stops when one of its children returns success or running. In case a child returns failure, it tries the next one. Only when all children return failure, it will fail.
# selector composite example
func tick(actor, blackboard):
for c in get_children():
var response = c.tick(actor, blackboard)
if response != FAILURE:
return response
return FAILURE

Execution nodes are where your custom logic is implemented. They are also called leaf nodes because they are located on the edges of the tree. In other words, leaf nodes do not have child nodes.
Your leaf node could implement an action, such as "attack", "move" and "jump", or a condition, such as "has low health", "is enemy" or "is in attack range".
# leaf node example: go to position
func tick(actor, blackboard):
var target_position = blackboard.get("target_position")
var delta = blackboard.get("delta")
actor.move_towards_position(target_position, delta)
if actor.position.distance_to(target_position) > 0:
return RUNNING
return SUCCESS
The example above implements an action to move the actor to a predefined position. The movement implementation is abstracted in the method move_towards_position. Assume this method does some kind of linear interpolation.
Because this kind of action is usually not finished in only one tick, we check if the actor has reached the target and, in case it has not, we return running, otherwise we return success.

The decorator pattern is a common design pattern in object-oriented programming. It allows behavior to be added to objects dynamically, without changing their class. Decorator nodes do the same thing for nodes. They may add extra checks before executing a node or changing its output after execution. Let me show you examples for these two cases.
Example 1: changing the output
The inverter decorator inverts the output of its child. This way success becomes failure, and failure becomes success. This makes nodes more reusable.
Imagine a situation where you have an enemy with an attack cooldown period. It attacks the player if not in cooldown, and when in cooldown, it runs away. Instead of implementing two different scripts for the leaf nodes, "is in cooldown" and "is not in cooldown", you can use the same script, only adding an inverter decorator to the condition when needed.
# Inverter decorator
func tick(action, blackboard):
var child = self.get_child(0)
var response = child.tick(action, blackboard)
if response == SUCCESS:
return FAILURE
if response == FAILURE:
return SUCCESS
return RUNNING
Example 2: adding input behavior
A limiter decorator adds a limit on how many times a node can be called. It keeps track of how many times the node was executed, and in case the predefined limit is reached, it stops passing calls to the child node, and returns failure on every subsequent call.
Let's say you are implementing a fighting game. In this game there is a character with an over-powered attack, that should be executed at most once in a fight. For that, you could add a limiter decorator to the branch that deals with the over-powered attack logic. This way, even if the tree calls this branch multiple times, it will only succeed once.
onready var cache_key = 'limiter_%s' % self.get_instance_id()
export (float) var max_count = 0
func tick(actor, blackboard):
var current_count = blackboard.get(cache_key)
if current_count == null:
current_count = 0
if current_count <= max_count:
blackboard.set(cache_key, current_count + 1)
return self.get_child(0).tick(actor, blackboard)
else:
return FAILED
In my example, for convenience, I'm saving the execution count in the blackboard. Another thing to note, is that max_count is defined through a parameter, 0 is its default value.
Most game engines have some built-in or community developed Behavior Tree implementation. Godot has at least one community developed one, that I know, with a drag-and-drop interface. I haven't used it myself, so I can't really recommend it.
Godot's architecture was built around the concept of a tree of "nodes", which makes it easy to create Behavior Trees without requiring any extra plugin.
Here is an example of tree using Godot nodes (these node icons are custom images I added to the project).

And here is an example showing how easy is to change node's parameters through Godot's editor.

I created this example to show how to implement a Behavior Tree in Godot. In my example, there is a behavior tree for an actor that follows the mouse, when close enough, and in case the mouse is too far, it goes to the closest "home". As a third branch, the actor changes its colour when reaches home for the first time.
In case you are interested in the step-by-step implementation, check the video in the beginning of this blog post.
If you decide to implement a behavior tree yourself, there are a few tips you may want to follow:
Keeping state inside nodes makes them less reusable. Always keep in mind other nodes may want to use the info stored. Also, you can't guarantee a node will be called on every tick, so internal data could get stale.
If you need to save or share data, save it in the blackboard.
In this post, most of my examples have blackboard keys embbeded in the script, like the "go to position" action:
func tick(actor, blackboard):
var target_position = blackboard.get("target_position")
var delta = blackboard.get("delta")
actor.move_towards_position(target_position, delta)
if actor.position.distance_to(target_position) > 0:
return RUNNING
return SUCCESS
This is not a good idea, as it means you will only be able to use this node with data from "target_position", and, in some situations, you may have issues where different nodes overwrite the same blackboard key.
Instead, you should export your key as a parameter, like this:
export (String) var target_key
func tick(actor, blackboard):
var target_position = blackboard.get(target_key)
var delta = blackboard.get("delta")
actor.move_towards_position(target_position, delta)
if actor.position.distance_to(target_position) > 0:
return RUNNING
return SUCCESS
For instance, even though your action may say "go to position", it doesn't need to know how your actor moves around.
Your actor may choose to implement movement like this:
position += position.direction_to(target_position) * delta
Or maybe this way:
self.position = Vector2(
lerp(self.position.x, target_position.x, delta),
lerp(self.position.y, target_position.y, delta)
)
Either way, this should be abstracted into a method, and the action node should use the high-level method, instead of re-implementing it itself. This makes your "go to position" node more reusable, as it can be used by different actors, only requiring them to expose an implementation for the high-level method.
As an improvement, you could use types in your implementation. This way, you make sure your actor implements the methods required by your action.
func tick(actor: Character, blackboard: Blackboard):
# ...
Using an example from the video, you could implement an action "follow mouse cursor". This action would:
This node is very specific, making it less reusable and harder to change. What if I want to add a maximum time for how long the NPC should follow the mouse? Or what if I decide to implement some kind of cooldown period?
Any change would require making this node even more complex. To prevent that, you should have small nodes with clear responsibilities.
Each bullet point in that list could be a node by itself. In fact, this is the end result in my example.
Even though smaller, generic nodes are more reusable, it's harder to start like this.
It's easier to start with a very specific implementation, and then generalise it when more scenarios appear, and you can see the similarities.
This is actually a piece of advice also applied to general programming, known as Rule of three.
As I mentioned before, you should abstract details about your actor from your behavior tree. There are many things you don't need to have explicit in your behavior tree.
As an example, if when moving to position you want to play a "walking animation", this should be made internally in your actor, and not like a node "play animation".
In my example, I ended with a tree, like this:

But maybe this tree could be better represented like this:

Both trees achieve the same result, but they do it in different ways. Feel free to move nodes around if it makes your tree clearer.
It's good to give your nodes descriptive names, even though you may be using generic scripts. This makes it easier to understand what your behavior tree is doing.
A tree path:
sequence > load mouse position > is target nearby > go to position
is harder to understand than:
sequence: follow mouse > load mouse position > is mouse cursor nearby > go to the current mouse position.
I hope this text may have helped you understand a little bit more about behavior trees. Even if you decide to use an off-the-shelf solution, it's important to understand how it works under the hood.
As I said before, this is a very naive and simple implementation. There are probably more robust and performant implementations out there.
Having said that, this is how I implement behavior trees in my game, and it has worked well so far.
You can download and fork my example from github.
If you like game devlogs, you may consider subscribing to my Youtube channel.
Thanks for reading. Comments, suggestions and feedback are always welcome.
See you! Stay safe!
]]>It's called Far Star. This is the first one. I hope you enjoy.
If you like it and want to keep getting updates, consider subscribing to the channel.
Thanks.
]]>TL/DR
As a way to brush up my skills, I decided to experiment creating a simple "Google Keep"-like note-taking app in ReactJS. However, while building it, I couldn't find a grid library with the features I wanted and that would work well with ReactJS.
What I was looking for was:
I decided to create this example for anyone who is looking for something similar. Feel free to fork it and change it as you see fit.
For the grid part, I found this pure CSS/JS implementation that works just fine. It uses CSS Grid for the responsive layout and JavaScript for adjusting how many rows an item should occupy.
To see my ReactJS adapted grid implementation using hooks, check the grid folder in the source code.
For the Drag and Drop implementation, I use a library called react-dnd. It provides the foundation and utilities for implementing Drag and Drop. I adapted their sortable example to be used in a grid.
You can see my implementation in the dnd folder.
To keep it simple, I handle items' order as a list, instead of a matrix, as people usually do for grids. This makes sorting easier and allows the grid to be responsive, as items can change rows without having to be sorted again.
You can check the source code for tests and comments that explain a little bit more about the implementation.
There are a few improvements that can be made in my example.
First of all, when dragging an element in a touch-enabled device there is no preview (ghost) element. This is due to the Touch Drag and Drop API not supporting it. There are ways to work around it by using the react-dnd-preview plugin, which allows you to define a custom ghost item while dragging.
Another possible improvement is to use react-dnd-test-backend in unit tests for testing drag and drop behaviour. As I decided to not eject from create-react-app, to keep this example as simple as possible, I was not able to wire the test backend to my application. In a real project, I suggest using this test backend, as it provides many utilities and simplifies testing those components.
If you want to learn more about CSS grids, I recommend this awesome guide by CSS Tricks.
Check the source code for more information.
Feel free to reach to me if you have any questions. See you!
]]>This problem is even more accentuated on a pair programming rotation with many teammates and many different setups. Some teams try to mitigate this issue by coming up with standards and default mappings, however, even though this can be an effective approach, it also sacrifices flexibility and it may undermine organic configuration improvements.
In my setup, I follow a few rules that help me keep my configuration flexible and approachable. They may be handy and give you some ideas on what can be improved to make your (and your team's) life easier.
Before creating a new mapping or installing a new plugin, search for how to do the same task using VIM's default commands. You'll be surprised by how many things can be easily accomplished using what comes out-of-the-box.
By doing this you may get two benefits: You'll be able to work when using a vanilla VIM configuration and you will avoid bloating VIM with unnecessary mappings and plugins.
My rule of thumb is: I only use a mapping or plugin if the command is too complex to remember. Everything else I prefer to keep as it comes.
Every time you are pairing on someone's else machine, which does not have the same mappings you have, you can rely on the default commands to accomplish the job. Well, as long as they are still available.
I've seen many people overriding default mappings with their preferences and even plugins suggesting mappings that conflict with VIM defaults. For someone trying to use your editor, this can become annoying and frustrating very quickly.
As a good teammate, you should keep the defaults working just fine so other people have a fallback in case they are not used to your mappings. Replacing a few silly mappings is fine, but changing some important navigation command is mean.
A good way to keep your configuration simple and avoid collisions is to set mappings only for commands you use frequently or require quick access.
When setting up a new mapping think on how often you are going to use it. There is a chance you will never need it or when the time comes you'd have forgotten what it does.
Every person has a preferred workflow. I don't like to use tabs and I use mainly ctrlP to navigate between buffers. A friend of mine, on the other hand, uses mainly tabs. He uses them like an accordion, expanding and collapsing as needed.
When starting a pairing session we usually define how we are going to work. If both can use their preferred approach without messing with the others, fine. If not, choose the simplest one. It's also worth to try other people's workflow, as you may end improving yours or even enjoying the new way.
Maybe this one is not related to pairing, but it does help to share knowledge and avoid forgetting "why the heck is this configuration here". I usually add comments explaining what a plugin does or why I use a given configuration.
Your future self will thank you when reading your documented configuration.
In summary:
Keeping your configuration sane and accessible helps your pairing mates to have the same joy and speed you have when using your setup. Also, make sure you share your good practices, so people can learn from them.
Photo by Kevia Tan on Unsplash
]]>It's nice to work with TS as it makes debugging, inspecting and making sense of the codebase easier. However, it may give us a false sense of safety by making us forget that the type system only works until transpilation.
Consider the following example:
type Response = {
category: {
description: string
}
};
// [ ... ]
const request = await fetch(...);
const response = (await request.json()) as Response;
// [ ... ]
// category is undefined
return response.category.description
In this example, we are assuming our request will return a type Response, which contains a mandatory property category with description. As this property is mandatory, accessing response.category.description should be safe, as category should never be undefined. However, we can't guarantee this will be always true as it's coming from an external source.
Other typed languages, like Rust and Java, force us to handle those scenarios upfront, either by defining exception paths, default values or by explicitly assuming the risk of parsing issues. TypeScript chooses to trust the developer instead. Because of that, if we don't add proper input validation a bad input could go down many levels before it "explodes", making spotting issues very hard.
I've seen at least two issues caused by bad input validation since I started working with TS. Since then, I've been treating TypeScript types as a hint for developers during development, and not as a full-blown type system.
All things considered, working with TypeScript has been very satisfying, and I recommend giving it a chance. :)
]]>The only way to move a Rigid body is by applying forces to it, such as impulse, torque, gravity and friction. The physics engine is responsible to calculate the resulting movement and its new position. This makes the movement more realistic, but also harder to control.
As an example, if a body is moving to left, in order to make it go right you need to apply an impulse in the reverse direction. However, before moving to the new direction the body will first deaccelerate to a stop. This may look realistic, but for a user-controlled object, it could be frustrating as controls won't feel as responsive as they should.
Kinematic bodies, on the other hand, are not affected by physics. This gives you freedom two do whatever you want, with the downside of having to implement everything manually. For most games, this is not an issue at all, as probably they would require a simplified and sometimes crooked version of physics.
Rigid bodies are always detecting collisions and notifying it through signals. For instance, every time a body touches a RigidBody it emits a body_entered signal, and a body_exited when the contact stops. This makes the implementation easier as you know those signals will be triggered on every contact.
In contrast, Kinematic bodies do not notify collisions unless a movement is made. When moving it, you need to check if a collision happened either by moving it using move_and_collide or calling get_slide_collision afterwards. Because of that, you will have to design your code in a way it can handle scenarios where your node is being hit while stopped.
Rigid bodies are usually used in 3D games or games that require realistic physics simulation. Kinematic bodies are mostly used in 2D games and user-controlled bodies. Your necessities will define which one fits best your game.
Leave a comment if you have something to add or suggest. Thanks.
Documentation: Kinematic Body: 2D, 3D | Rigid Body: 2D, 3D
Post image from Godot Docs
]]>If you are not interested in hearing about this tool, here is a simple command that does the job:
ffmpeg -i [input video] -f gif - | gifsicle --optimize=3 > [output gif]
However, if like me, you don't like to install random libraries and their dependencies in your main system, or maybe you just find this command too hard to remember, keep reading and I will tell you a bit more about it.
Those are all the options available in video2gif:
video2gif [OPTIONS] [input file]
-s, --size size. e.g 600x400. Default: same as video size
-o, --output output file name. Default: [input].gif.
-i, --input input file.
-ts, --start-time time position from video to start gif. Seconds or HH:mm:ss. Default: start of the video
-te, --end-time time position from video to stop gif. Seconds or HH:mm:ss. Default: end of the video
-d, --gif-frame-duration delay/duration of each Gif frame in hundredths of a second. Default: 3.
-fr, --video-frame-rate video frame rate. Less frames generate smaller gifs. Used by ffmpeg. Default: 10.
-h, --help print help message.
-v, --version print version.
Everything you do with video2gif you can do with ffmpeg and gifsicle. Because of that, I will show you how to use both commands, so you don't need to download my tool if you don't want to.
video2gif
video2gif -s 600x400 input.mpeg
ffmpeg + gifsicle
ffmpeg -i input.mpeg -s 600x400 -f gif - | gifsicle --optimize=3 > output.gif
video2gif
video2gif -ts 1:05 input.mpeg
ffmpeg + gifsicle
ffmpeg -ss 1:05 -i input.mpeg -f gif - | gifsicle --optimize=3 > output.gif
Note: -ss needs to come before -i, otherwise it won't work.
video2gif
video2gif -te 3:00 input.mpeg
ffmpeg + gifsicle
ffmpeg -to 3:00 -i input.mpeg -f gif - | gifsicle --optimize=3 > output.gif
Note: as in the previous example, argument position matters.
Duration is defined by hundredths of a second, so 3 is equivalent to 0.03 second.
video2gif
video2gif -d 3 input.mpeg
ffmpeg + gifsicle
ffmpeg -i input.mpeg -f gif - | gifsicle --optimize=3 --delay 3 > output.gif
Fewer frames generate smaller gifs, with the expense of making it choppier.
video2gif
video2gif -fr 10 input.mpeg
ffmpeg + gifsicle
ffmpeg -i input.mpeg -r 10 -f gif - | gifsicle --optimize=3 > output.gif
video2gif
video2gif -ts 10 -te 1:10 -s 400x200 -d 3 -fr 10 input.mpeg
ffmpeg + gifsicle
ffmpeg -ss 10 -to 1:10 -i input.mpeg -s 400x200 -r 10 -f gif - | gifsicle --optimize=3 -d 3 > output.gif
As you can see, it is not that hard to use ffmpeg+gifsicle, however, if you do this conversion frequently you may consider using my script.
I hope it was useful. To know more about how it works, you can check the repository.
]]>Coc is a completion framework and a language server client. It's fast, responsive and provide full LSP support. I've been using it for a little more than a month and I'm really impressed by its performance.
The only downside I can see so far is the number of dependencies required. Coc requires Node and Yarn to work, besides those I had to install a Neovim python dependency and if you are using Vim it requires a vim-node-rpc plugin as well. In general I don't like plugins with too many external dependencies, however I feel this time it worths the hassle.
Here are some examples of Coc in action:
Completion
The completion prompt has been really fast and responsive so far.
Go to definition

Show references
Preview pane on references list is very useful.
Rename
I was able to rename variables/methods (and their references) effectively, even in JavaScript.
Show buffer's issues in a list

Check the project repository for a more detailed explanation about the tool as well as some configuration examples.
]]>There is nothing wrong enjoying to work with one specific programming language and specializing in it. The problem is when you start looking down to other technologies and close yourself to alternatives.
Every language has a strong and a weak suit. If you rely on one single language you will be bounded by its weaknesses. "If all you have is a hammer, everything looks like a nail."
Learning a new language may bring challenges, but it also brings a new ecosystem with different patterns, structures and techniques. A good example to think about is how different languages deal with same situations such as asynchronicity, IO, mutability, concurrence, parallelism and persistence.
But can you be a good programmer not focusing in one single language? Sure. However in the end all boils down to one word: balance.
Understanding deeply how one specific language works is as important as knowing how to code in different languages. First you focus, then you expand.
With time every interface bureaucrat recognise the benefits of dynamic languages and every duck typing hippie admits the power of strongly typed languages.
Thanks for reading. I know this subject can have many branches, but for now I'm just leaving this simple thought. Comments and suggestions are welcome.
Photo by Rock'n Roll Monkey on Unsplash
]]>Just recently I found out that ALE allows you to use features like "Go to definition", "Find usages" and completion suggestions using the power of LSP (Language Server Protocol) linters.
I've been using it for Rust and JavaScript and it has been working better than CTAGs ever worked for me.
Here are some examples:
Autocompletion:

Go to definition:
After installing ALE the only required configuration for enabling autocompletion hijacking is let g:ale_completion_enabled = 1.
For Rust you need to install RLS (Rust Language Server). The catch here is that ALE uses Rust Nightly by default. You can choose between installing RLS in the nightly toolchain or change ALE configuration to use stable instead.
For JavaScript I installed typescript globally (npm install -g typescript). It comes with tsserver included, which is the default engine in ALE for JS.
There may be other plugins powered by LSP's that provide same features, but as ALE was something that I was already using and it was so easy to configure I didn't want to spend time looking for alternatives.
Take a look on my VIM dotfile for configuration details.
Suggestions and questions are welcome! :D
]]>Before building this page I had created a stream that sends Queen's Bohemian Rhapsody lyrics as messages.
Those messages are sent obeying the time they would appear in the song. What this means is if you press play when the first verse is received you are able to listen to the song synced with the lyrics.
http://playground.thisisvini.com/bohemian-rhapsody-event-stream

I intend to publish both server and client's source code as soon I have time for this.
The server was made using NodeJS (I need to improve it a little bit).
The client uses the native implementation of EventSource to consume the stream. This is how it looks like:
const eventSource = new EventSource(STREAM_URL)
eventSource.onmessage = (message) => {
container.innerHTML = message.data
}
eventSource.onerror = (error) => {
container.innerHTML = 'Sorry! Something went wrong with the stream'
}
eventSource.addEventListener('started', (e) => {
status.innerHTML = 'Playing...'
})
eventSource.addEventListener('stopped', (e) => {
status.innerHTML = 'Stopped'
})
This is a minimum implementation for testing the stream.
event field defined.started. Every time a started is received the label in the bottom right corner of the page is changed to "Playing…". The same principle applies for the next listener.This is how the raw stream looks like:

To avoid complications I decided to set some limits to this stream:
I don't think usage will ever get close to those numbers.
Server-Sent Events is supported by most of the browsers.
In case you need support for other/older browsers you can use this polyfill.
If you want to dig a little bit more in Server-Sent Events maybe this post could be of your interest.
SSE doesn't rely on any new technology. Instead, it uses features already existent on HTTP.
This is an example of how an event-stream response looks like:
HTTP/1.1 200 OK
Content-Type: text/event-stream
Cache-Control: no-cache
Connection: keep-alive
Transfer-Encoding: chunked
: Welcome! this is a comment.
id: 1535462271572
data: my first message!
id: 1535462271572
data: another message
event: my_event
[...]
In a event stream all information is sent as plain text in UTF-8. Each event is separated by an empty line and each line defines a field. The standard describes how clients should react to those messages and how to parse them. This is made through an interface named EventSource, which looks like this:
// JavaScript
const eventSource = new EventSource('http://stream/sub');
eventSource.onmessage = function(e) {
console.log(e.data);
};
eventSource.addEventListener('my_event', function(e) {
console.log(e.data);
});
After the first handshake no messages are sent from client to server, only the other way around. This means event streams provide one-way communication where the server talks and all clients listen.
Every client receive the same data in the same order. When a new client connects, it receives all the messages sent in the stream before it's connection.
In case of failure, the standard describes a way for clients to retrieve the stream starting from the last event received. The standard doesn't cover questions like message expiration or limits. It's up to the server to handle those questions.
Those are just some highlights. The standard contains a lot more about how to handle reconnections, redirects, failures and messages.
As I said before, SSE relies on features already existent in the HTTP implementation. Let's check how they are used.
In order to easily explain how SSE works let's remember, in a simplified way, how a normal HTTP request flow works.
Let's say you want to access the resource https://thisisvini.com/about/. This is what happens between your client/browser and the server:
As the server is listening to incoming connections when the client contacts it a TCP socket is opened between them. After the connection is established the following conversation happens:
Client:
GET /about/ HTTP/1.1
Host: thisisvini.com
Accept: */*
"Yo! Could you give me the resource
/about. By the way, I know how to communicate using HTTP/1.1, and to be honest, I don't really care about the type of the content you'll send me."
Server:
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 7915
<html>...
"Sure thing! I can do that. I'll send you HTML. Here it is […] See you later"
The content is streamed to the client in chunks of data. After all the content is transmitted the socket is closed by the server and this polite conversation is over.
As we can see, TCP and HTTP already allow us to send chuncked data and keep a stream open between server and client. The missing part was defining a standardised way for servers and clients to deal with communication through a long-lived stream.
The only real difference between the previous flow and an event stream is that instead of closing the connection, the server would keep it open sending new chunks of data when necessary.
Obviously there are more details and bureaucracy in this conversation. You can check the living standard for more details.

If you want to see a real stream working you can curl my Bohemian Rhapsody stream with the following command:
curl -i -k -H "Accept: text/event-stream" http://playground.thisisvini.com/bohemian-rhapsody-event-stream
This stream sends messages in sync with Bohemian Rhapsody song. Just press play when the [START] message is received and sing together. :P
I recently implemented a SSE-Client in Rust for a side project. This library is fully functional, following the living standard and even implementing an exponential back off for reconnections. Source code Documentation
SSE is really good for sending live data and broadcasting updates for many clients.
Things to keep in mind:
That's all for now. Thanks for reading.
If you have something to add, questions or suggestions don't exitate to contact me.
]]>Although I've never released a game before, I did experiment with other engines and technologies along the years. That's why I decided to summarise here my point of view of Godot's pros and cons and why I chose it over other options available.
Unfortunately I can just talk about the 2D part of Godot, as I haven't really tried the 3D engine. You can read more about Godot features here.
Everything in Godot is a node, and the proper way of communicating between nodes is through signals. In the editor you can easily embed scenes or extract a group of nodes to a new scene. This modularized orientation allows a good level of decoupling and makes creating, changing and supporting your game easier.
Far from having the best code editor ever, Godot editor does a decent job. Auto-completion is complete and useful, it is easy to find errors and switch between the graphic part and its related scripts.
GDScript, Godot's official language, is simple and easy. It's based on Python, a language known as being beginner friendly. Its dynamic nature makes it a good fit for scripting and spiking.
Another good thing is that you are not limited to GDScript. Godot has support for other languages such as C# and C++, besides the community-provided support for a few others.
Godot editor runs in all major platforms and exports games for mobile, web and desktop. Tested and approved!
It is amazing how many answers you can get with a simple search. Godot community is very active and growing everyday. You can dig the forum or look into the documentation which is usually easy to search and mostly complete.
All Godot files are plain text. This makes solving version control conflicts an easy task. It is relatively easy to understand what changed only looking at the diff.
Besides all the benefits we get from an open source tool, Godot counts with a small team of skilled people working full time on the project. Every release come with many bug fixes and cool features and it is always transparent for users and contributors.
Sometimes when reviewing my changes before commiting I see differences in files that I didn't change. This is due Godot storing information about my workspace (such as nodes expanded or collapsed) in the scene's file.
It is useful to come back to the editor and find nodes in the way you left them, however I can see the hassle it would be for developers working in teams where every time you commit something you need to review which files are changes and which ones are just noise.
GUI development always sucks. It's boring and annoying. Godot does a decent job here, but it's not pleasant. If you don't structure your elements carefully they will expand and shrink in the craziest ways.
As most of the game engines, there is no easy way of testing your scripts. Given testing is one of the best tools for designing complex scripts, it would be nice to have a way of keeping them inside the IDE workflow.
I see why writing tests are not the focus for game engines given the fact that many things are done using the interface and scripts are usually procedural, short and simple. I agree in those cases testing would be contra-productive.
My workaround when developing complex scripts is to make them in a different language outside my project and then translating them to GDScript. I'm talking about pure logic scripts. I don't think you should test things that interact with Godot's API.
In the post "How to make your dream game, publish it and not die in the process", Juan Linietsky, Godot's lead developer, explains Godot's philosophy and his point of view of game development. Tests are not one of the topics of this post, however it makes clear why their absence shouldn't be a problem.
Whether you are an experienced developer or a beginner I do recommend trying Godot. Keep in mind an engine always come with a learning curve and some constraints, however Godot still enjoyable.
Disclaimer: Even though these engines didn't fit my scenario, this doesn't mean they are bad or worse than Godot.

Cocos2D-x is an open-source, multi-platform framework.
The main problem was that I got the worst of two worlds: I didn't have all the benefits of a full engine workflow and at the same time I was not as free to work in my way. I was constantly looking into the documentation and trying to understand why things didn't work.
To make things worse, some times the only help I could find was all written in Chinese.
To be fair, I used Cocos2D-X more than 5 years ago, and things probably improved since then. Another thing to point is actually their focus seems to be mobile games.

Unity has a big community and the many resources available make it easy to get in. Having said that, developing 2D games in Unity always felt hacky to me.
2D in Unity is actually 3D with a fixed camera. I lost the count how many times I had to solve issues that where just things in wrong perspective.
Among things that made me look for something else are: Unity is heavy, consumes a lot of resources, you need to download updates very often and there is no Linux editor. (Update: On mid 2019, a Linux version was release for Unity editor)

Defold looks really good. To be honest I didn't develop on it, because when I started for the first time they asked me to login and save my files in their servers. The Defold catch is that it was made to work using King's servers.
There is a way to use your own version control, but after reading I realised it wouldn't be that simple.
There are other possible downsides such as the small community and being a proprietary engine maintained by a small team(Update: On May 2020, Defold was transferred to Defold Foundation and all source code was made available). But I confess what scarred me most was the lack of freedom in the way you develop and organise your application.

Gamemaker Studio is a heavy weight of game engines with a impressive showcase. The reason I didn't follow up with it is simple and for many people probably silly. Their support for Linux is limited to Ubuntu only.
I've been using Linux as my main operational system for more than 10 years and making a game that runs in Linux distros, Windows and OS-X is always one of my goals.
I know people will say that moneywise Linux is not a good target, but for me it is more a matter of principle than anything else.

MonoGame is an open-source implementation of Microsoft XNA 4 Framework. You can make games for many different platforms, including PS4 and XBox One. Many successful indie games were made using MonoGame such as Fez, Bastion, Tower Fall and StarDew Valley.
What turned me off was all the requirements, confusing documentation and the heavy dependency on other softwares such as Visual Studio and Xamarin.

LÖVE is a cute, multi-platform, and open source framework for 2D games. Not much to say. It was just too limited for what I was looking for.
The best engine for you will depend on your goals. First define what you want to achieve and then think how an engine would be able to help you.
For me Godot is serving well. I still want to make a game from scratch eventually, however it requires a big amount of work and my goal now is just to release my first game.
I appreciate feedback. If you have something to add, a different point of view, comments or suggestions leave them bellow. Thanks!
]]>However, with experience, we realize that not everything requires tests and in some cases, it's better to not have them at all. Madness? No, this is being pragmatic.
If you are reading this probably you already know about tests, but in case you are just starting and trying to see the value of it I'll list some benefits I see on writing tests:
With those benefits why would you prefer to not write tests? Well, it's all about trade-offs.
Spiking is a good way to get familiarized with a new technology or finding answers for assumptions. Here, you'll want to go dirty, hack and slash, copy and paste and make it work. Starting by testing will only delay your discovery process. You would be fighting test frameworks and losing focus from what you want to validate.
It is a good strategy to isolate your code from third-party code. Having extra layers on top of libraries may feel overkill, but they pay off making changes, updates and even replacing dependencies easier.
Writing unit tests for this layer requires many stubs, mocks or fake implementations, which are difficult to maintain and to keep in sync. There is still the option of integration or E2E tests, however, they are costly and in some cases flaky.
You should never test something that you don't understand. A test based on assumptions may cause more harm than good.
Testing legacy code is painful, difficult and not efficient. The best strategy is isolating the code and forgetting about it.
I know! It annoys you knowing there is that dark place in your codebase. Every new developer will try to refactor it failing miserably or creating more legacy code and bugs in the process. Some people will even suggest rewriting the whole application, but they will fail as well. Just keep in mind that if it doesn't affect your performance and your ability to change, it is better to let it be.
Creating tests for legacy code only creates a false feeling of safety. People will think it's ok to refactor it because it is covered by tests. Instead of putting a lipstick in the legacy pig, it is better to write a big sign saying "Abandon hope all ye who enter here".
Ok, You caught me. All the items before are all about this one. In summary, it is ok to not write tests when writing tests doesn't make sense.
It is not about coverage, but the quality of the tests you have. By quality, I mean tests should be easy to maintain and easy to change. They should be consistent and ensure that your code is working properly. If you can't ensure the quality of your tests, maybe you should try a different approach.
Having said that, tests are an important tool. In most cases not being able to write them properly could mean that something else is wrong, which may require your attention.
The decision of not writing tests shouldn't be a stigma as long it is conscious and supported by good arguments.
That's all for now. If you have something to add, a different point of view, comments or suggestions, leave them below. Thanks!
Photo credit: Internet Archive Book Images on Visualhunt
]]>The main reason I had never thought about blogging before was the amount of content out there. Good or bad, there are so many tutorials, opinions and reviews on the Internet. I didn't feel I should add to this blob of data only for the sake of getting attention.
Nowadays you can solve most of your problems searching for the solution on the Internet. However sometimes you face a situation where you have a simple issue and all the solutions you find are not valid for you, probably because of the many variables involved.
After reflecting about this I realized that maybe all the things I didn't write about could had helped someone with the same constraints I had.
This is why I'm starting now. I'm not saying this will change people's lives, but if at least one person find something interesting in this dark corner of the Internet, it is enough for me.
Photo credit: RAETHIER on Visual hunt / CC BY-NC-SA
]]>