Tic Tac Toe with PHP-GTK2

Finally it’s here :) The game you have been waiting for…

Since I haven’t tried PHP-GTK2 before and it’s currently in alpha stage, I wanted to see how easy I can take a simple GTK application written in another language and port it to PHP-GTK2. I ended up porting this Ruby/Gtk example written by Daniel Lichtenberger which have some logic, dialogs, events and some graphics.

Most of the code was pretty straight forward and directly ported. I had to heavily use the PHP-GTK2 Manual in addition to check/verify my assumptions with the source code of the PHP-GTK2 extension a few times. I had most problems with porting the graphics, but ended ut by simply using the GtkImage on a GtkButton instead of using GdkPixmap’s. I think I used about 10 hours on this experiment.

The source code is available here (GPL). If you have installed PHP-GTK2, simply run the game with:

$ php tictactoe.phpw

I’ve tested it with PHP 5.1.4 and the current PHP-GTK2 alpha release. Since this is a really simple application I probably won’t use many calories to improve it. But if you have some free time, try it!

Have fun! :)

6 Comments

Pierre  on October 12th, 2006

Hi,

it looks great. Seems that GTK2 becomes a very good tool to develop Desktop-Apps. Maybe somebody should programm a WordPress-GTK application to manage your Weblog(s) from the Desktop without hazzle ;-)

Eris Ristemena  on October 12th, 2006

I’ve tested using PHP 5.1 for windows, it works fine. Thanks for the fun, i mean to hack it .. :p

Scott Mattocks  on October 12th, 2006

Nice application Knut. I am glad that you didn’t find PHP-GTK 2 that hard to work with. You might also want to check out the game page at Gnope.org.

NuLL  on October 12th, 2006

Thx for this app :-) For me its is great PHP-GTK tutorial :-)

Carl  on October 21st, 2006

Great stuff, Knut!

Inspirational. :-)

atiol  on November 6th, 2006

Yep!

This sounds great! But the Decription / Haccking could be a problem.

Obfuscating your code using a program like Code LocK could realy make the difference.

But yes. Really nice.

Once I eard about PHPDock by NuShere.
It should be an alternative to GTK. And again using Code Lock, even the Cheapest V1 ( http://tinyurl.com/ylfh4m ) could make the deal!

Nice.

Leave a Comment