Space Invaders

I remember when I was around 10 years (in the early 80’s) old my family started to go to Genting Highlands for vacation during the Chinese New Year holidays, almost every year. As our parents and my uncles and aunts went to the casino to try their New Year fortunes, my brother and other older cousins head towards the arcade games room with me tagging along. That was when I first saw them.

It was Space Invaders first, then Pac-Man and Galaxian. We were totally hooked. 20 sen coins went fast and furiously into those machines, until our cash reserves were exhausted. Life was never quite the same after that. It wasn’t as if I was really that good either — I never went past the first few levels anyway. I suppose I never really had enough coins to play for too long but those times at the arcade games changed me in different ways. I realised that machines can be intelligent and interactive, and fun.

I suppose after so many years this has never left me — I’m still trying to ‘play’ with every single machine I see, every time I buy a new piece of hardware, the first thing that comes to my mind is — ‘how do I program it?’ Well, I bought a Gameboy for my son a few months back, and an NDS Lite for myself last month. The question of programming both of them naturally came to my mind especially when the NDS has mouth-watering wifi capabilities, two screens, with one of the being a touch screen and amazing graphics and sound system.

Of course I’m no game programmer — have been doing only enterprise applications for most of my working career (11 years and counting) but it’s something that really caught my imagination. I started thinking back to my days at the arcade with the Space Invaders. Well, yes, it’s the first arcade game and it’s really primitive but it’s fun as well. So that’s what I wanted to do — a Space Invaders clone on the Gameboy. There’s one already in the market but this one will be all mine.

I promised myself to do it after my GCIA exams, and here I am about to embark on it. I spent a couple of hours fiddling around it and I got a sprite bouncing back and forth the screen. Nothing spectacular but it’s a start. At the end of it I’ll write a short tutorial on how it could be done. Wish me luck!

Advertisements

Layouts and AJAX support for JSS

I added in layout support, as well as some fundamental AJAX support for JSS. I’ll put in a tutorial later to show exactly how it’s done, but for now a quick description of how to do layouts in JSS:

Layout support

There is a layouts directory under the views directory which contains a list of all your layouts. For example, let’s say you have a layout file called main.jsp. Your layout file might look something like this, though you can do whatever you like with it:

<%@ taglib prefix=”jss” tagdir=”/WEB-INF/tags”%>
<html>
<head><title>JSS Recipe Demo</title>
<style>
table {
border: 1px solid black;
}
body {
font-family: verdana;
}
</style></head>
<body>
<jss:content_for_layout/>
</body>
</html>
table {
border: 1px solid black;
}
body {
font-family: verdana;
}
br /> body {
font-family: verdana;
}<br

Where you want the content to be placed (i.e. your content) put in the tag <jss:content_for_layout/>. At the top of your controller file (e.g. recipe_controller.jss), after the import statement, put in the layout declaration:

layout = “main”;

where main is the name of your layout file.

That’s all! All your views under this controller will be using this layout. If there are any views you don’t want to have a layout, just put anywhere in your view method:

layout = null;

If you want to use another layout just for that view, you can also set the layout to something else e.g.

layout = “report_layout”;

So what does it do? Using a layout for a controller allows you to enforce the same look and feel or have shared data for all the views under the same controller. This extends to the rest of your web application. I’ll talk a bit more about the AJAX support in another post.

Arsenal lost

Don’t want to talk about it … depressing. Woke up 2am in the morning to watch an exhilirating but ultimately disappointing match. Arsenal fought admirably though and Ronaldhino was quite pathetic most of the game. Hope he improves in time for the World Cup in Germany … I’m supporting Brazil as usual :)

Liverpool wins FA Cup!

Stayed up to watch the FA Cup — brilliant match! Steven Gerard is a powerful player, two stunning goals from him saved Liverpool from the brink of disaster. Quite amazed that Jose Reina saved 3 out of 4 penalty kicks. Issue with the West Ham penalty takers or Reina is simply too good? Second time in a row that Liverpool won a trophy in an nail-biting way, and through penalties, last year’s Champion League and now this year’s FA Cup.