From the Burrow

Python and Emacs

2012-08-12 00:00:00 +0000

When I first started getting into using Emacs for all my editing I had major problems trying to get a decent Python setup working. I spent hours messing around on line getting nothing but a headache, it almost made me drop Emacs entirely. However after finding a couple of clearer tutorials I was able to bodge something together, but if I’m honest Its never felt good enough. Luckily it seems that some lovely soul has put together this!

In the author’s words, the goal is “collecting and customising the perfect environment for python development, using the most beautiful emacs customisation to obtain a really modern and exciting (yet stable) way to edit text files.”

Next time I do some Python hacking (i.e. when I can tear myself away from Lisp!) I’ll try this out and let you know how it went.

Hopefully this can help some other Python loving Emacs noobs get started with a really slick python environment.


In other news I’ve written a .obj file parser so I can read some 3D models into cepl (my lisp opengl experiment). I should have something to show you by the end of this week.

Goodnight!

Entity Systems in Games

2012-08-11 00:00:00 +0000

As I have been making good headway on studying OpenGL I have been starting to have a look into more of the things I will need to make real games using my tools.

One of the obvious first steps is working out how I will manage all the different types of ‘things’ (lights, boxes, triggers, explosions, hats..and err..BIG HATS) in the games and also how to defining and extending their functionality as easy and powerful as possible.

It doesnt take much googling to see that object-orientated programming is not actually the way to go. This seems strange at first as OO can seem a natural fit for defining types of object. I mean you can have something like this:

character
  |
  |__human
  |   |___soldier
  |   |___civilian
  |
  |__alien
       |____alien queen
       |____alien soldier

But it turns out that in real life, things change (who knew?!) and, as new type of object are need in the game, functionality that use to be specific to one class of game object has to be moved up the tree.

For example, lets look at out pretend object hierarchy above. When the game designers first added the ‘alien solider’ they wanted to let it be able to call re-enforcements, this is fine but the ‘human->solider” also has this functionality. As good coders we want to reduce code duplication but where do we put the ‘call re-enforcements’ functionality? The only shared class is the ‘character’ class so we would have to put it there…but now this means that the ‘civilian’ and the ‘alien queen’ also inherit ‘call re-enforcements’ even though they will never do this in-game.

It turns out that this kind of thing happens a lot, and you start getting classes (like ‘character’ here) which become dumping grounds for functionality. These classes are often called Blobs.

Ok so if this isn’t what we want then what other options do we have?

Well the one that is interesting me is called an Entity System. It detatches the functionality from the data which allows for composition of game objects in a way that is much more flexible than multiple inheritance …well rather than me doing a poor job replicating the articles I have read I will just link them below, hopefully they will help you as much as they have me.

Right I’m very tired now, Goodnight Everyone!

Ch-ch-ch-ch-modifications

2012-08-07 20:05:00 +0000

Well I’ve been very quiet recently and that’s mainly down the my mild addiction to playing with Lisp. I been beavering through Let Over Lambda which ia fantastic book on the crazy stuff in common lisp (code that writes code etc) which has been bending my mind plenty.

I’ve also got sick of how the opengl interface works and have gone on something of a spring clean. I’ve made some tools on top of the exisiting common lisp opengl library in order to make it a nicer to work with.

Its definitely not ‘lispy’ enough yet but pushing data into buffers, making vaos and managing programs and their uniforms is much easier now. I’ve got it all up on github though I wouldn’t recommend playing with it yet as I’m damn sure there will be some HEAVY changes before I’m happy with it.

Here is a quick video of me playing around with a small chunk of code which handles the rotation of the objects in the scene. Notice how errors don’t crash the program and I can simply recompile the offending function and carry on. Also note that the repl still works so I can mess around with the camera position from there.

I’m now bored of these little 3D whatchamagigs now so I need to write an importer .obj files so I can get something interesting up on the screen.

Ciao

Today's Blob of Inspiration

2012-08-07 00:00:00 +0000

Its’ wonderful just to see some of the people involved and their passion. Watch this after you have had your fill of the landing itself.

It really feels like the start of something huge again, the SpaceX docking had me tearing up and this just caps it off for me, Well done to everyone involved, I cant wait to watch the next few years of this.

Jekyll and YouTube Videos

2012-06-21 00:00:00 +0000

If you are having problems with embedding youtube videos in Jekyll blogs and getting errors then check out this link.

It turns out that the markdown processor doesn’t like the ‘allowfullscreen’ part of the embed code.

Delete it and the video embeds just fine!

Its moves, IT LIVES!

2012-06-20 00:00:00 +0000

Here is the first little video showing a 3d object translating and scaling while I edit the code and inject it into the running program. This really makes tweaking lots of fun as even the errors can be corrected without having to close the program and recompile.

Slowly Getting There

2012-06-17 00:00:00 +0000

Learning OpenGL in lisp is pretty cool, its my first lisp project, first time using opengl and first time learning the workings of a foriegn function interface. All this makes for hairy debugging as its always nice to learn from some familiar terortory so you have a rough idea, when something goes wrong, whether it’s you cocking up or some other bit of code.

This time however,no such luck.. Each problem has the potential to be me missunderstanding the tutorial..or OpenGL…or the C++ code I’m translating from…or the lispy abstractions around the c library provided by cl-opengl! But there is progress… I’m up to tutorial 5 in the awesome modern OpenGL tutorials at ArcSynthesis.

It doesnt have a depth buffer yet so the smaller object is actually further away than the apparently larger one, but that in the next tutorial!

Rosetta Code and Studying

2012-06-10 00:00:00 +0000

This is really a ‘note to self’ but if you are learning a language and have experience with other, then the Rosetta Code really help when you hit that problem when you yell “THIS IS SO EASY IN -insert language here-!”.

While trying out Common Lisp and I keep coming up against little problems that I would happily tap out fluently if I was coding in Python but which in Lisp leave me scratching my head. Rosetta Code has helped a few times now and yet I keep forgettign about it…Hopefully now I’ve wirtten this it may stick!

Lisp, OpenGL and Uninterrupted development

2012-06-10 00:00:00 +0000

As with anything I want to learn, it seems I need a project to drive me. The project is often WAY above my ability but it makes for a very motivating goal to keep in mind while trudging through the more tedious/mind-braking parts of whatever I’m studying.

The project I have in mind with Lisp is a live game coding environment. I listened to an awesome talk on FLOSS Weekly a little while back on Overtone, a live music coding environment, written in Clojure. If you are struggling to see how this would work have a look at this video.

The real feeling I get here is that, just like in music, coding can have composing and jamming. What I mean is that programming (to me at least) can often feel like I’m composing, I am primarily solitary, noodling around with little ideas and bits of code until I get a good idea of where I’m going and then I need to plan and write so I can eventually present what I have made.

Jamming has the result visible from the start, and because what is happening is immediately viewable (audible) other can chip in and shape the result, even if they are not playing themselves.

I want to do this with code, specifically visual programming and games.

These ideas obviously aren’t new, they have been said plenty of times before, and there have been strides in the direction. Every time the speed of iterating in a language is improved, we are one step closer to this goal. Recently a fantastic guy called Bret Victor gave this amazing talk where he explained that “creators need an immediate connection with what they’re creating” and demonstrated it beautifully with (amongst other wicked demos) a 2d platformer where the changes he made in the code were immediately reflected in the game. This seems cool enough but the result of this immediate feedback is that he could ‘jam’ with the code, he could make changes with worrying about crashing out of the demo and just explore the ‘what ifs’ of what he was writing.

Now while Lisp doesnt implement this at all it does have one feature that is very nice, you can compile the code for a single function and add it to the running program. This also means you can redefine the code you are running while it’s running which is a great first step.

Just a minute ago I was able to load up the OpenGL tutorial I was working on which involved a triangle moving in a circle (yup I’m starting from scratch!) and, just by virtue of the code being written in lisp, I was able to change the colour, path, speed of the triangle and immediately push the changes in the code into the running program and see the effects they had.

I could also see how things broke if I messed with commands in the wrong way, and thanks to how lisp handles exceptions I could undo the change in the code, push the change into the program and tell the program to continue using the new code, and in only couple of seconds. I must admit, it felt fantastic!

I’m putting at the work I’m doing on github although there’ not really much there yet, I will post here with videos and pics as more takes shape.

Take care, happy jamming!

Finding out you OpenGL Version under Ubuntu

2012-06-10 00:00:00 +0000

If you need to quickly find out the version of OpenGL you have along with the version of GLSL you can use then run the following at the command line.

glxinfo | grep -e "OpenGL.*version string"

Remember that if you have 2 graphics cards that you will need to be aware of which one it will be checking. For me that meant running:

optirun glxinfo | grep -e "OpenGL.*version string"

As I am using Bumblebee to enable use of the optimus graphics setup.

Mastodon