Blox Game Engine:Tutorials:Introduction
From GPWiki
[edit] IntroductionThe Blox Game Engine is a powerful and fast 2D game engine. It provides you with features such as sprites, textures, sounds, music, render targets, and even offscreen memory known as surfaces. If you want more information about the Blox Game Engine and a list of it's features, then visit the website at http://blox.no-ip.org/bge The engine is meant for Microsoft Windows' users using Microsoft Visual C++ as their C++ compiler. For a more thorough tutorial visit out forums under the 'Tutorials and Examples' forum. [edit] What is the Blox Game Engine?The Blox Game Engine is a 2D game development kit(game engine) that can be used to create impressive 2D games. The purpose of Blox is to provide you with the stuff you need so you don't have to spend all of your time researching, and fixing bugs! [edit] Setting Up the Blox Game EngineSetting up the Blox Game Engine in Visual C++ is very straight forward. The first thing you will need to do is tell Visual C++ where to find the Blox Game Engine. You do this by adding the 'include' and 'bin' directories to it's search path. After you have got that done, you need to include the engine's header file, and link to it's library file. #include <BloxGameEngine.h>
[edit] A Skeleton FileThe following code is a skeleton file that can be compiled 'as-is'. You can add your own game's code to this, or just learn from it. It is the most basic Blox program. #include <BloxGameEngine.h> bgeVideo VideoDriver; int main() { VideoDriver.CreateDeviceEx("Hello World!"); while(! bgeKeyPressed(VK_ESCAPE)) { VideoDriver.StartScene(); VideoDriver.StopScene(); } return 0; } [edit] Primitives and VerticesAnother word for 'shape' is Primitive. A primitive is basically a bunch of vertices that make up a shape. Vertices is plural for Vertex. A Vertex is simply a point on the screen. If you want to draw simple shapes such as a rectangle, circle, line or pixel than the Blox Game Engine already has methods for those. If you want to render your own shape, you will have to define an array of vertices that make up the shape. Here is an example of a rotating rectangle that has four differently colored corners. #include <BloxGameEngine.h> bgeVideo VideoDriver; float RectangleRotation = 0.0f; BGECOLOR RectangleColors[4] = {0xFFFF0000, 0xFF00FF00, 0xFF0000FF, 0xFFFFFFFF}; bgeVector RectanglePosition((640/2)-100, (480/2)-100); int main() { VideoDriver.CreateDeviceEx("Rotating Rectangle"); while(! bgeKeyPressed(VK_ESCAPE)) { RectangleRotation += 0.5f if (RectangleRotation >= 361.0f) { RectangleRotation = 0.0f; } VideoDriver.StartScene(); VideoDriver.DrawRectangleRotated(RectanglePosition, 100, 100, RectangleRotation, RectangleColors); VideoDriver.StopScene(); } return 0; } |


