Jump to content
  • Advertisement
Sign in to follow this  
  • entries
    17
  • comments
    37
  • views
    8951

About this blog

Curious about how to build a 2D engine?? Me too, let's resolve this together making one.

Entries in this blog

 

Another Demo

here is the last version...

http://members.gamedev.net/kerkhoff/JournalFiles/Predator-Demo.rar

tell me what you thought...give me ideas...

I'm a very bad layouter eauhuah
this layout is very...very ugly I know...but Is the better(believe me) that I get..

Just copy and paste the font file to the c:\windows\fonts please ehehhe

Thanx....

See ya

Kerkhoff

Kerkhoff

 

Another chance? ehehhe

Hi my friends...

here is the new version of Predator Engine with some basic controls...

download this file:

http://members.gamedev.net/JournalFiles/Predator-Demo.exe

Thanx... =D

Next controls will be the check box, the check button, radio buttons, numeric updown, another panels...

give me ideas..give me =D

byeee

Kerkhoff

Kerkhoff

 

Update....

Just to keep you informed...

I'm rewriting all the Predator Engine... =D

There was very bugs and the code organization was going to the hell..

I'm writing carefully all components and after the primary controls be ready...I'll post the demo here...

Firstly I would like to left done:

PPanel,
PButton (done)
PLabel (done)
PTextBox,
PProgressBar

with good features to have few work in get amazing effects...

thanx...byeee

Kerkhoff

Kerkhoff

 

Let's play... = )

Ladies and gentlemans..

I present you..

the Predator Engine =P

(clap clap clap clap)

thanx...thanx =D

Ok...

Download it from this address

and test what we got until now..

I made the follow components..

PLabel
PPanel
PButton
PProgressBar

no laughs please...I haven't much time = (

test and send me the bugs and new ideas for I implement it...

Thanx a lot...

to everyone

Kerkhoff

Kerkhoff

 

We can do something now =P

Hi my friends...

After this late in post here...

I bring some news...

The PLabel class supports the Outline Fonts, Bitmap Fonts and Texture mapped fonts..

the PPanel class is almost done, it's working now, except by some details that I'll implement tomorrow, like caption align, borders visible, etc...

the PGraphicObjectCollection is dead...it just brought me problems...

PPanel : PInputEventReceiver



private:
PLabel* FCaption;
SColor* FBackgroundColor;
SColor* FBorderColor;

std::string FTextureFileName;

unsigned int FTexture;
unsigned int FDisplayListRectWireFrame;
unsigned int FDisplayListRect;
unsigned int FDisplayListRectTexture;

int FBorderWidth;
int FRectType;
bool FFilled;
public:
PPanel(SRect* ABounds, int ARectType, IVideoDriver* AVideoDriver);
~PPanel(void);

PLabel* GetCaption(void);
void SetCaption(PLabel* AValue);

SColor* GetBackgroundColor(void);
void SetBackgroundColor(SColor* AValue);

SColor* GetBorderColor(void);
void SetBorderColor(SColor* AValue);

std::string GetTextureFileName(void);
void SetTextureFileName(std::string AValue);

int GetBorderWidth(void);
void SetBorderWidth(int AValue);

bool GetFilled(void);
void SetFilled(bool AValue);

void PrepareToDraw(void);

void Draw(void);



The IVideoDriver have some new methods too



virtual AUX_RGBImageRec* LoadBMPRec(std::string AFileName) = 0;

virtual void SetBlend(bool AValue) = 0;
virtual void SetTexture(bool AValue) = 0;

virtual unsigned int GenerateDisplayList(int AListSize) = 0;
virtual void CallDisplayList(unsigned int ADisplayList) = 0;
virtual void DestroyDisplayList(unsigned int ADisplayList, int ASize) = 0;

virtual void LoadTexture(std::string AFileName, unsigned int &ATextureBuffer, int ATextureType) = 0;
virtual void BindTexture(unsigned int ATextureBuffer) = 0;

virtual void DrawText(std::string AText, float ASize, SColor* AColor, SCoord* ACoord, unsigned int ADisplayList, int AFontType) = 0;

virtual unsigned int GenerateDisplayListRectWireFrame(SRect* ABounds, SColor* ABorderColor, int ABorderWidth) = 0;
virtual unsigned int GenerateDisplayListRect(SRect* ABounds, SColor* ABackgroundColor) = 0;
virtual unsigned int GenerateDisplayListRectTexture(SRect* ABounds, SColor* AColor) = 0;





I'm using display list for everything, if someone has any suggestion in how I can approach the performance...tell me...

I have made a little demo with two panels and one running label to show the use of layers and what we have until now:



well...I hope you like the system...

I think that our next step is make some buttons..right?

see ya

Kerkhoff

Kerkhoff

 

News...and PLabel!!!

Hi...
after some days without post here, I show you the PLabel class...

PLabel: PGraphicObject


private:
unsigned int FDisplayList;

GLYPHMETRICSFLOAT FGlyphs[256];
HFONT FFont;

SColor* FColor;

std::string FCaption;
std::string FFontName;

int FSize;
int FWeight;

bool FWireFrame;
bool FItalic;
bool FUnderline;
bool FStrikeOut;

int GetCaptionWidth(void);
int GetCaptionHeight(void);
public:
PLabel(std::string ACaption, std::string AFontName, int AFontSize, SCoord* ACoord);
~PLabel(void);

std::string GetCaption(void);
void SetCaption(std::string AValue);

SColor* GetColor(void);
void SetColor(SColor* AValue);

std::string GetFontName(void);
void SetFontName(std::string AValue);

bool GetWireFrame(void);
void SetWireFrame(bool AValue);

int GetSize(void);
void SetSize(int AValue);

int GetWeight(void);
void SetWeight(int AValue);

bool GetItalic(void);
void SetItalic(bool AValue);

bool GetUnderline(void);
void SetUnderline(bool AValue);

bool GetStrikeOut(void);
void SetStrikeOut(bool AValue);

void BuildFont(void);
void Draw(void);



This class is quite simple, some properties...

the BuildFont Method, have to be called before the Draw Method

Well, like the title says...I have made some changes in our mechanism...

Now, we have a PGraphicObjectCollection class, that have a list of PGraphicObjects (=P)...


protected:
PList* FObjects;

IVideoDriver* FVideoDriver;
public:
PGraphicObjectCollection(IVideoDriver* AVideoDriver);
~PGraphicObjectCollection(void);

virtual void Sync(void);



the sync method, just distribute the FVideoDriver component(that is unique) between its FObjects...

The Sync Method, must to be called after all objects are inserted and before call methods that uses the FVideoDriver of them.

Okay, I'll try to be more fast and keep on posting everyday...

See ya...

Kerkhoff

Kerkhoff

 

Predator namespaces!!!

Hi...

This is like our 2d engine looks after namespace organization:



namespace Predator
{
namespace Common
{
PDefines
PList
PStack
PStructs
}
namespace System
{
PDevice
PInputDriver
PKeyboardDriver
PMouseDriver
}
namespace Drawing
{
IVideoDriver
PGraphicObject
PInputEventReciever
PLayer
POpenGLDriver
PWindow
}
namespace GUI
{
(PLabel, PPanel, etc...)
}
}





Well..any suggestions =D

After that, I'll start the GUI programming..

See ya...

Kerkhoff

Kerkhoff

 

A little doubt

Hi everyone..

I have spent my time reading about create my own engine and use some of existents...

I think about and get in none result = (

I'm here to ask you, what you think?

however...
my next mission is dismember my engine in namespaces,

tomorrow I'll show the engine's new organization

I hope you like...

PS: please give your suggestion about my doubt

Kerkhoff

Kerkhoff

 

PLayer

Hi my friends...

this is my first post in 2006 =D

I present you the PLayer class:

PLayer : PInputEventReceiver


private:
PList* FGraphicObjects;

std::string FLayerID;
SColor* FColor;
public:
PLayer(std::string ALayerID, SRect* ABounds, IVideoDriver* AVideoDriver);
std::string GetLayerID(void);
void SetLayerID(std::string AValue);

void Draw(void);





This class will be responsible for Keep all objects in the screen, I prefered use the layers because it has the order benefit...

For while, this class just has this few methods, I have not thought in another funcionallity for it.

The draw method just will draw its graphic objects =D

Tomorrow I'll show the PPanel class and after that, I'll need your help to know "what path I have to follow" =P

Thanx...

PS: I'm sorry about the late...

Kerkhoff

Kerkhoff

 

What about a visual look!!

Hi everyone..

I'm home and without my computer with the codes, so...I decided improvise some visual look of our engine...

Above, the images with what we have until now...

Structs





Drivers



Graphics



Well my friends...I don't know what I'll write until monday, I'm without the computer with the codes...so...be patient =D

Byyyee..

Kerkhoff

Kerkhoff

 

Our first Main.cpp

Hi everyone, I'm a little hurried, so I will just write here our first main.cpp =D

We can already create some windows and show...

If you are following the previous days, check how simple is the code:


#include "PStructs.h"
#include "PDevice.h"

int main()
{
PDevice* MainApplication= new PDevice(vdOpenGL);

MainApplication->CreateNewWindow("MyWindow", new SRect(0, 100, 500, 500));
MainApplication->Show("MyWindow");

while (MainApplication->Running())
{
MainApplication->Refresh();
}

delete(MainApplication);

return 0;
}



When we create a PDevice instance, we pass by parameter, the type of API we want to use. In this case, is OpenGL..

Well...tomorrow I'll show the first "visual" version of our engine, with what we have until now..

See ya..

Kerkhoff

Kerkhoff

 

PWindow and IVideoDriver

Hi, how are you??

well, proceeding, let me explain the IVideoDriver class...

Check out the code:

IVideoDriver


public:
virtual void RestoreDefaultSettings(void) = 0;
virtual void PrepareScene(void) = 0;
virtual void DrawScene(HDC AHDC) = 0;
virtual void ResizeDriver(SRect* ADimension) = 0;

virtual void SetClearColor(SColor* AColor)= 0;




The IVideoDriver is just an interface that contains all the drawing functions (until now just the "prepare" functions, none of REAL drawing is done) of the engine... the POpenGLDriver only implement this interface with OpenGL methods.

All the graphicobjects have a pointer to IVideoDriver to perform its drawing.

Now..the PWindow class..one of most important classes:

PWindow: PInputEventReceiver


private:
bool FFullScreen;
bool FNeedResize;

std::string FName;
std::string FCaption;
SColor* FBackgroundColor;

HWND FHandle;
HDC FHDC;
HGLRC FHRC;
HCURSOR FCursor;
public:
PWindow(std::string AWindowName, SRect* ABounds, IVideoDriver* AVideoDriver);
~PWindow();

bool GetFullScreen(void);
void SetFullScree(bool AValue);

bool GetNeedResize(void);
void SetNeedResize(bool AValue);

void Show();
void Hide();

std::string GetName(void);

std::string GetCaption(void);
void SetCaption(std::string AValue);

SColor* GetBackgroundColor(void);
void SetBackgroundColor(SColor* AValue);

HWND GetHandle(void);
void SetHandle(HWND AValue);

HDC GetHDC(void);
void SetHDC(HDC AValue);

HGLRC GetHGLRC(void);
void SetHGLRC(HGLRC AValue);

void Draw();




This class control the windows of the application. Until now there are no complex methods that need explanation..maybe in the future =P

Okay, tomorrow I'll show the example of a simple Main.cpp that create and show a window with a background color.

Any suggestion or question...comment please =D

Thanx
See you tomorrow..

Kerkhoff

Kerkhoff

 

PGraphicObject and PInputEventReceiver

Today I should explain the PWindow class and IVideoDriver interface..but...looking the project, I decided to show the PGraphicObject (all the graphic objects will derive from it, so...) and the PInputEventReciever first, because the PWindow class derives from PInputEventReciever =D

Check the code:

PGraphicObject


private:
bool FVisible;

IVideoDriver* FVideoDriver;
SRect* FBounds;
public:
PGraphicObject(SRect* ABounds, IVideoDriver* AVideoDriver);
~PGraphicObject(void);

bool GetVisible(void);
void SetVisible(bool AValue);

SRect* GetBounds(void);
void SetBounds(SRect* AValue);

IVideoDriver* GetVideoDriver(void);
void SetVideoDriver(IVideoDriver* AValue);

virtual void Draw(void) = 0;




This class have not much to explain...any doubt ask me please...

PInputEventReceiver


private:
void (*FOnMouseMove)(SCoord* AMousePosition);
void (*FOnMouseDown)(SCoord* AMousePosition, ENMouseButton AMouseButton);
void (*FOnMouseUp)(SCoord* AMousePosition, ENMouseButton AMouseButton);

void (*FOnKeyDown)(int AKey);
void (*FOnKeyUp)(int AKey);
protected:
virtual void DoMouseMove(SCoord* AMousePosition);
virtual void DoMouseDown(SCoord* AMousePosition, ENMouseButton AMouseButton);
virtual void DoMouseUp(SCoord* AMousePosition, ENMouseButton AMouseButton);

virtual void DoKeyDown(int AKey);
virtual void DoKeyUp(int AKey);
public:
PInputEventReciever(SRect* ABounds, IVideoDriver* AVideoDriver);
~PInputEventReciever(void);

void OnMouseMove(void (*AOnMouseMove)(SCoord* AMousePosition));
void OnMouseDown(void (*AOnMouseDown)(SCoord* AMousePosition, ENMouseButton AMouseButton));
void OnMouseUp(void (*AOnMouseUp)(SCoord* AMousePosition, ENMouseButton AMouseButton));

void OnKeyDown(void (*AOnKeyDown)(int AKey));
void OnKeyUp(void (*AOnKeyDown)(int AKey));

virtual void Draw() = 0;




This class just have the pointers to the methods. All the PInputEventReceivers objects, will be registered in the MouseDriver and KeyboardDriver on PDevice and the events will be fired from these drivers to the recievers.

just like I said, the PWindow class derives from PInputEventReceiver.

Tomorrow I'll show the PWindow class and the IVideoDriver interface..
at this time, I promisse..hehe

leave comments with suggestions, critics or love phrases =P

well..see you tomorrow..

Kerkhoff

Kerkhoff

 

The PDevice Class

Well, yesterday, because my xmas party, I didn't post here =D

But, like I said, here is my first engine description:

The code:

S[name_of_class] = Classes that describe structs;
P[name_of_class] = Standard classes;
I[name_of_class] = Interfaces;

EN[name] = Enumerators;

F[name] = Attributes;
A[Name] = Parameters;

From the beginning:
I have made some classes (I have not used any structs until now and I don't pretend), to describe the structs that I'll need to use.
SRect, SCoord, SColor. This classes are being used in all the standard classes until now.

My main class, is the PDevice:

PDevice:


private:
PList<PWindow>* FWindows;
PStack<PWindow>* FOpenWindows;

MSG FMessage;
int FActiveWindow;
PWindow* FCurrentWindow;

IVideoDriver* FVideoDriver;
PMouseDriver* FMouseDriver;
PKeyboardDriver* FKeyboardDriver;

void RegisterInstance(LPCSTR AWindowName);
void BuildWindow(const LPCTSTR AWindowName, SRect* ADimension, PWindow* ANewWindow);
void PrepareWindowToDraw(PWindow* ANewWindow);

static private LRESULT CALLBACK PDevice::WindowProcedure(HWND AHandle, UINT AMessage, WPARAM AWParam, LPARAM ALParam);

public:
PDevice(ENVideoDriver AVideoDriver);
~PDevice(void);

PWindow* CreateNewWindow(std::string AWindowName, SRect* ABounds);
PWindow* GetCurrentWindow(void);

IVideoDriver* GetVideoDriver(void);

bool Running(void);
int ActiveWindows(void);

void Show(std::string AWindowName);
void Hide(std::string AWindowName);

void Refresh(void);

void InitializeMouse(void);
void InitializeKeyboard(void);




This class, have a list of PWindows, that are the windows of application =P. The stack with OpenWindows serve to set the DeviceContext to the previous window when another window is about to be closed.

The video driver, contains the drawing functions (that aren't implemented yet, except the "prepare" and "refresh" routines).

Mouse and keyboard drivers will handle the respective messages.

Another methods are explained by itselves.

Tomorrow I will talk about the PWindow and PVideoDriver class.

Remember, I'm building this framework yet, neither the windows system are ready. I will appreciate any suggestions in how can I approach my system.

Tell me what you think.

Thanx!!!

See ya...

Kerkhoff

Kerkhoff

 

My first entry

Hi, my name is Matheus Von Der Kerkhoff, I'm new in game programming.

For this day forward, my journal will show you a little bit about my experience in the game programming world.

My first project is a graphical engine 2D, in C++.

My idea is quite simple. First, I need to make a little engine, and after that, I can begin with some little games (I have already done some games without an engine, but didn't like), like plataform games and something like Counter Strike 2D.

If my engine support the skills of Counter Strike 2D or Soldat(is just some examples), I'll be very happy. =D

A little piece of my engine is already done. Tomorrow I'll explain you how I plan build it and will appreciate all the suggestions.

Thanx!!

See ya..

Kerkhoff

Kerkhoff

Sign in to follow this  
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!