Coding a game in Python. Code published on GitHub

python
python3
pyglet
gaming
puzzle

#61

Coding night 22 - internalization and some new animations

With its dictionaries, Python is easy to create language versions with few lines of code. I set en_EN as default, and any translation can be added at any time. I added pl_PL, of course.

image

I’ve also redesigned animations on the game start and level finished (in 2 variants). No soundtracks yet, besides the sample one I created yesterday in about 5 minutes. :slight_smile:

The avbin library, necessary to play compressed sound (music tracks will be in ogg!) may not be present on each machine / OS. Arch Linux needs an AUR package. avbin crashes for me, avbin7 plays well with pyglet. Void Linux has no avbin support yet. For the game to work, even with no music (just sound FX in .wav), I added a workaround. When started, the game attempts to play the initial sound from the .ogg file. If the try clause catches an exception, the avbin variable is being set False. No more compressed file will be loaded.


#62

Wow, some updates & tweaks.


#63

Coding (day and &) night 23 - summary bar

This seems to be not really important feature on 6 x 6 board, but I expect it to be useful. After each move, which results in deletion of cells, a summary bar is being displayed. It shows how many cells of each type left, and disappears when mouse moved (could be displayed again with “h” key). If less than 3 cells of any type left, the value will be followed by :(, so that you could use the Undo button.


#64

Coding night 24 - more sounds

Not all of them included in the movie. :wink:


#65

Coding night 25 - player panel

The part of the job I don’t really like: player account, player login, top players list. This means the text input and also printing results, and I’d like to avoid opening another window(s). It also means php and MySQL on the server side - bleh!

I divided the remaining area of the user’s panel and added buttons. It must be enough for tonight.

player-panel


#66

You work too hard @nwg . Coming up nicely.


#67

Coding night 26 - player account dialog

It’s always a hell of work with coding dialogs in a framework like PyGame or Pyglet. Pyglet offers some basic text widgets, but they do not look well enough to be shown to the world. I implemented the player account dialog as a sprite, but still a lot of work is waiting to be done. At least it already looks not bad. :slight_smile: By the way - I did a lot of optimisation to the bottom panel code.


#68

Coding night 27 - runtime configuration

Being slightly fed up with the player account, I put it off, and added the RuntimeConfig class and the rc file. At the moment it allows to select the cells graphics, and also play with the background image:

  • if to draw it while playing (or save on resources on less powerful machine) - True by default;
  • if to rotate it while playing (too distracting to me!) - False by default.

Further progress to the player account - later. UEFA Euro 2020 qualifying starts tomorrow. :slight_smile:


#69

Coding night 28 - player account continued

As usually - it’s a real pain in the ass. I had to re-write quite a lot of the python code. Even if I reuse php I wrote for my two previous games, it doesn’t make things look any better. For now I have the player account creation working, and it’s 4:30 am. Enough is enough.


#70

Coming up slowly but slowly right !


#71

Coding night 29 - still the player account

Nothing special to show tonight. I started adapting the old php code. Also made several changes to the panel to show the online status.

image