Sign in to follow this  
  • entries
    3
  • comments
    5
  • views
    1523

First Post EVER!!!!!!!!!!!

Sign in to follow this  
robpers2003

253 views

Hello everyone and welcome to my world. This is my first entry on my journal. I do want to talk about a few things I am working on. Lets start.


Game Engine Development



Well, I have been working on a 2D DirectX game engine. So far it is looking pretty good. I did have one problem with it. I created the engine in a C++ class and that made it difficult for many reasons to actually use the engine.


My goal in this engine is to have the user of the engine not have to worry about DirectX code. All they would have to do is just include the header file of the game engine and start coding. I remade the engine so it wouldn't use C++ classes. Instead it uses C style functions such as the #define and many other things. I have not released the engine to the public yet, because I am still adding things to it. I am thinking, though, about putting up some articles on GameDev.net on how I created the engine. I think that would be pretty cool. Let me now show you a bit of how easy it is to use this game engine of mine.


First, after you added the game engine files to your project (I used Visual C++ .Net 2003 for my projects), you add a source file and include the header "lage.h" at the top of the source file. There are three main functions you have to use here:



  1. void GameInit()
  2. void GameLoop()
  3. void GameEnd()


The GameInit() function is for when the game or program first starts. It is only called once. In here is where you initialize the Game Engine and load up your resources, such as sprites and backgrounds (more on that later).


The GameLoop() function is where the meat of your code goes. This function is constantly called.


The GameEnd() function is where you release the resources you loaded up in the GameInit() function. I made this process especially easy so I know I released my images right.



Game Initialization and Resource loading



To initialize DirectX and set up the window, you would use this function I created in the GameInit() function to do that:


int InitD3D(int width, int height, bool fullscreen);


This function takes as parameters the width and the height of the window. The last parameter is a boolean value determining whether the application is run full-screen or windowed. "true" means fullscreen and "false" means windowed. I believe you would be able to run this application with only the InitD3D() function. All you would see is a black screen, but it is a DirectX app.


To load images, I defined two DirectX variables and gave them a new name. For instance, LPDIRECT3DSURFACE9 can be called by the variable name SURFACE. The second variable was LPDIRECT3DTEXTURE9, but I later defined it as SPRITE. You should declare the image variables globally. Here is an example:


SURFACE background;


SPRITE sprite1;


SURFACE will mainly be used for just backgrounds. The SPRITE though is obviously going to be used for sprites with support for transparency.


In the GameInit() function, here is an example of how you would load up a SURFACE and a SPRITE:


void GameInit()


{


InitD3D(640,480,true);


background = LoadBmp("background.bmp");


sprite1 = LoadSprite("sprite1.bmp",255,0,255);


}


The LoadBmp() function is only used for surfaces and takes as a parameter the filename. The LoadSprite() function is only used to load sprites and takes as parameters the filename and the RGB color value for transparency. In the example above I used RGB(255, 0, 255) which is a sort of pink color for transparency.


Well, my hands are getting tired now. Most likely in the next post I will show you how I would draw the sprites and the background. I also want to put updates on my game projects here. So till next time, have an excellent day. Bye bye.


--robpers2003 (http://www.liveartsnet.com).

Sign in to follow this  


4 Comments


Recommended Comments

That's actually very similar to my generic cApp class (which is an OO version of your solution)

class cApp {
protected:

virtual void init() { }
virtual void running(DWORD step) { }
virtual void shutdown() { }

public:

cApp() { }
~cApp(){ }

virtual bool run() {
init();

running(0);

shutdown();

return true;
};

};







When you want to build on this, you simply derive a class from this pure virtual base class. My 4E4 entry is derived from cSDLApp, which is derived from cApp. cSDLApp is like an SDL framework which handles pretty much everything, along with a couple other helper classes. The actual game code fits nicely in you're derived derived class, and the underlaying foundation is free to be used in other projects.

The beauty of it all:
#include "c4E4.h"


int main(int argc, char* argv[]) {
c4E4 tehGame;
return tehGame.run(false,500,400); }

^ Your whole game. (Now I just need to port it into a VB-safe dll and make it a drag-n-drop control...)

Long live OOP!

Share this comment


Link to comment
World. Welcome to journal land. Superhappyratingsrape for you. What part of Jersey are you from? I'm in Maplewood, Essex County.

-IV

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now