August 28, 2011

Image Browser - Part 3 - Class diagramm

Class Button:
This class handle button graphic, animation, and its catch user interaction.

Class Entry:
This class handle how the directory list elements show on sreen and handle user interaction with these elements.

Class HMI:
This class provide a Human-Machine Interface. The basic tasks of this class is to countain buttons and entries. Handle user interaction, like find witch button was pushed, and show buttons and directory list.

Class Directory:
Handle directory reliated tasks.

Class Image:
Basic image showing and functions to browse through images in a given directory.

August 25, 2011

Image browser in Python - Part 1 - Specification

My next project is an image browser. Which specifications are the followings:

  • Minimalistic desing
  • Maximum space for pictures
  • Support the most common image types (png, bmp,gif,jpeg)
  • Automatic align of the buttons at different screen sizes
  • Always in full screen mode
  • Browsing through directories function
  • Animated buttons
  • Automatic picture downsize if need

August 18, 2011

Python on Android

Did you know  that Android is base on a Linux kernel? And I think almost all Linux for PC-s has a built in Python. So let's put Python on Android and have some fun. :) But how to do that? First you need a SL4A (Scripting layer for Android) on your system. SL4A is like a shell and the next step is install Python or any other program language engine. See more information in the main website. After some minutes/hours/days of work you can write and run Python scripts on your mobile device. If it's not enough disco to you, you can add Python subset for Android too. And make games and earn a furtune with them throught Android Market. For example here is my previus Prince of Darkness game ported to Android. I made some changes in intefaces to be more cool looking on Android, and slightly change gameplay too (and you can still run it on an avarage PC). If someone could help me how make an .apk file from it please discous it with me.
Hints:

  • Both SL4A and PS4A is on the Market, you can download them. If not, use websites download areas.
  • If you use Pygame Subset for Android 0.9.3 don't forget to add android.init() to the code else touchscreen won't work. I spent 2 days with this problem...
  • You don't need to have a Android mobile device for these things, they are run on Android emulator too. I developed my game on it.

August 14, 2011

Python to Windows executable

To convert my Python programs to Windows executables I use Py2exe and here goes some line about how to use it. So you installed it and wana convert your .py file to .exe. First you need a setup script like the following:

import sets
from distutils.core import setup
import py2exe
setup(windows=['yourprogram.py'])


The 'windows' key makes your program run without a console, if you wana run your program with an ugly looking console write 'console' instead. It is just a minimalistick script, if you wana add icon picture or other stuffs look documentation on web.

Next thing is after you saved your setup.py script is run the script. But don't use IDLE for it. Use command line. Like this: "c:\python\python.exe setup.py py2exe" As you can see the main things are define the program (python.exe) that you wana use for execute setup.py and add py2exe for run setup.py with py2exe option.

After a bunch of lines its over, and you will find two new directory, where your setup.py. These are build and dist. You dont need the build dir just the dist one. All the files in the dist directory that you need to use for run your program without an installed Python. So zip them for distribution.

If you use fonts in your program and after the conversation it gives you error messages its could be because of missing fonts. To solve this just copy the following files to your dist filder. "SDL_ttf.dll, font.pyd, libfreetype-6.dll"

Thats all...

August 10, 2011

Prince of Darkness : Bloody Saturday

This post will be about my first game that I wrote, it is: Prince of Darkness: Bloody Saturday

Review:

Tha base concepts are: a quarc game from tha late 80's - early 90's and a romour about a famous star. So I took thes things and made my game. You can download the windows executable or the source here . Lets see what programs I used. First Python 2.6 for basic operations, Pygame 1.9 to handle graphic, Buzhug 1.8 for database to save high scores and players name's. At least Py2exe for making windows executables.

How to play:

Your aim during the game is to catch as much bat as you can before lose your 4 life.

After start the game, you can see the scoretable by hitting the 'S' key, to begin game hit key 'B'. You can move with the 'H','U','J','Y' keys.

During the game you get continous feedback of your score and how much life remained.

When game end you can write your name in the score table. If you mistake use BACKSPACE to delete and hit ENTER when you ready.

Usefull advice:

If you using pygame and experiance slow down during gameplay, look for sprites that you draw but not delete, over and over. 700-1000 sprites can cause serious slow down. :)

August 8, 2011

Art Gallery

My first "work" was an art gallery for my vectorgraphic drawings. You can check it on

chiharu.net46.net

It is the secound version of my gallery. It has a lot of improvements compared to the first one. It is more modular now. Which is make the coding, developing and maintaning more easier. You can select languages, rate picuters, and like it on Facebook besides placing comments.

The code was written in PHP mostly. I could get rid of the javascript that I used at the previous version to handle user enteraction when forward or backward selected. For the dinamic contents I use SQL databases and queries.

I developed and tested it offline on my PC useing XAMPP. Whitch contain apache and sql server as well as an ftp server. It has great features so I recomand it to everyone.

About hosting. My host is www.000webhost.com its free of course and they don't delete your site if it is look dead.

If you have any question about the gallery dont hasitate to ask.