It’s better to use floats for maths and leave ints for indices

Someone showed me a bug in my recent game, Freefall, whereby you can get as far as you like, by just changing speeds continuously, you don’t even need to look at the screen, just tap with a consistent tempo to keep changing speeds. This works because the projectile speeds are set with integers which means they have:

  1. A base speed at which they will hit you with the parachute
  2. Fast (double base) speed they will you with if in free fall
  3. Anything faster than this will miss you because it will get off the screen before it reaches you and is therefore only in there for decoration / to confuse the player

I used integers for practically everything in the game because the low resolution meant that even moving one pixel at a time is a pretty big step (there are only 48px in the vertical axis) and you can’t draw smaller than that.

During testing I focussed on checking that 1 & 2 would hit you at their respective speeds and that you could dodge them if you changed at the last moment. If you change speeds so infrequently the problem is less apparent. Continue reading

Ebiten vs PyGame

The following is a copy of a response I wrote to a university student asking in the Ebiten Discord server whether they should use Ebiten or PyGame for their first time making a game:

Having used both I can say that PyGame provides much more out of the box but that this is not just a pro but also a con. For example in pygame there is a concept of “sprite” that has movement and you can tell it move left, move right etc. In Ebiten it surprised me to find that there is no such thing but it’s nice for two reasons: Continue reading

Use HOME as your GOPATH

How and why I normalised my Go paths and personal/local home paths.

Like many people, I have my own scripts and stuff in a bin directory in my home directory. Actually it’s a symlink to ~/.local/bin because I saw there was a ~/.local/share which some programs use to store user-specific things and I wanted to be consistent.

Then I saw some people have ~/bin and ~/src and I thought that looked like a Continue reading