Archive for the nonsense Category

I am an idiot.

Posted in LISP, nonsense, programming with tags , , on September 11, 2008 by bbarrett

I have just figured out where I am going wrong. All my variables are stored on the LISP stack, which is a std::vector<Cell> instance, (Cell is the variable type). Some of these Cells themselves contain Standard C++ Library objects (lists use std::list<>, functions are std::vector<Instruction>, strings are std::strings), and references to those objects are stored on the C++ stack during operation.

A few functions deep, when stuff keeps being added to the stack, it eventually will reallocate and… boom, all my iterators and references die a horrible death. Took quite a while to figure out that this was going on, I was preoccupied with assuming there was an issue with the Cell’s implementation of the Rule Of Three. I had already had issues with that, as I mentioned before.

For the moment, a “quick fix” is to manually set the initial stack size quite high. I think with this my current implementation works fine, but I hate such an ugly fix, which is too brittle anyway. I could choose std::list<>, so elements won’t be moved around in memory, but there might be another way.

That took far too long to diagnose…



Posted in nonsense, programming with tags on June 5, 2008 by bbarrett

Long time no post. Well, I am finished my degree now, so that – theoretically – should leave time for some projects.

Content for once

So, I made a little progress during the week. I was playing my Asteroids game from a USB pen and it really showed me how my dynamic loading of files was slowing me down. Due to the way I wrote the game, nothing is preloaded (because all graphics and audio files are referenced from external scripts). They are loaded on demand. They were cached once loaded however. On my laptop hard drive, the delay is slight, but still perceptible. I must have gotten immune to it somehow – but since the USB pen thing I started to notice it more and it irritated me.

I wrote a little function that can be called from Lua (a running theme) that takes a directory and a function. It applies the function to every file in the directory and its subdirectories. The function is called with two arguments, the path to the file and a file size. The code for doing this is quite simple – I used the opendir() and readdir() POSIX functions, along with stat() to determine whether to recurse into a directory or to get the byte size of a regular file.

From Lua then I just loop across the data directory, and preload files that look like images or sound files. I haven’t yet implemented preloading lua files, and I’m not sure if I will (given that the majority of the are referenced by the script running the preloader). I’m thinking of breaking the script in two – one that is run at program launch and another that is run at “new game”. At the moment the same script handles a bit of both. I might consider using file watches (or listeners, or whatever they’re called) so I can be notified when a Lua script changes and reload the data, but that is far less likely.

Next up, some kind of graphical progress bar, rather than just using the window title text…

Alive… barely

Posted in nonsense on May 14, 2008 by bbarrett

I haven’t updated in quite a while. Still, I almost have an excuse. I’m finishing my degree this year, and as such the last month or two has been a blur of projects and exams. I’ve just started the final exams, which will go on for the next two weeks. Perhaps then, and when I’ve had a little time to get some proper sleep, I’ll start posting actual content again.

Until then…


Posted in nonsense, programming on January 9, 2008 by bbarrett

This week has been slow programming wise. I added/changed a few minor things on my Asteroids game. I also did most of a project for college.

The big news for me is that I have secured the services of both graphics and sound artists for my Asteroids game. When the various media are finished then I will be able to release it.

I have another project in progress, one that will probably get a lot more of my attention now that my Asteroids game is coming to a close. It is a ray tracer. This, of course, gives me an excuse to post a screen shot.

Continue reading

Project: Asteroids

Posted in nonsense on January 1, 2008 by bbarrett


I’m Brian, and I write games. I’m coming towards the end of development of my Asteroids clone. It has really come along and I’m hoping to release soon after New Year. It is a relatively simple, doesn’t do anything extraordinary, but can be fun to play. I’ll probably be using this blog to talk about programming, but game development in particular. More soon.

Happy 2008 everyone.