Thursday, 9 April 2009

Mac usable coloured terminal

When using a terminal window on the Mac (or on any system!) if everything is the same colour it is difficult to tell the difference between file types. E.g. there is no difference in presentation between a file, a directory and a link.

If you are using a bash shell (it tells you in the title bar what type it is), you can configure colouring using your profile. This lives in the file: ~/.profile. Add your changes to the end of the file.

There are some helpful blogs with information on what to add, but I found the bold lettering difficult to read. You achieve something more readable just using 'ls -G'. So add:

alias ls='ls -GF'
alias ll='ls -hl'

The -F option also tells you what the object type is (man ls), and ll adds an extra command to save doing ls -l.

You might also want to change your terminal prompt. The default is the machine you are logged into, which is a little pointless if you know it, and takes up a lot of screen. I find the following quite useful:
export PS1='\t \w> '
\t gives you the time in 24 hour format. It also gives seconds and can be a useful way of timing commands roughly. \w tells you the current directory.

Tuesday, 17 March 2009

First Jython experiment

W00t! Got first Jython program working with GTGE:
# Test of Jython and GTGE.

# Java Foundation Classes (JFC)
from java.awt import *

# GTGE API
from com.golden.gamedev import *


"""
**
* The basic skeleton of Golden T Game Engine (GTGE).
*
* Objective: show how to set up a new game.
*
"""

class Test(Game):

def initResources(self):
# initialize game variables
pass

def update(self,elapsedTime):
# update game variables
pass

def render(self,g):
# render to the screen
pass


def main():
game = GameLoader()
game.setup(Test(), Dimension(640,480), False)
game.start()

main()


I decided on GTGE because it seems like it has been used for a lot of games so far, and so is fairly mature. It has also just been released as open source and seems to fairly well supported. We'll see.

Anyway, have a working Jython program that create a GTGE window. Admittedly the authors of GTGE did all the work and I just converted a Java tutorial into Python. Original Java code:
// JFC
import java.awt.*;

// GTGE
import com.golden.gamedev.*;


/**
* Game in Windowed Mode Environment.
*
* Objective: show how to set up a windowed mode game
*/
public class Tutorial5_1 extends Game {


/***************************************/
/************ GAME SKELETON ************/
/***************************************/

public void initResources() {
}


public void update(long elapsedTime) {
}


public void render(Graphics2D g) {
}


/**************************************/
/********** START-POINT ***************/
/**************************************/

public static void main(String[] args) {
GameLoader game = new GameLoader();
game.setup(new Tutorial5_1(), new Dimension(640,480), false);
game.start();
}

}

Sunday, 15 March 2009

Safari 4 Beta

Just trying out Safari 4 beta. Previously I decided Firefox 3 was better than Safari 3 because Safari didn't seem to add any advantage, as Firefox has lots of customisation options.

My initial impression is that Safari 4 is really fast. Pages appear notably faster than Firefox 3. It will be interesting to see Firefox 3.5 improvements. I wonder if they'll beat Webkit.

Other reviews (The Unix Geek: Safari 4 Review) have pointed out new features. I agree that moving the tabs into the title bar is a great idea as it gives more space. This is especially important on laptops where the screen isn't as tall. It's a relatively simple change but being able to read a couple of extra lines makes all the difference.

I also found a plug-in to allow use of Delicious bookmarks. It's not as well integrated as the Firefox one, but it'll keep me using Safari until I can try Firefox 3.5. Having your bookmarks stored online is a great usability boost for web usage, and having this well integrated with the browser is just as important.

The new bookmarks viewer in Safari 4 looks interesting. You can scroll through previews of your bookmarks or history. This a great if you are doing research and trying to find a site you bookmarked to read later. I hope someone is working on a Delicious extension for this. Now that would be cool.

Saturday, 14 March 2009

Java games

Been wanting to write a little game for fun. There are lots of ways to do this!

There are good C/C++ cross platform game libraries. One of the best I found is Clanlib. It's well designed and contains everything you'll need. Libraries like SDL provide simple cross platform APIs but extra functionality is via extension libraries which tend to be low quality or not maintained. Clanlib provides more of a coherent framework, and uses OpenGL for all rendering, so there are no platform specific quirks.

Using Python and PyGame means you don't have to recompile per platform. PyGame provide bindings for SDL. High level languages, like Python, are nice for prototyping and knocking experimental games up. You also don't need to worry too much about performance these days since most PCs have more than enough horsepower.

If you want to get your game to the widest audience then probably the best way is to make is playable in a browser. Downloading executables from the web is a lottery. Any program could contain malicious code. Running them in a browser gives people more confidence nothing nasty will happen. Flash is quite popular for this, but I didn't really grow to like it when experimenting with it. Now that canvas has arrived, Flash may be on the way out.

I've never really used Java, I suppose I haven't found a use for it. I use C++ for performance programming and Python for scripted tools etc. An interesting Python variant is Jython, that is, Python written in Java. This allows you to compile Python code into Java. So this seems like a good compromise, and allows you embed your Jython applet in a page to be used.

Using Java and Python also allows me to use Eclipse, which is a great development environment. We'll see how it works out.

Saturday, 10 January 2009

Hot Chicks With Douchebags


If you haven't come across it yet I suggest you get over to "Hot Chicks with Douchebags". It's pictures people have sent in of the "choice" trendy set.

Not a lot you can say really, the title says it all. Here are some of my favourites. :-)





What is so brilliant about some of the posts are the Haikus. For example:



Crotch first, Glenn triumphs,
Two Russian Cougars from Queens,
And the Hair Point. Dude.

Hair tapered to point
reminiscent of a turd
that I just pinched off.

Inga: real estate
Olga: low-rent "socialite"
Glenn: sanitation

So full from dinner,
Pointy reclines and begs you
To sniff his blue jeans

Looks like all three shop
at H&M, buy one girl's
black shirt get two free