Entropy, a HTML5 game with bouncing balls and simple physics

Python version

In my free time I wanted to try out pygame, so I created Entropy. It’s a game where balls are attracted or repulsed by the mouse cursor when holding the left, right or middle button. The balls also bounce against the screen edges. It is not a real game actually because there is no specific objective. Still, it is fun to move the balls around especially with 1000 of them. Additionally, it runs on the Nokia N900 and the accelerometer controls the gravity. The source code can be found here: Entropy (Python version)

Here is a video:

There are some configuration parameters in the “config.py” file that can be adjusted.

Web version:

Then, I thought that no everybody would have Python and Pygame installed like Windows and Mac users, so I ported Entropy to Javascript and HTML5. Unfortunately, its performance was poor, so I added a WebGL renderer. Now it runs almost as smooth as the Python version !

If you have Firefox 4 or Chrome, you can try it out:

You can also check my games page which has more options.

For the web version, a few URL parameters can be appended:

  • “particles”: number of particles
  • “fps”: frames per second (defautls to 30)
  • “gravity”: “false” to disabled gravity. You can also hit the “G” key to toggle gravity.

Please note that the canvas content doesn’t resize automatically with the window, you have to refresh the page manually after resizing.

Have fun !

Edit: the code is now available on GitHub.

Thoughts about time travel and life

My favourite time travel stories are the ones where time is immutable, and where closed time-like curves (CTC) occur. They are some kind of logical time loops. Because of this, the past can’t be changed, so everything that is was already this way. If you still travel back in time and try for example to prevent a specific event from occurring, in the end you’ll find out that you can’t change anything no matter what you do. In some scenarios, the reason why that event has occurred in the first place was because you were there in the past and made it happen, directly or indirectly.

This happens for example in the “The Time Traveller’s Wife” movie, where Henry, the time traveller, meets his future wife Clare for the first time, they are both adults. She already knows him because when she was younger, she met an older Henry who travelled back in time. So at the time the present Henry first gets to know her, he doesn’t understand how she could already know him. It’s only later that Henry figures out that he would travel back in time and meet a younger Clare, and understand how she got to know him earlier. In this scenario we can see that these events have always already happened, and the protagonists are only discovering them one by one.

The best case of time loop I’ve seen is in the Doctor Who‘s episode “Blink“, where the Doctor is stuck in the past and communicates with Sally, a girl from the present. During the whole episode, Sally discover several inexplicable  messages from the Doctor, who seems to know her actions beforehand. The reason why he knows about her actions is because she would tell them to an earlier version of the Doctor later, before he got stuck in the past.

I like to believe that this is how time works in reality. So when I think about the past, I try to accept it as it is, and not hope I had a way to change it. But I still do like to think about what would happen if I changed some events in my life, especially negative ones. The result is often that I wouldn’t be where I am now without such events. Maybe I would be in a worse situation just because I didn’t learn a specific lesson at some point of my past.

From here, I try to learn from my past experiences, and accept them as they are. Some bad things happen in life which might lead to good things in the future. Also, good things happening now may lead to worse things happening later. So it’s better to keep everything as it is.

Creating maps with Platinum Arts Sandbox

I have created some maps for fun using Platinum Arts Sandbox. It is based on the Cube Engine, a 3d game engine where the map consists of a series of cubes with different sizes. The cubes themselves can be deformed in a limited way, like moving their points. An interesting feature is that it is possible for multiple people to edit the same map at the same time (coop mode).

Here are some pictures of the maps I created:

Chinese garden

 

Flying garden

 

Forest

 

Later I plan to package and publish these maps, as I have no specific use for them. Also, it is more enjoyable to have a virtual walk there than see the pictures.

More pictures can be found here.

 

 

Playing with the HTML5 canvas

I wanted to learn how to use the HTML5 canvas, and a good start was to implement some known games. So I have simply implemented a Tetris clone and a Minesweeper clone using only JavaScript and the HTML5 canvas.

Running BIRT in Tomcat on Nokia N900

IcedTea6 for Maemo is out. It’s a port of OpenJDK for the Nokia N900. Thanks to this many Java applications can be run on the tablet.

I recently tried to install Tomcat 6 and deploy the BIRT runtime on my mobile phone, and it worked ! :-)
But it was still a little bit slow to serve pages…

Now I’m waiting to see when I’ll be able to run Eclipse on the N900 and do some software development ;-)

My new game project: tuxomania

GNU/Linux needs more games ! That’ s what I read sometimes from people like me who hope that one day GNU/Linux can become more popular. Anyway, there are already lots of games for this operating system, and most of them are open source. Even some commercial games are available, like Unreal Tournament 2003 I personally own. Works very well :-)

Since I also want to contribute to the free and open source world, I have decided to make one of my child dreams come true: write my own video game and publish it !

Read more »

Screen orientation or how to surf the web while lying in bed

If like me you sometimes feel tired, would like to lie down, but still want to use your computer (like a real geek ;-) ), and maybe surf the web or read ebooks.

Rotating the screen

I have already shown you how useful a trackball can be compared to a mouse, especially in this kind of situation. You might have wondered how I am able to use my laptop computer while lying on my bed. The fact is that I have changed the screen orientation to match my lying orientation. If I wouldn’t, reading the screen would be rather painful.

Read more »

My new Youmouse Trackball

Until recently I was enjoying to use my Logitech Trackball for many years, one of the most comfortable trackballs I have ever tried. Unfortunately it is now broken, and clicking sometimes doesn’t work, which is not very convenient. You can imagine when I’m playing Unreal Tournament 2003, and I aim to an enemy, then click, but the rocket doesn’t fire… it just feels like my weapon is broken… that’s frustrating :-D

Logitech Trackball

Logitech Trackball

So I decided to buy a new trackball. Instead of buying the same Logitech model again, I took a look at other existing models in Taobao, the Chinese Ebay. Unfortunately, there is not much choice, and many trackballs don’t look comfortable, because their ball is on the middle instead of the side. After some research, I found the Youmouse company (in chinese 优鼠) which sells trackballs in China, and also to other markets like USA and Europe, according to their website. I am a little surprised to find it because it seems that trackballs are not common at all in China (at least here in Shanghai), and most of the people never heard of trackballs before. Anyway, I am glad to see that some companies are trying to improve this market, and by the same chance provide me with a shiny new trackball :-)

I bought the USB “Hand-held Trackball Optical Mouse” from Youmouse. Here are some pictures I made:

youmouse1

Youmouse trackball

youmouse6

In trackball mode

As you can see you hold the trackball with the ball on top and use your thumb to roll it. The left and right mouse buttons are on the right side of the ball. The device also has a scroll wheel, but its position is not between the two mouse buttons as usual. It is situated on the part below the ball, right under your thumb. This means that you can’t use the ball and the wheel at the same time.

The trackball itself can also be used like a regular mouse. For this, it has two separate optical sensors, one for the ball, and one the part that can slide on a flat surface.

youmouse2

On the table, like a regular mouse

youmouse4

Optical sensor for mouse mode

youmouse7

Mouse mode by moving, trackball by rolling the ball

Holding the trackball feels alright, but is not especially comfortable at the beginning. It takes a few seconds to take it in the hand, find the right position for your finders, and get used to it. This is not convenient when you need to often switch between mouse and keyboard, so it can slow down regular desktop use. This problem applies to both trackball and mouse mode.

Both optical sensors are hardwired in a way that creates a conflict between each other: it means that if you roll the ball and move the mouse at the same time, even in the same direction, the first one that moved has priority over the other, there is no accumulation of the movement. One issue I have met is that from time to time the mouse pointer doesn’t respond to the ball and stays stuck, especially if I put it on a surface. This might be related to this conflict, as the mouse-mode sensor might have detected some very small movement while I was using the ball.

Also, the two optical sensors seem to both send the same signal USB-wise, and it is not possible for software to distinguish between ball rolling and mouse moving. If that would be possible, one could use 4 axis of movement instead of 2, which would be a nice feature for gaming and for multi-mouse/multi-pointer applications, similar to what the Multi Pointer X server and CPNMouse are achieving.

Logitech Trackball and Youmouse Trackball side by side

Logitech Trackball and Youmouse Trackball side by side

The Youmouse Trackball looks and feels more like a gaming device, compared to the Logitech one. From my experience, it is actually very suited for gaming, and also as a remote control (with laptop linked to TV), and any situation where you always keep the trackball in your hand. I especially like to use it when I lie down on my bed, lying on the side, and surfing the web :-) . In this position, it wouldn’t be possible to use a regular mouse.

Lazy Vincent using Youmouse Trackball

Vincent in "lazy mode" using Youmouse Trackball

With the Logitech Trackball, since it is right-handed, I could only lie on one side (the left one), because it must stay flat for the ball to roll properly. The Youmouse Trackball, like I said before, can be rotated in any direction, and the ball can still roll properly, so it can be used by lying on any side.

To sum up, the Youmouse Trackball doesn’t feel to me as good as my previous Logitech Trackball. But even though it is not very convenient to use it for desktop applications where you want to switch between mouse and keyboard, it is still a great device for gaming, as remote control, and also for “bed surfing”. :-)

Hello world and happy new year 2010 !

Hello world and happy new year 2010 !

My name is Vincent and I’m a French computer geek. This means that I enjoy spending most of my time tinkering with computers, like trying new software, and finding new ways to improve life through computing.

Since 2003 I am a happy openSUSE user (formerly SuSE), one of the best GNU/Linux distributions out there. I would like to help spreading the word about GNU/Linux to the world through this blog, and also to help making it more popular, especially in places where it doesn’t seem to be well known, like here in China where I currently live.

In this blog I will mostly post about my experiments with computers, interesting ideas or hacks, hints, and anything that will hopefully be useful in some way to you computer users out there.

Enjoy !

Vincent