Friday, July 24, 2009

Experimenting with haXe

So, I found on the web this nice language that can compile to flash/javascript/php and other bytecodes (even to pure binary) and I decided to give it a try.

And, also, some time ago I started to wonder if I could make a Facebook app (a game).
I started to think to something easy to make and funny to play and then a little flash game on a site with some simple tutorials reminded me of a stupid game I wrote in C at school using only OpenGL's rectangle and triangle.

I spent something like 3 hours trying to code a GameMaker-like engine in flash, but I wasn't able to figure out how the flash drawing system works.
Tired, I pointed my browser to Google and found this nice tutorial on making a 2D game with haXe. Its approach to bitmap blitting is odd: it creates a BitmapData object for the screen, then it creates a Bitmap from it and adds it to the root (flash.Lib.current).

I adapted some of the tutorial code to my engine and now I have some rectangle moving on the screen :). The next step will be to add support for animating sprite and then I can start the funny part: programming the gameplay.

Here is the demo (only 6Kb, you should understand why it is so small xD):

Thursday, June 25, 2009

New release of KlonDuke

New release of my tool to edit iPod Klondike savefiles!

Well, actually it is not a new release, I just rewrote the old code using Qt4 instead of FLTK.
Advantages? Easier to compile, solves some issue and looks nicer :).

You can download the linux binary or the source code from emptylabs @ Google Code (it is name v0.2).

Some screenshots (before, after, about):


P.S.: If someone manages to compile it under MSVC or XCode I'll be happy to link it here :)

Sunday, May 24, 2009

iPod Lyrics

Tired of manually downloading songs lyrics and copy-paste into plain-text files to view them in iPod's "Notes", I searched the web for a site that could do it for me. I only found some applications to download and use on my computer but it was not what I was looking for, so i wrote a simple python script to do the job.
After thinking a little about it I realized that I could simply write a "one page" website that sent request to my little script... so I did it and if you open you browser at http://ipodlyrics.x10hosting.com/ you'll find a beta version of it.

3mpty

Friday, April 3, 2009

Ingen: Opensource Modular Synth

After trying alsa modular synth and seeing it crashing every 2 mins, I decided to search the web for something better... and I found Ingen.

A simple MIDI-controlled synthesizer patch

Ingen is a software that uses LADSPA and LV2 plugins, connected with each other, to create synths. LV2 is a new format of plugin, that probably will substitute the old and limited LADSPA if all goes right.
LV2 gives the programmer the possibility to create a custom GUI, just like VSTs do.

You can install Ingen from your distro's repository, but if the version you get is not up to date, you should checkout the latest from SVN: If you are able do deal with the console, the second is the better choice, because it means more stable software.

On this page there's the step-by-step guide to compile it from SVN.
(The build system, waf, needs python 2.x to work.)

If you get an error ending with
/giomm-2.4/giomm/error.h:97: error: expected declaration before ‘}’ token Build failed
-> task failed (err #1):
{task: cxx ConnectWindow?.cpp -> ConnectWindow?_1.o}

I managed (in a not so good way) to "solve" it:
Just open the file error.h (that should be in some folder like "/usr/include/giomm-2.4/giomm/") and skip the source to the line indicated by the number indicated (in this case, 97). After that, change the line from "HOST_NOT_FOUND," to "HOST_NOT_FOUND_," and do the same for the next line.
Then recompile with ./waf and all should work fine. After compiling, reopen error.h and revert the changes.

Now, a simple "sudo ./waf install" or "./waf install" if you are already root installs the app on your system.
To run it, if you don't see it on the app menu, open a shell and write "ingen -eg": this will start ingen with the graphical frontend.

As I wrote before, Ingen needs plugins installed on your computer, otherwise it is quite useless.
Here are some links to good plugins:
Ingen automatically adds LV2 plugins in its menu, while for LADSPA ones you must right click->find.

If you have any problem or question, just leave a comment or write some line on Ingen's IRC channel on freenode.

I hope to write a short tutorial to describe how to create a simple synth with ADSR ampli.

3mpty

Friday, March 13, 2009

Python CGI Debugging howto: Part 2

Ok, in the previous post I wrote that probably there was a better way to display errors for cgi script in python, so, here it is:

import cgitb
cgitb.enable() #This enable it all


Two lines :)

Simply put them at the beginning of a script and they do all the work. It's also possible to output errors in a log file instead of displaying them in the browser of the user (just take a look at python documentation on cgitb.enable()), a far better solution for production environment.

Python CGI Debugging howto

I found this useful when you are trying to debug a python script running on a remote server (that has a previous version of python, in my case :( ).

To show the classic interpreter error messages just do this:

import sys
sys.stderr = sys.stdout

print "Content-type: text/html\n"


In this way, we set the errors to output text on the standard output (in other words, we redirect the errors to the standard output), then we print the standard HTTP header to inform the browser that the following text will be an HTML page (even text/plain works fine) and if we get an error, it will be in some part of the page source :D.

Simple, probably not the best, but it works.

Thursday, January 22, 2009

KlonDuke 0.1

Here's my new useless software: KlonDuke
It's a graphical application based on the FLTK2 toolkit that lets you edit savefiles of the iPod game "Klondike".

(You must have already saved a game to use this tool)
It's really simple, just open it, click on "Open", select the "datafile" in the directory IPODDIR/iPod_Control/gamedata_RW/110xx (Where IPODDIR is the directory where the disk is mounted on unix-like systems or something like F: in Windows, and 110xx is the game ID starting by 110 with the last two digits changing from version to version), edit whatever you want (if it shows a wrong player name it's better that you simply close the program), click "save" and then "close" or "quit".

If something goes wrong you can delete the datafile from klondike's directory and the game will create a new one.

Screenshot:


Sources: klonduke-0.1.tar.gz
SHA1 Checksum: 334d212c228e354a9643693f1ecd51b7c028763a
Linux binary: klonduke-0.1_linux.tar.gz
SHA1 Checksum: 5441f93807876dda33dfb8b454a86717647fdd8b
Windows binary: I'm having problem with FLTK2 and MinGW
Mac binary: I don't have a Mac!

P.S.:
If you want to make a precompiled executable that isn't listed there simply leave a comment. I need a Mac binary and a MS VC++ one (VC is better than MINGW).

Wednesday, January 21, 2009

FLTK2 howto: Display images on widgets

I spent some time figuring out how to do this. Yes, you simply call:

widgetName->image(myPrettyImage);

But (at least for me) this did not work.
So I searched in the documentation but all seemed right.
The next logical step was "search on Google" (everyone should know that "he is your friend").

I read something on a forum regarding the function fltk::register_images() (Absolutely not documented) and I understood that it must be called before you use any other image-related stuff with fltk2.

So, if you want a widget to display your beautiful image you must code a main() like this:


#include "myMainWindowWithBackgrounImage.h"
#include <fltk/SharedImage.h>
#include <fltk/run.h>

int main()
{
fltk::register_images();
myMainWindowWithBackgroundImage win;
win.show();
return fltk::run();
}
You must then link the executable to libpng, libjpeg and libfltk2_images passing "-lpng -ljpeg -lfltk2_images" to the compiler.