Friday, February 13, 2009

Installing Allegro Developmental Branch 4.3.10 on Ubuntu

Last night I spent a fair bit of time reinstalling Ubuntu and downloading all the packages I need for video playback and other stuff you do when you first install Ubuntu. When it came time to install Allegro, I decided to skip getting the repository version, and go for the latest 4.3.10 version. I had a bit of a hard time so here is a list of instructions on what you need to do to get it working for others with the same troubles.
  1. Download Allegro from http://sourceforge.net/project/showfiles.php?group_id=5665&package_id=40805&release_id=569935 get the file named allegro-4.3.10.tar.gz
  2. Extract the files into a folder of your choice. I extracted mine like thus /home/cosmicr/Projects/allegro-4.3.10/
  3. You need to do all this stuff as root, so type sudo su (enter) and type your password.
  4. Next, because mine was a fresh install of Ubuntu, I didnt have autoconf installed. So load up the Synaptic package manager and install autoconf.
  5. This next step is only required because we are compiling the Developmental Branch.
    • From terminal, cd (your installed folder)/allegro-4.3.10/
    • autoconf (enter).
  6. Here there are two options. You can dynamically link the library, from the same directory now type ./configure (enter).
    This may take a minute or so.
    Or second option is to type ./configure --enable-static (enter). The second option is how the library in the repository was built.
  7. At the end of the configure process it will tell you which modules wont be built because you dont have those packages installed. At this point you might want to go into Synaptic and install those packages, especially the X11 development files.
  8. If you installed new packages, you'll need to run ./configure again.
  9. Now type make (enter).
  10. After make is finished, type make install (enter).
  11. At this point you're good to go, but you can also run make install-man to compile the manuals too. There's a whole heap of manual compiling options, such as pdf etc. Have a look at the instructions in the build folder.
To get it working in Code::Blocks, normally you would add this to linker options: But if you didn't compile with --static-enabled instead you have to put
And thats about it! Everything should be good to go.

Thursday, February 12, 2009

Starting from Scratch

I thought I'd give Windows 7 Beta a go. It was a big mistake. The installer crashed whilst re-sizing my partition, and so I lost my install of Ubuntu with all my code too. Luckily I had documented some of it here (and in my google docs account).

But since that has happened, it has allowed me to re-install Ubuntu and do it the proper way. I am going to put my home folder on a separate partition.

Now I am re-considering what game library I want to use. I am completely familiar with Allegro, but sometimes its good to step outside your comfort zone. I am considering SDL, OpenGL, SFML, and I've even had a look at the DarkGDK. Now most of these more modern API's are geared towards C++ or object oriented programming, which I'm still not quite ready for yet. I get a lot of pressure from people telling me its easier every time I post for help on a forum, but I promise - my next project will be in C++.

So which one to use? Some would say the most obvious choice is SDL. I have had a look at it the most and even compiled some test programs. There is heaps of documentation on the internet, however not quite as much as Allegro. The best sources of documentation and implementation are LazyFoo and the ones found here http://www.sdltutorials.com/.

I am going to stick with Allegro for now, but my next project will use SDL. As I write my code, I will post it for others to learn.

Friday, February 06, 2009

More on Pathfinding

After re-reading my previous code, I have realised that there are a few things that can be done to optimise the code, whilst still keeping the same method of static arrays.
  1. The Struct list_s could be made to a typedef, and *path declared only inside the findpath function, eliminating the need for the initnodes() function.
  2. node.onopen and node.onclosed could become one variable of either TRUE, FALSE, or NULL.
  3. There's no need to keep the f value on the list.
  4. The instances of 40 need to be replaced with a constant tilesize or even tilew and tileh.
  5. The map and its associated dimensions could all be passed to the findpath function.
  6. Some error checking needs to be included, such as what if there is no possible path? At the same time, some checks already included might be able to be removed.
Also sorry if the code is a bit hard to read, it looks great in code::blocks, but the width of the blog restricts it. If you're having trouble, copy and paste it into your editor and it'll be a lot easier. When I get the chance I'll go and edit it to be easier to read.

Oh yeah, and on a side note, I've noticed that the code syntax highlighter I'm using (http://www.dreamprojections.com/syntaxhighlighter) doesnt seem to work properly in Firefox for Ubuntu. I'm not sure if its working in other firefoxes (such as windows) but it does work in Internet Explorer, which is what I'm using most of the time (I know - dont ask!).