mipesom

Sep 102012
 

In these tutorials, we will create a Super-Mario-like jump&run using C++ and SFML. First I will show you how to install Qt-Creator and how to setup a little SFML test app.

I’ve chosen Qt-Creator since it’s the IDE that I usually use for C++, it’s free and external libraries are much easier to include than in Eclipse Indigo with CDT. I use Linux, but you only have to replace the paths to follow on Windows.

I’ll use SFML 1.6 for now, but will update the tutorials for SFML 2.0 when there is a final release. And please let me know in the comments if there is interest in Python+PySFML tutorials, too.

Let’s install Qt-Creator

Go to this site and download the version for your OS. (In my experience, the online installer saves time, but you can of course use the offline installer, too. We need Creator, but you should download the Designer and the source code too, if you want to use Qt for more than SFML)

After downloading it, you’ll have to make the file executable. You can use your filemanager for this (Dolphin, Nautilus,.. – right-click the file, pick properties, go to the permissions tab and mark “is executable”) or you use chmod u+x QtSdk-online-linux-x86_64-v1.2.1.run in terminal (you have to adjust the filename and don’t forget to go to your download folder first). Execute (file manager or type ./QtSdk-online-linux-x86_64-v1.2.1.run in terminal) the installer then. (run it, don’t kill it. ;) )
Make sure that all parts you want to install are marked and let the installer do its work. You can easily change the configuration later by using the maintenance tool, though.

Next task: Installing SFML

If you’re also using Linux, you’ll find SFML 1.6 in most cases in the repositories of your Linux distribution.
If you’re using Windows, Mac or a Linux distro that doesn’t offer it in the repositories, you should visit this site and download the version for your OS.
Unpack the archive in filemanager or terminal. Switch to your Downloads directory in terminal (cd ~/Downloads) and use cd SFML-1.6 and then sudo make install.

Let’s open a SFML window to test the setup

Pick New file or project…from Qt-Creator’s File menu.

Screenshot of project creation

Pick the Plain C++ Project from Other Projects, click next and type C++SfmlSM in the project name field. Click next twice and then finish without making any changes.

Screenshot Qt

The result should look like this. (Click to enlarge)

Open the c++SfmlSM.pro file by double-clicking it (it’s right below your project name in the projects view) and change it into this:

TEMPLATE = app
CONFIG += console

SOURCES += main.cpp

LIBS += -L/usr/lib -lsfml-graphics -lsfml-window -lsfml-system -lsfml-audio 

INCLUDEPATH = usr/include

You see that we erased the subtraction of Qt. We don’t want to write a Qt program, but we want to use one of its functions, qDebug(), for our convenience.
Furthermore, we added the include path and the libraries for SFML. (Windows or Mac users will have to adjust the paths. That may be needed even on some Linux systems – when you installed SFML in your home directory, e.g.)
If you followed the manual SFML install earlier, please change the paths to -L/usr/local/lib … and usr/local/include in the .pro file above!
If you ever tried to integrate external libraries in Eclipse, you’ll love the simple approach of Qt-Creator!

Double click main.cpp and replace its content by copying the following source code into it

#include <iostream>
// Qt-Creator delays output to the console via cout till the app is finished. 
// With qDebug() we get it at runtime
#include <QDebug>
#include <SFML/Graphics.hpp>

using namespace std;

// Creates the RenderWindow with a size of 800*600 and 32 bits colordepth as 
// a global variable
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "Jump & Run Tutorial");
// The event that we use to catch the closing of the game
sf::Event Event;

bool init() {
    // return that initialization was successful
    return true;
}

void update() {
    // look for events
    while (App.GetEvent(Event))
    {
        // if the user did close the window (by pressing the x button of the
        // window, e.g.), close the game
        if (Event.Type == sf::Event::Closed) {
            App.Close();
        }
    }
}

void draw() {
    // Clear the graphics window
    App.Clear();
    // Everything that needs to be drawn will be here later

    // Actualize the display
    App.Display();
    // Look the the console window to see this output
    qDebug()<<"Just to see qDebug in action.";
}

int main()
{
    bool initSuccess=init();
    // if an error occured during init() close the game
    if (!initSuccess){
        App.Close();
    }
    // gameloop till game is closed
    while (App.IsOpened())
    {
        update();
        draw();
    }
    return EXIT_SUCCESS;
}

Compile and run the program. An empty black window will pop up. You can close it by clicking the x Button in the corner of the window title bar. We will build on this in the next part. If you have trouble with the tutorial or questions, please leave a comment.

Part 02 should arrive within 3 days. Don’t forget to follow our RSS feed to miss no update (left sidebar at the top). UPDATE: Part 2 will be published on Sunday, 23th and contain creating a level and loading/displaying it with a ’tile engine’.

 Posted by on September 10, 2012
Jun 172012
 

Since Microsoft will stop making OSs for desktop PCs (Windows 8 is a phone/tablet OS!), it was time to upgrade my Linux alternative (Ubuntu 10.4) to a more actual distribution, cause it hadn’t qualified as a full-time replacement of Windows.

Newest Ubuntu was no (convenient) option cause Gnome 3 and Unity are intolerable (out of the box), cause like Windows 8 they try to tabletize the desktop.

Mint on the other hand offers two alternatives out of the box with MATE desktop (Gnome 2.3.x fork) and Cinnamon desktop (Gnome Shell fork).
But I wanted to test -at least additionally- some non-Ubuntu-based distribution. Back then, I had my first Linux experience with SuSE 5.3 and so I picked OpenSuSE 12.1 as another option. Hadn’t tried KDE on a decent PC for years and so I did pick KDE as desktop manager. To keep this part of the story short: KDE is still as awfully slow as I remembered it. Therefore it wasn’t too bad that I couldn’t figure out (in 30 minutes) how to activate my WLAN card.

If you follow my Twitter feed, you may have noticed that I tried OpenSuSE as the second, but changing the chronological order moved it out of the way before the more interesting part starts.

First I had tried MATE edition of the Mint Maya release (64 bit). It worked, (nearly) everything was quickly and without bigger complications installed. Video playback was fine with all players (had always trouble here with older Ubuntu versions), but one big problem occurred. Having a Twitter program that suits my needs is quite essential to me and I did only manage to install the new Tweetdeck (1.4 using Wine) in MATE. This version is still a piece of sh.. compared to good old Tweetdeck 0.38.

The problem is that Adobe Air and Tweetdeck are discontinued for Linux. Adobe Air is installable with some extra effort (Installing Adobe AIR 2.6 in Ubuntu 12.04 64-bit) and the installation of Tweetdeck goes well after this, but in MATE, TD is unable to store information (an issue related to gnome keyring, obviously). Tried different workarounds, but nothing did help.

At this point I decided to install the Cinnamon desktop additionally – just to have an impression of the differences. Good old Tweetdeck worked right away as did everything else. Yes, now follows the but.. ;)
But.. Cinnamon offers (other than MATE) to put an additional panel at the top of the screen. I always preferred to have some system monitoring apps on a second panel and so I switched to two panels. After the mandatory restart of Cinnamon (ALT+F2, ‘r’, RETURN), every program I opened stalled. I was able to kill them with right click menu, but nothing worked. Reset the panel to the default state solved the problem (after another restart of Cinnamon).
That alone is a problem I would have just ignored. Sadly, there was a much more ANNOYING problem. Regardless of my choice, Cinnamon turned off the monitor after 10 minutes of inactivity. Mint forum has some threads where people report a similar problem. For them the auto-screenlock function connected to the auto-monitor-off didn’t work. But all had -like me- installed Cinnamon side by side with MATE. Enough reason to try a pure Cinnamon install.

The next day (after that short and unsatisfying OpenSuSE trial), I installed the Linux Mint Maya Cinnamon ISO (64 bit). Too keep it short: That was more than one week ago and I still haven’t touched Windows since then. Above mentioned problems didn’t occur with the clean install, everything works and everything works stable. What software do I use most? Tweetdeck (0.38.2 – Twitterclient), Google Chrome (Browser), Eclipse (IDE), Banshee (Musicplayer), Focuswriter (Texteditor), Nitro (great To-Do-List), Radiotray (Webradio in systemtray), Guake (Terminal), Geany (Texteditor and IDE light), MySQLWorkbench (Database administration tool).

Conclusion: Give Linux Mint Maya Cinnamon a try!

 Posted by on June 17, 2012
Oct 142011
 

Yesterday I got my newest gadget – an iRiver Story HD. Thought about buying an e-reader since the first Kindle came out, but always hesitated cause of DRM. The issue still exists, of course, but on the other hand there are so many free classics available that these alone would justify the buy. I just didn’t want to wait any longer. And since I don’t want to be married to Amazon, I looked for a Kindle alternative.

Photo0078

First impression:

I’m in love with it! Of course I will miss to have a real book in my hands and to smell the book (when we reach a time when really all books are available as eBooks everywhere!), but still..

What I like..

It’s such a good feeling to have this lightweight (207 g) in your hands instead of a heavy book when you read a little bit longer.

The 6’’ eInk-display has a resolution of 768×1024 and is ultra sharp. It’s impossible to spot single pixels. It’s very eye friendly. Cant understand how people can read (for a longer time) on an iPad or some other device that has no eInk-display.

Turning a page takes nearly no time. A short flash and the page is turned.

I like the design and the device seems solid. I hope it will take some time before I’ll accidentally test HOW solid it is. ;)

It feels a bit like Star Trek to read that way.. And it became difficult to keep my status as a geek without one. ;)

It took around 30 seconds to get used to the way how you control the reader.

What I dislike..

In the actual firmware 1.13, it’s not possible to change the font. The integrated font is okay and causes no problem, but still I really would like to be able to chose my personal favorite. Such things should be self-evident anyway!

The iRiver doesn’t remember what size you’ve chosen for the font. That means that you’ve to do it again every time you open a book.

I was happy that the most actual firmware was already installed, cause downloading from iRiver’s website seems to be impossible. From server errors to interrupted downloads, everything but a successful download in 8 tries. Forum posts suggest that the support is also terrible.

As mentioned, it comes with more than 200 free books in epub format preinstalled. To get the iRiver extracting title and author from the files you’ve to open every single one of it once. Took me an hour, cause the iRiver interrupted me from time to time with “rescanning DB”. No big deal as it’s only needed when you add a book, but annoying!

Bottom Line:

So far, I like the device and I would buy it again. All points that I criticized could be corrected with a firmware update and a much more reliable website (so that we all can really get this update!). And now excuse me please – I have some hundred books to read.

 Posted by on October 14, 2011
Oct 212010
 

World News Asia 2009

 

The Brief 2010

 

World Report Hong Kong 2010

 Posted by on October 21, 2010