As of 2016-02-26, there will be no more posts for this blog. s/blog/pba/
Showing posts with label library. Show all posts

flycombat is part of Pygamii examples. You are an airplane and you shoot down enemys planes.

This is a simple game as an example for the gaming development library. You get a score on top and life as well. Several different enemty planes, so its not too bad as an example for just 287 LOC.

Pygamii was created by Carlos Maniero, written in Python 3 with readchar, termcolor, and optional Pygame for sound, under the MIT License, currently version (2015-12-23). from PyGamii is a clone of Arkanoid or Breakout. PyGamii is an engine for ASCII games, which only has less LOC at this moment.

Although its named, I dont see any power-ups falling down. Since its just an example, I shouldnt expect much from it, it doesnt have a score.

The library is small, but it uses PyGame for audio, and that probably is the reason why PyGamii named PyGamii. Its not officially supports Python 2, but I found it has no problem to run with it, just its kind of glitch in display.

PyGamii was created by Carlos Maniero, written In Python 2/3 with readchar, termcolor, and optional Pygame for audio under the MIT License, currently git-2fe2332 (2015-12-15).

As I mentioned in previous post about Call Stack, the thing is ready on GitHub, It's a library for easy logging, here is a quick screenshot of the examples:

As you can see, it's colorful, little too fancy, I hope it didn't blind you. It's new , so I hope someone can jump in and improve it. There are some in it I didn't like, e.g. the templating.

It's easy to use, just source, then you are good to go. Please read more on GitHub.

Google just announced a new image format, WebP. The statistics of compression ratio looks very promising. But I wonder about the process time of reading. So I downloaded webp-leptonica (version 0.0.1) tarball and added few lines to webpconv.c to time it with libvpx 0.9.0 (with mmx sse sse2 ssse3 threads flags).

--- webpconv.c.original 2010-09-30 02:19:39.000000000 +0800
+++ webpconv.c  2010-10-01 08:26:48.000000000 +0800
 -39,6 +39,7 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <time.h>
 #include "allheaders.h"

 #define DEFAULT_PSNR 42.0
 -218,13 +219,17 

     struct Pix \*pixs;
+    clock_t c0, c1;
+    c0 = clock();
     if (!strcmp(ext, ".webp")) {
       pixs = pixReadWebP(argv[a_idx]);
     } else {
       pixs = pixRead(argv[a_idx]);
+    c1 = clock();
+    printf ("Elapsed CPU time on reading pixels: %10.6f seconds\n", (float) (c1 - c0) / CLOCKS_PER_SEC);
     if (pixs == NULL) {
       fprintf(stderr, "Failed to read image\n");
       return 1;
 -240,6 +245,7 
       format = "png";

+    c0 = clock();
     if (strcmp(format, "bmp") == 0) {
       pixWrite(fileout, pixs, IFF_BMP);
     } else if (strcmp(format, "jpeg") == 0) {
 -275,6 +281,8 
     else {
       return ERROR_INT("Format not supported", "webpconv", 1);
+    c1 = clock();
+    printf ("Elapsed CPU time on conversion    : %10.6f seconds\n", (float) (c1 - c0) / CLOCKS_PER_SEC);


My goal is to time pixRead() and pixReadWebP(). This may just be a rough numbers, here is the results on images from this page:

The blue block is about JPG to WebP, and the purple block is about WebP, which is from previous conversion of JPG to WebP, to WebP. I didnt set the quality, I let the program to decide on its own.

As you can see the size are reduced after the conversion. But, interestingly, the read time or decode time, its not the same story. For bigger images, it seems to need more time for decoding pixel data. I dont know about image library or processing. Maybe this is not practical or the library is not optimized yet. Anyway, this new format is still new.

Honestly, I dont really think anyone can kill JPEG, even the Google. Yes, Google may be able to push this new format or anything into our programs, WebM is the good example. But the old stuff support is too hard to be dropped, till today some people still use GIF (not for animation) instead of PNG. If someday, Flickr supports the WebP embedding, I will still not use it to put images in my blog.

By the way, why are 5.jpg and 8.jpg missing?