Silicon Delight

From Silicon to High Level Languages

What I’ve learned implementing a simple blocks game

I always wanted to make games, I have tons of games ideas, but I have always struggled while trying to implement them.

After reading an article I started to implement a simple block game.

Start simple

Event the simplest game becomes rapidly hundred of lines, dozen of functions and multiple files.

So by starting with a simple project, to learn the basic principles of the games, game loop, entity management…

Prototype then clean

To implement a new feature, I like to start to implement it with the basic algorithm and not so clean code.

When the feature works, the I look how to clean the code, refactor it.

No memory allocation/free in the main loop

Having memory allocation/free in the main loop can give huge leaks that will rapidly become segfaults. Furthermore  allocating the data at the init of the game or the level often simplify the code.

Compute the data offline

To handle the rotation, I started with a rotate function, but after some experimentation his behavior felled strange. By looking at the rotation documentation  I found that the implementation is complex, because of the size of the shapes (2×2, 1×4, etc).

So finally I implemented the rotation by storing the possible rotations in an array manually.

Move the complexity at the init

After the multiples cleanups, all the data transformations and creations that have to be done at run time are made at the init. All the SDL_texture for all the possible rotations are computed at init.

Beautiful does not mean complex

At first I started by looking how to implement gradients to draw the blocks. But I switched to colored block with carefully chosen colors and the result is good.

Introducing NotesCharts

Since a few days, I started a new project: NotesCharts.
This project comes from my need to mix Mind Mapping and Note taking.

After using lots of Mind Mapping software I think it is a very useful tool to
help thinking about a problem. It is also very good at providing an overview of
the problem and ideas.

In contrast note taking tools are useful to note my day to day activity,
meeting notes, to keep them and retrieving them.

I want a tool that mixes both of the worlds, allowing me to take notes and to
provide an overview of my notes, to filter them to link them…

Ideas:

  • Layouts: Many layouts, from normal document layout to Mind
    Maps like layout.
  • Tree: All the data is organised as a tree like all the
    Mind Mapping Tools.
  • Data: The user owns its data, he can play with its data and
    import/export it to custom format.

For the first week I started by setting up the environment to draw the
graph.
I also started to play with layout starting to write algorithms to make the
positioning.

The next time I will start to manage user input.

1PPM: February Review

This month was another bad month, especially because I was preparing a big running race and made lots of commutes.

But I have not done nothing, I have started the GTK+ integration in order to provide an user friendly interface. For March, I plan to finish the GTK+ integration and to finally make a first usable version.

First Month review: EPIC Fail!

As I said in the previous post, one of my resolutions of this year is to make 1 project per month. Today we are in February, and one month happened since the beginning of the challenge, so a project should have been finished.

First, since the beginning of January I’ve lost my motivation on my side project, I’m have not done any developments since December. I see this as a pause, I was really exhausted about programming and I only re-start to develop right now.

Second, I planned to finish my previous project and after some hindsight, I found that these project are too big. So I will split them in smaller ones.

So the February plan, is to split these projects into smaller finished ones, and to publish them.

The 1PPM Challenge

Hello,

New years are always subjects to new good resolutions. And like many people I have a lost of sides projects in mind. Following a news on HN (link) and a post on (1PPM Challenge). I decided also to try to make one project per month.

This for multiple reasons. First, to limit the time on project, when a project becomes too long my motivation tend to lower. Second, to force me to limit the scope of my project to make a minimal viable product. Third, not only to code, but also to market my products by making a beautiful page and speak about it on websites.

My first project is to finish and make a product from a side project started the last years: IOMind.

Embedding Tiny Scheme in a Game

I have recently started to develop a game from scratch. This game is about drone races. I will write about it in future posts.

I wanted to have a scripting language in order to be able to:

  1. configure game object properties,
  2. draw the entities,
  3. draw the levels,
  4. etc.

I started implementing my own parser but it rapidly became very complicated. So I’ve then looked for many embeddable scripting languages, such as lua, tcl, squirell and finally scheme.

The last one is very interesting because the Lisp family languages are very well suited to implement Domain Specific Languages (DSL).

This article compares the embeddable scheme implementations and shows how to embed TinyScheme.

Read the rest of this entry »

Vulkan the future of OpenGL

The Khronos group recently annonced the Vulkan API.

Thi new API is intended to be close to the GPU hardware than OpenGL.

Recently a post on gamedev by an intern an NVidia discussed about the fact than most AAA games have a bad use of OpenGL, and the driver team changes the driver to allow better game performances. It also speek about the fact than thousand of lines are dedicated to deal with the hardware abstraction layer.

But the new Vulkan API will certainly not be ported on old devices. The fragmentation between the version of OpenGL (most games used OpenGL 3 because Opengl 4 is not supported by lot of devices).

Vulkan will be closer to DX12, this will helps the port of games.

Vulkan and DX12 API will be the same on embedded devices.

 

 

On the evolution of the Raspberry Pi

The starting

Initially the Raspberry pi was launched as a ARM 11 running at 700MHz. This is equivalent to an old Intel Pentium 3 processor.
Compared to other boards like the BeagleBoard that have a ARM Cortex A8 core and a DSP processor, it is a low performance board.

First improvement

The first improvement in the global performances was with the announcement of the recompilation of the packages of the raspbian distribution with hardware floating point support.
This is not an hardware performance improvement, but it is an improvement on the use of the hardware. The gain was visible in the applications that uses intensively the floating point arithmetics, for example the graphics.

Then the hardware improvement

A few day ago they announced an update on the firmware that allows to run the raspberry pi at 1GHz without loosing the guaranty or reducing the lifetime.
The gain is up to 52% faster on integer, 64% faster on floating point and 55% faster on memory.

What next?

So a widely used and intensively supported product like the raspberry pi can give good surprises after the launch, like the distribution that have evolved, the performances, etc.
This for free without changing your board!

So what we can expect for the next improvement?
Maybe the support of GPU acceleration with OpenCL? Hum, the GPU firmware is very closed, and the manufacturer seems to don’t be ready for OpenCL. But the amount of user may put some pressure on them.
A new version of the distribution recompiled with support of the SIMD to improve the global performances? I don’t know if this can increase the performances, but for sure the power consumption.

 

Grabbing frames from webcam with a Raspberry pi

I have just received my Raspberry pi.

My objective is to use webcams with the board, so the first step is to connect and test a webcam with the board.

So after installing the official debian image on my pi board, I have plugged a webcam on one of the USB ports. Then I have tried:

 

 

It shows an USB video device connected to the board.

The next step ti to look into the devices directory for a video device:

 

 

But… nothing!

After looking on the web it seems that the video for linux driver is not included in the official raspberry pi debian image…

So I have two choices, recompiling my  kernel, or trying another image.

I have tested the beta version and the archlinux image.

The second one works, I now have a video device in /dev!

But I’m connected in ssh to the board, so I need a sample tool to test the webcam.

I’have found on the official video for linux documentation API an example.

There is another example on another video for linux API documentation.

Here is the code:

 

Compile it and test it with :

And you will find some ppm pictures grabbed  from you webcam in the same directory.

EDIT:

With the new firmware version compile with:

Light Table funded on kickstarter

Maybe you have heard about Light Table.

This new editor that make some improvement in this kind of tools shows the code in a novel manner, functions are showed separately, file are just a method to store file.

Another new feature is the instant show the function informations.

The major feature is the ability to prototype the application IN the editor. but this kind of feature seems to be possible only for languages supported by JIT (Just In Time) compilation like Lisp derived or Javascript.

For more informations visit the Chris Granger website.