Nanode for dummies

I’ve always been interested in electronics that could control stuff in the real world. Back twenty years ago I used the Commodore 64 to control some motors etc. and had fun with that. It was fairly easy because everything on the serial port was directly available. A peek here and a poke there, and you could do everything! If you had a LED you could wire it up directly into the C64 and turn it on using only two poke commands.

But then the world changed, OS’s became complicated, and the serial port even pretty much disappeared on all computers. USB was the new thing, but USB is seriously complex. Both coding for it, and just to turn on a LED you need a load of electronics at the far end of the USB cable.

Then came the internet, and everything had to be online. All my dreams about controlling stuff sort of boiled down to: “I want it to be online and easy to do.” and thus went nowhere for 20 years… until today where I got my hands on a Nanode board. The only problem was that I hadn’t fiddled with electronics for 20 years! This is how it went…

Continue reading

Function pointers in Java

Java does not have function pointers. They are not really needed… and I have never needed them either in my 10 years of Java coding. However, I came across a rather interesting solution at work. This solution was coded in a completely different language and utilized the fact that programmers could write small bits of code, and these bits where then connected, at runtime, identified only by their name. The system makes it possible to have a model outside the actual code. And then by changing the model, the behavior of the system will change as well without needing any compilation.
“Is this even possible in Java?”, I discussed with a colleague… and we quickly agreed that it was not “the Java way” to do stuff. However, of course this needed to be tested 🙂

Continue reading

Playable game

Yesterday was sunday and I had no plans what so ever. Finally some time to do some coding 🙂

The little java game is actually playable now. Its possible to complete levels, and the game now has four tutorial levels.

I’ve compiled a runnable JAR file for download here. If you have the JAVA 1.6 runtime installed you just need to double click it to run it.

Continue reading

More 2D Java gaming

Seven hours of further work on the game and its starting to look like a game. Some proper graphics have been added and I’ve started to code the game logic. I want pixel perfect collision detection, but since hardware assisted features like these have gone to hell during the last 15 years I have to code it myself. On the picture theres an extra window open for debugging purposes. This window shows what the collision detection algorithm sees. I was worried that this was going to be slow so I optimized it quite a bit. I still ended up with a system that does 65536 comparisons every frame…. but since cpu power has gone WAY up during the last 15 years this didn’t even bother the system at all. In fact I can hardly even measure if the collision detection is on or off.

Creating a Java 2D Game just for fun

To refresh my Java skills I started making a little game. I’ve always liked the good old Thrust and back in 1994 I wrote a similar game for the Amiga. Back then it took me 3 weeks of hardcore assembler coding. The Amiga had hardware support for two layers of graphics and 8 sprites(Smaller graphics objects). This included hardware collision detection between all those elements. This made it fairly easy to write a game with a ship (one layer) and stuff that it shouldn’t hit (The second layer consisting of a tile based world.) and a bunch of missiles(Sprites) that the player could shoot with.

The result was a nice little game where the player controls the rotating spaceship through a maze of rocks, shooting stuff, and carefully maneuvering towards the exit. It had multiple levels, sound, and high score table.

Now 15 years later I wanted to recreate the game on the PC… of course bigger and better.

Continue reading

XCode experiment: Screensaver

Apparently I had too much free time because I decided to play around with XCode and have a go at Objective C.

The result is a screensaver.  It simply draws random colored blocks in a zigzag pattern up across the screen. At the same time it fades them out, but due to some strange effect that happens with drawing using BezierPaths and alpha channels…that I honestly haven’t quite figured out yet… they aren’t all faded out evenly. I like the result and find it pleasing, like looking into a fire or something.

So.. even though this little project turned out nowhere near what I planned its still one of the most best pieces of hobby programming that I’ve created in years 😀

Perhaps you’ll like it as well…. get it here. [Edit: Now compiled for Snow Leopard as well. I don’t know how well it will work on other systems though.]
I also uploaded the entire xcode project here in case you want to have a look at the actual code.

Since this is an xcode project it means that the screensaver is for Mac only. It may even be so that you require an intelbased mac… or perhaps it even requires you to run Leopard or something. I only got one mac.. and it works there…and thats pretty much all the testing thats ever gone into this project. What I’m trying to say here is that “your milage may vary” … and don’t blame me if your Mac explodes and burns down your house or something. You could leave an angry comment though, if you want 😀

bloxscreensaverpicture