Pages

Tuesday, May 21, 2013

NyanChat! Complete

This was my first attempt  at creating a fully functional chat application in Java. Sure, it has plenty of bugs, but it works. Should be great for your programming projects or just to read through.

You're probably here because you're looking for something like this anyway.
Here's the link:

Download NyanChat!

The source code and executable jar files are included. Along with an odd user manual. Don't pay much attention to it, really.

Tuesday, May 7, 2013

Great Success! Get SFML to work with Code::Blocks IDE

Hello!
I said I'd report back, and that's what I'm doing. I know I'm a couple of days late, but, better late than never right?

On to the good news. I finally managed to get SFML to work. How? Well, the boys over at SFML-dev have updated their website, source code and tutorial quite recently. With this brand spanking new update, alot of things have been fixed. That means it's much easier to set up and use. I shall guide you through the process now (which is the main reason why you're here, right?).

Note that this tutorial is intended for Code::Blocks IDE on Windows. If you're using another one, try their official documentation first.

  1. Go the the Code::Blocks download page and grab yourself a binary release WITH the MingW compiler. If you're into building from source, they have those as well.
  2. Install or unpack it.
  3. Write yourself a small C++ program in Code::Blocks to make sure that it's set up properly. If it compiles and runs fine, then you've got the easy bit done.
  4. Now scoot on over to the SFML download page and grab the GCC 4.7 TDM (SJLJ) version (either 32 or 64 bit depending on you're system). In my experience the DW2 version gave me errors. If the SJLJ version gives you errors, try DW2. 
  5. Unpack the contents of the zip on your hard drive (somewhere safe, with read and write privileges). Open up the directory and locate the include and lib folders. Remember them.
  6. Go to Code::Blocks, click on the settings menu bar, and go to compiler. In older versions of Code::Blocks, it's called compiler and debugger.
  7. Under Global Compiler Settings, search for the Search Directories tab and click on it. Now, in this tab, you have more subtabs, two of which are called compiler and linker.
  8. Under the compiler tab, add the directory to SFML's include folder from step 5. So if you unpacked the zip to the root of your C: drive, an example of the directory would be C:\SFML-2.0\include.
  9. Under the linker tab, add the directory to SFML's lib folder from step 5. If unpacked to the same place, an example would be C:\SFML-2.0\lib. Click OK to apply your settings
  10. Phew. Okay, now we need to add SFML's libraries to the linker. Next to the Search Directories tab is a Linker settings tab. Click it.
  11. Under Link Libraries, add the following libraries IN THIS ORDER. i.e click on add, navigate to the lib folder in SFML, and add libsfml-graphics.a, libsfml-audio.a, libsfml-window.a and then libsfml-system.a (libsfml-graphics.a must be at the top, libsfml-system.a must be at the bottom). If you're project is using some networking libraries as well, don't forget libsfml-network.a as well.
  12. Click OK and apply all settings. Now, navigate to the bin folder in your SFML directory and copy all the .dll files into the folder your project's executable is found, which should be the bin folder of your project.
  13. Time to test out your code. Create a main.cpp and enter this code:
Now compile, and run. Voila!

Okay, if this doesn't work for you, let me know.

Friday, May 3, 2013

A C++ Library that lives up to it's name (sort of)

Hello again. You remember me, right? Of course you do!

You wouldn't be here otherwise.

Recently, I've been tasked with developing an educational game as a 3rd Year Computer Science Project. It also happens to be a group project, which helps with the workload. However, it has to be done in C++.

<sarcasm> Great </sarcasm>

If those HTML tags don't work for you, you should try updating your browser.*

Now, for a group of students who spent a majority of their high school and university career developing in Java - being thrown into the deep end with a language that has no native libraries for simple media processing and GUI creation sounds like development hell. It is, especially when you have just over a month to complete it (don't forget other projects and tests being  thrown into the mix!).

We were cut some slack, though. We have the freedom of choosing our own IDE and libraries to use for our project, which should make our lives easier. So, after much research and debate, we narrowed the possibilities down to three options:

  1. Visual C++ 2010
  2. QtCreator
  3. SFML
The first option would have been great. Until we realised that we are developing in Linux (more specifically, Fedora 14). So we threw Visual out the window. Splat.
QtCreator was our next option. It looked promising, but at the end of it all, we learned that it's commercial software and we have to BUY it. The trial version lasts 30 days. That's less than our expected development time and we didn't want to take any risks. 

So, we were left with SFML. It looks promising, and we can use it to create a rather pleasant looking game with sprites instead of fancy coloured GUI components. The problem that arose with SFML, however, was setting it up.

No matter how closely we followed the tutorials, we always ended up with either an executable that refused to execute (in some rare cases, it would execute but crash immediately) or the IDE would not be able to find the library at all. Many people around the world (even some of my fellow classmates who wanted to use the library for their game) have a similar issue, but what boggles me is that others have managed to get it to work.  

I've used the MingW version with Code::Blocks and Eclipse, to no avail. On Windows 8 it compiles but the executable is broken. On Ubuntu 10.10 and Fedora 14, both IDE's can't find the libraries, even after we've added them to the libs and the linker. The other option was with Visual C++ 2008, so I tried the SFML version of that as well. The results were still the same.

I refuse to give up on this. I've been working with SFML 1.6, so I think I should try 2.0 next time. After I compile it from source, that is. I'm also going to try this in Windows 7, using a slightly older and less buggy version of Eclipse. 

I shall have results tomorrow, and I shall make a note of them here. If I get it to work, I will post a nice little tutorial on how I managed to get it working. If you managed to figure out the relevance of the title of this post with some of it's content, a million points to you.

*I was being sarcastic here, too.