Development/Tutorials/Games/KGLEngine2d

From KDE TechBase
Revision as of 07:34, 10 October 2008 by Packadal (talk | contribs) (New page: <div class="rbroundbox" style="width:100%;"> <div class="rbtopwrap"> <div class="rbtop"><div></div></div>{{{KGLEngine2d tutorial}}}</div> <div class="rbcontent"> {|style="width:100%; b...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
{{{KGLEngine2d tutorial}}}
Tutorial Series   KGLEngine2d developement
Prerequisites   None
What's Next   Nothing at the moment
Further Reading   KGLEngine2d's code

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 "kglpong.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;

KGLPong *pong = new KGLPong();

pong->show();

return app.exec(); } So, what are we doing ? Initializing the KApplication, and creating an instance of one of our own classes, that's all. I told you there was nothing exiting in here :)

The KXmlGuiWindow

As of now, it is mandatory to create a window in which the engine will exists, but this may change on the road to 1.0.

TODO: finish this :p