(Help Request) Hello! can you help me?

<< < (3/4) > >>

RedSlash:
There is also a workshop tutorial with sample game code here that might be helpful:
http://ccpssolutions.com/nogdusforums/index.php?topic=318.0

Richard Marks:
I have no problem with you making hard copies for yourself, and yourself only.
However, if you print copies and start handing them out to people, or try to make any money off of it, then I'll be quite upset. Printing the code for your own study material is fine.

SAWD was a rush-job that I just wanted to win the contest with, and I did. Don't use its source as a learning tool. Its messy as hell. :D

Same goes with the FFV Menu example, that was just be being bored. Its really poor code style.
Which Pong game did you download? I've done quite a few :D

DirectX is a major pain in the butt to learn. If you are not proficient with all of the Windows bullshit, then you will want to rip your eyes out when writing DirectX :D
However, I've got so many references here that if you do decide to learn DirectX, you shouldn't need to search much, just ask here, and I'll give answers. Or help YOU to get the answers. Its important to know how to find answers when no one else is around to tell you. ;)

You want to learn structure, then stick around here and ask all the questions you can think of.

As for the link, I know its not working. I've contacted the people who maintain that service, and I have not received a reply as of now.

*back to work on your little GDI engine project* :D

Richard Marks:
Thought you might want to see the new WinMain.cpp file contents (you had it named main.cpp which while works, is not a good idea since it does not follow proper file naming conventions)

Code:

// tell windows we don't want junk
#define WIN32_LEAN_AND_MEAN

// include windows API header
#include <windows.h>

// include the game engine header
#include "Engine.h"

// include the game state headers
#include "TitleState.h"
#include "PlayGameState.h"
#include "PausedState.h"

// our Engine singleton class is in the GAMEENGINE namespace, so to keep from needing to
// type the full qualifier name (GAMEENGINE::Engine->Foo()) we just use this using statement here.
using GAMEENGINE;

int WINAPI WinMain(HINSTANCE instance, HINSTANCE garbage1, LPSTR garbage2, int garbage3)
{
// initialize the game engine
const int WINDOW_WIDTH = 640;
const int WINDOW_HEIGHT = 480;
if (Engine->Initialize("Commander Bravo", WINDOW_WIDTH, WINDOW_HEIGHT, instance))
{
// register all of the game states that you will ever use
Engine->RegisterState("title", &TitleState::GetInstance());
Engine->RegisterState("play game", &PlayGameState::GetInstance());
Engine->RegisterState("paused", &PausedState::GetInstance());

// push your startup sequence to the stack
// in this case just the title
Engine->PushState("title");

// process the game states in the stack
while(!Engine->StateStackEmpty())
{
// handle windows messages
if (Engine->NoMessages())
{
// calls the Execute member function of the game state
Engine->ExecuteState();
}
}

// return success
return 0;
}

// oh no it failed to Init!
MessageBox(0,
"An error occurred during the initialization of the game.\n\n"
"Please contact your@emailhere.com\n\n"
"Sorry for the inconvenience!", "Error", MB_OK | MB_ICONEXCLAMATION);
// return failure
return 1;
}


there is still much to do, but rest assured, its fully commented line for line. 8)

Richard Marks:
Here is a possible Title Game State source file.

Code:

// tell windows we don't want junk
#define WIN32_LEAN_AND_MEAN

// include windows API header
#include <windows.h>

// include complementing header
#include "TitleState.h"

// include the game engine header
#include "Engine.h"

// our Engine singleton class is in the GAMEENGINE namespace, so to keep from needing to
// type the full qualifier name (GAMEENGINE::Engine->Foo()) we just use this using statement here.
using GAMEENGINE;

// return the singleton class instance for the title state
TitleState* TitleState::GetInstance(){TitleState si; return &si;}

// constructor - inits member vars to zero
TitleState::TitleState() : titleImage_(0) {}

// destructor - calls Destroy()
TitleState::~TitleState(){Destroy();}

void TitleState::Initialize()
{
// load the title image
titleImage_ = new Image("title.bmp");
}

void TitleState::Execute()
{
// if the ESC key was pressed, then we exit the title state
// if the SPACEBAR key was pressed, then we jump into the play game state
if (Engine->WasKeyPressed(VK_ESCAPE))
{
// leave this state for good
Engine->PopState();
}
else if (Engine->WasKeyPressed(VK_SPACE))
{
// change state by pushing a new state
Engine->PushState("play game");
}

// get a pointer to the back buffer image for drawing on
Image* display = Engine->GetBackBuffer();

// prepare the back buffer for drawing (clears it)
Engine->BeginScene();

// draw the title on the back buffer image
titleImage_->Draw(display, 0, 0, 0, 0, titleImage_->GetWidth(), titleImage_->GetHeight());

// flip the back buffer to the screen so we can see what we have drawn
Engine->EndScene();
}

void TitleState::Destroy()
{
// clean up after ourselves
if (0 != titleImage_)
{
delete titleImage_;
titleImage_ = 0;
}
}


Now, I still have not implemented that yet, but this is how I work. I code with stuff that does not yet exist, and once I see what I need, then I implement the functions. Hope it looks like something you want to use. 8)

cursebox:
oki doki, master! ;D You can trust me on that.

Beautiful!! that's just what i've been trying to do. I wish i could do that too. You organized it properly. Certainly, that's going to be the best reference i will have.

Navigation

[0] Message Index

[#] Next page

[*] Previous page