Development/Tutorials/Games/KGLEngine2d

< Development‎ | Tutorials
Revision as of 23:12, 10 October 2008 by Packadal (Talk | contribs)

Jump to: navigation, search
{{{KGLEngine2d tutorial}}}
Tutorial Series   KGLEngine2d developement
Prerequisites   None
What's Next   Nothing at the moment
Further Reading   KGLEngine2d's code

Contents

Abstract

KGLEngine2d is a recent try to develop a 2D games engine using openGL, and powerful enough to deliver complex and beautiful games. As of now, version 1.0 is not even out, but the API is stable enough for anyone to start playing with the engine. Through this tutorial I will explain how to use a great part of the engine, included but not limited to : sprites creation, rotation and deplacement and collision detection.

The example : kglPong

Anyone who have followed the KGLEngine2d developement a bit will have seen some kglPong screenshot, as this is the way new features are shown, using this simple game to showcase them.

Starting Point : the main.cpp

Every application need one, so let's start with it, as it really is simple.

  1. include <KApplication>
  2. include <KAboutData>
  3. include <KCmdLineArgs>
  1. include "pongengine.h"

int main( int argc, char **argv) {

KAboutData aboutData( "kglpong", 0, ki18n("kglpong"), "0.1", ki18n("Classic pong game using KGLEngine2d"), KAboutData::License_GPL,

                             ki18n("Copyright (c) 2008 Developer") );

KCmdLineArgs::init( argc, argv, &aboutData ); KCmdLineOptions options; KCmdLineArgs::addCmdLineOptions(options); KApplication app;

pongEngine pong; pong.show();

return app.exec();; } So, what are we doing ? Initializing the KApplication, and creating an instance of our main class, the one that surclasses KGLEngine2d. Then we tell him to show himself, and that's all. I told you there was nothing exciting in here :)

The KGLEngine2d pong engine

TODO: finish this :p



KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V.Legal