📜 ⬆️ ⬇️

Getting started with the Rungine game engine

Runner Engine (abbreviated as Rungine) is a new 2D / 3D engine for creating games and multimedia applications. It has a flexible set of tools that can help the developer to increase the speed of development, but they are still being finalized. The engine includes: Core (kernel with its own set of utilities), GUI, Graphic2D. Currently, Runner Engine only supports DirectX9. Work is underway on OpenGL support. In the future we plan to continue working on support for DirectX10 and DirectX11.

Supported Platform: Windows

Currently the engine is in development. If it will be very interesting to someone to look at this engine at work, it is possible to create an intermediate demo version, for this you need only to inform.
')
Initialization:

The first step is to connect the engine dll:
#include "..\..\RunnerEngine\Runner.h" #pragma comment(lib, "../../Bin/Runner.lib") 


We announce the device:
 RDevice rdevice; //     Create: if(!rdevice.Create(800, 600, Mode::Windowed, API::Direct3D9)) { return 0; } 


The entire working cycle is as follows:
 //,     while(rdevice.EnterMsgLoop(true)) { rdevice.Clear();//   //   if(rdevice.BeginScene()) { //    rdevice.EndScene();//  rdevice.Present();//   } } 

Everything. Initialization we figured out. Now you can display a picture or draw an image.


Hello runner
Hello, Runner is the first example from the Rungine SDK. It shows how to initialize Rungine and draw the simplest image.

Source code with description:
 // : #include "..\..\RunnerEngine\Runner.h" #pragma comment(lib, "../../Bin/Runner.lib") String MediaDir = "../Media/HelloRunner/"; RDevice rdevice;//      Picture im;//  RFont font; int WINAPI WinMain( HINSTANCE hinstance, HINSTANCE prevInstance, PSTR cmdLine, int showCmd) { RFile f; // : int width = 800; int height = 600; bool mode = Mode::Windowed; int api = API::Direct3D9; //  : if(!FileUtility::FileExists(MediaDir + "../Samples.dat")) //  ,     Visual Studio: MediaDir = "../" + MediaDir; /*   , ,   (/)   API: */ if(f.OpenRead((MediaDir + "../Samples.dat").ToChar())) { f.Read(&width,sizeof(width)); f.Read(&height,sizeof(height)); f.Read(&mode,sizeof(mode)); f.Read(&api,sizeof(api)); f.Close(); } // Runner Engine   //  WidthHeight : if(!rdevice.Create(width, height, mode, api)) { return 0; } //   Tahoma 10  font.Create(&rdevice, Fonts::Tahoma); // im,   RunnerBackground.tga: im.Create(&rdevice, MediaDir + "RunnerBackground.tga"); //  : Window::SetTitle("Runner Engine. Tutorial: Hellow World"); //,     while(rdevice.EnterMsgLoop(true)) { //true  ,       ,   //  rdevice.Clear();//   //   if(rdevice.BeginScene()) { //    im.Draw(0,0,Window::GetWidth(),Window::GetHeight(), Colors::White); // : font.Begin(); font.Draw2DText(10,10,"Press ESC to exit",Colors::White); font.Draw2DText(10,25,String("FPS: ") + rdevice.GetFPS(), Colors::White); font.End(); rdevice.EndScene();//  rdevice.Present();//   } //    ESC: if(Keyboard::GetKey(KEY_ESCAPE)) { Window::Destroy();//   } } return 0; } //     hWnd : Window::GetHWND(); 


The running example looks like this:
image

Gears:
Gears is an example of the simplest animation using the example of two interconnected gears.

 #include "..\..\RunnerEngine\Runner.h" #pragma comment(lib, "../../Bin/Runner.lib") String MediaDir = "../Media/Gears/"; RDevice rdevice;//      // : Picture Gear1;//  Picture Gear2;//  Picture Symbol;//  RFont font; //      : int g1_count = 12; int g2_count = 12; float angle = 0.0f;//     bool Create() { RFile f; // : int width = 800; int height = 600; bool mode = Mode::Windowed; int api = API::Direct3D9; //  : if(!FileUtility::FileExists(MediaDir + "../Samples.dat")) //  ,     Visual Studio: MediaDir = "../" + MediaDir; /*  , ,   (/)   API: */ if(f.OpenRead((MediaDir + "../Samples.dat").ToChar())) { f.Read(&width,sizeof(width)); f.Read(&height,sizeof(height)); f.Read(&mode,sizeof(mode)); f.Read(&api,sizeof(api)); f.Close(); } // Runner Engine   //  WidthHeight : if(!rdevice.Create(width, height, mode, api)) { return false; } rdevice.SetTexFilter(TexFilter::ANISOTROPIC,TexFilter::ANISOTROPIC,16); //   Tahoma 10  font.Create(&rdevice, Fonts::Tahoma); // : Gear1.Create(&rdevice, MediaDir + "Gear1.dds"); Gear2.Create(&rdevice, MediaDir + "Gear2.dds"); Symbol.Create(&rdevice, MediaDir + "Symbol.tga"); return true; } void UpdateFPS() { //  fps(   ): static int old_fps = 0; //   fps: int new_fps = rdevice.GetFPS(); if(old_fps != new_fps) { //  : Window::SetTitle(String("Runner Engine. Tutorial 2: Gears ")+ new_fps +" fps"); old_fps = new_fps; } } void Render() { //,    : while(rdevice.EnterMsgLoop()) { UpdateFPS(); /*        ,    :*/ angle += rdevice.GetElapsedTime()/500.0f; /* ..    ,   g1_count ,    g2_count,       , .. ,      g2_count/g1_count       . ..       :*/ float angle2 = -(g2_count/g1_count)*angle; /*       .        .*/ rdevice.Clear(Colors::System::Background);//   rdevice.SetTexWithAlphaChanel(1);//   //   if(rdevice.BeginScene()) { //    800600,   //       //       //800600: float kx = (float)Window::GetWidth()/800; float ky = (float)Window::GetHeight()/600; int x = 170;//*kx; int y = 70;//*ky; //   : int sx = INT(297.0f*kx); int sy = INT(297.0f*ky); // 297        , //   800x600 // : Gear1.Draw(INT((x - 40)*kx), INT((y + 170)*ky),sx,sy, angle); Gear2.Draw(INT((x + 150)*kx), INT((y - 40)*ky),sx,sy, angle2); //     : Point Size = Symbol.GetSize()*Window::GetWidth()/2300; Symbol.Draw(Window::GetWidth() - Size.x, Window::GetHeight() – Size.y, Size.x, Size.y); // : font.Begin(); font.Draw2DText(10,10,"Press ESC to exit",Colors::White); font.Draw2DText(10,25,String("FPS: ") + rdevice.GetFPS(),Colors::White); font.End(); rdevice.EndScene();//  rdevice.Present();//   } //    ESC: if(Keyboard::GetKey(KEY_ESCAPE)) { Window::Destroy();//   } } } int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE prevInstance, PSTR cmdLine, int showCmd) { if(Create()) { Render(); return 0; } } 


The running example looks like this:
image

Source: https://habr.com/ru/post/127385/


All Articles