Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: C++/Direct3D Pong Tutorial Series  (Read 6289 times)

0 Members and 1 Guest are viewing this topic.
C++/Direct3D Pong Tutorial Series
« on: February 15, 2010, 08:23:52 pm »
  • Minalien
  • *
  • Reputation: +10/-1
  • Offline Offline
  • Gender: Female
  • Posts: 2119
Don't know if anybody's paid any attention to my signature, but I've been working on a Pong tutorial using C++ and D3DX on my blog. Now that I've got the second tutorial in the series up, which covers initializing Direct3D and creating our engine's framework, I figured that I may as well make it known here.

The engine being developed through this series is aimed at being reusable in future projects, so enjoy yourselves.

Requirements
This tutorial series assumes that the following are true:
1) You have the DirectX SDK installed and configured on your system.
2) You know how to configure your IDE to use the header files and libraries included within the DirectX SDK
3) You know how to set up a new Win32 project (vice the use of a console project) in your IDE
4) You know how to add static libraries to a project within your IDE

Starting Words
In this tutorial series, I’m not going to give instructions to any particular IDE. I personally use Visual Studio 2010 B2 right now, and will at least be assuming the use of Visual Studio as far as some code samples go.

Links
Tutorial Series Directory

Tutorial 01 - Creating the Project and Setting up Win32
Tutorial 02 - Setting up Direct3D and our Engine Framework
Tutorial 03 - Scene Objects and Sprite Rendering
« Last Edit: March 21, 2010, 08:57:55 pm by Samantha »
Logged
Quote
There's such a double standard about religion in the modern world. Catholics can gather, wear white robes, and say "In nomine Patris, et Filii, et Spiritus Sancti" and be considered normal.

But if my friends and I gather, wear black robes, and say  "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn", we're considered cultists.
  • Development Blog
Re: C++/Direct3D Pong Tutorial Series
« Reply #1 on: February 15, 2010, 09:24:57 pm »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3725
Great tutorial series. Looking at the code listings they are very familiar to me. It looks like you are creating an improved version of the Advanced2D engine from Advanced 2D Game Development book. I guess, the tutorials will follow the same setup and maybe added 3D graphics to it.


Well, I have to say for those who haven't read the book it will be a great tutorial, so keep up the good work. And I will probably look in to see how your ideas for improvement are.
Logged
Re: C++/Direct3D Pong Tutorial Series
« Reply #2 on: February 15, 2010, 09:39:55 pm »
  • Minalien
  • *
  • Reputation: +10/-1
  • Offline Offline
  • Gender: Female
  • Posts: 2119
Great tutorial series. Looking at the code listings they are very familiar to me. It looks like you are creating an improved version of the Advanced2D engine from Advanced 2D Game Development book. I guess, the tutorials will follow the same setup and maybe added 3D graphics to it.


Well, I have to say for those who haven't read the book it will be a great tutorial, so keep up the good work. And I will probably look in to see how your ideas for improvement are.
Yeah, I am taking a bit of the format for the A2D engine, but only so far as graphics are concerned. I've got a lot of work in the future areas, such as input and entity management, that are completely different from his methodology. Harbour does a lot of things in his programming style that !@#$% me off, and is pretty inconsistent throughout that book (for example, at times he will use ZeroMemory(&pointer, sizeof(pointer)), while at other times he will use memset(&pointer, 0, sizeof(pointer)). Inconsistency is annoying.)
Logged
Quote
There's such a double standard about religion in the modern world. Catholics can gather, wear white robes, and say "In nomine Patris, et Filii, et Spiritus Sancti" and be considered normal.

But if my friends and I gather, wear black robes, and say  "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn", we're considered cultists.
  • Development Blog
Re: C++/Direct3D Pong Tutorial Series
« Reply #3 on: February 15, 2010, 09:50:08 pm »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3725
Yeah, I noticed the inconsistencies too. And I agree that his entity manager and entities and collision detection designs are really crap. I don't know if he had improved it in the 3rd edition of the book.

His input section was actually really empty, with a lot to add to. Additionally, I found it a load BS when he mentioned that because the book is aimed at PC games, he wouldn't discuss Gamepad/Joystick functionality. As if PC gamers never use that.

His game engine also lacked a good state/process manager. Ah well, I am ranting again. Good luck with your tutorials.
Logged
Re: C++/Direct3D Pong Tutorial Series
« Reply #4 on: February 15, 2010, 09:58:25 pm »
  • Minalien
  • *
  • Reputation: +10/-1
  • Offline Offline
  • Gender: Female
  • Posts: 2119
Yeah, I noticed the inconsistencies too. And I agree that his entity manager and entities and collision detection designs are really crap. I don't know if he had improved it in the 3rd edition of the book.
Precisely why I never finished reading the book. :P

His input section was actually really empty, with a lot to add to. Additionally, I found it a load BS when he mentioned that because the book is aimed at PC games, he wouldn't discuss Gamepad/Joystick functionality. As if PC gamers never use that.
One of the things I intend to add, actually. I'm going with an XNA Framework style for input management, where the input states are updated and checked each frame. I'm only going to be doing Mouse, Keyboard, and XInput (XBOX 360 Controller - and I'll actually be basing this on an earlier tutorial of mine on CodeProject) for this tutorial series, but I'm planning on adding a follow-up on adding support for other joysticks/gamepads.

His game engine also lacked a good state/process manager. Ah well, I am ranting again. Good luck with your tutorials.
While I'm not adding finite state management to this series, I will be doing a tutorial on it later, while furthering the development of this engine. My ultimate goal is going to be having game logic written with GameMonkey scripting, while the engine and framework (and high-priority tasks) will be using the C++ core.

Planning on keeping the engine as a whole two-dimensional, but it's going to be a pretty powerful engine when I'm through with it. Currently planning on adding networking with RakNet and shader support, along with some effects classes (advanced particle systems among them). :P
Logged
Quote
There's such a double standard about religion in the modern world. Catholics can gather, wear white robes, and say "In nomine Patris, et Filii, et Spiritus Sancti" and be considered normal.

But if my friends and I gather, wear black robes, and say  "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn", we're considered cultists.
  • Development Blog
Re: C++/Direct3D Pong Tutorial Series
« Reply #5 on: February 16, 2010, 12:21:30 am »
  • (y)(;>.<;)(y)
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3293
That's one thing I disliked about XNA. I much prefer using 'events' of one type or another for my input, since I've found it makes it much simpler to create a fancy input wrapper so controls can be changed easily, like for those left handed players that insist on using IJKL instead of WASD.

Of course in XNA this meant trying to write a class that ran in a separate thread and manually polled the gamepad, buffering the results and firing associated delegate functions when it got 'flushed', which felt nothing short of painful in C#/XNA...But that's just me =P
Logged
Re: C++/Direct3D Pong Tutorial Series
« Reply #6 on: February 16, 2010, 12:27:21 am »
  • Minalien
  • *
  • Reputation: +10/-1
  • Offline Offline
  • Gender: Female
  • Posts: 2119
That's one thing I disliked about XNA. I much prefer using 'events' of one type or another for my input, since I've found it makes it much simpler to create a fancy input wrapper so controls can be changed easily, like for those left handed players that insist on using IJKL instead of WASD.

Of course in XNA this meant trying to write a class that ran in a separate thread and manually polled the gamepad, buffering the results and firing associated delegate functions when it got 'flushed', which felt nothing short of painful in C#/XNA...But that's just me =P
Jay, you suck at life. You seriously didn't see the easy way to do that? All you need to do is store the custom keys to check for in a variable, and check for the variable instead of the key itself. >.>;;

Example (Obviously not from XNA - or anything else, for that matter):
Code: [Select]
Key* jumpKey = CInputManager::Keys::KEY_SPACE;
Key* fwdKey = CInputManager::Keys::KEY_W;
Key* bwdKey = CInputManager::Keys::KEY_S;
Key* strLKey = CInputManager::Keys::KEY_A;
Key* strRKey = CInputManager::Keys::KEY_D;

// ....

void Update(float delta)
{
if(CInputManager::Instance()->IsKeyDown(fwdKey))
{
Player->Velocity.vecFwd = Player->Speed * delta;
}

// ... etc ...
}
Logged
Quote
There's such a double standard about religion in the modern world. Catholics can gather, wear white robes, and say "In nomine Patris, et Filii, et Spiritus Sancti" and be considered normal.

But if my friends and I gather, wear black robes, and say  "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn", we're considered cultists.
  • Development Blog
Re: C++/Direct3D Pong Tutorial Series
« Reply #7 on: February 16, 2010, 12:51:10 am »
  • (y)(;>.<;)(y)
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3293
Well I wound up with something like with my method. I decided to drop the keyboard entirely, and make it only playable through the Game pad for simplicities sake (wouldn't have been to hard to add really). I also dismissed the multithreading and buffering concept as overly complicated and retarded.

The end result was it didn't poll every key (obviously), just the ones it was told to poll and then fired the related event if they came up as having changed, but it was still a pain and a half to keep logic and input separate, which was what I was trying to do.

Still meant I couldn't really change input 'on the fly' like I really wanted (as that'd still require polling every single button), and neither could your method since, again: still would need to poll every key to figure out what they just pressed to change the control scheme.

On the plus side it was fairly reusable and I was able to make PacMan, multiplayer Space Invaders, Pong, the usual test projects with it, alongside the Screen system I hacked together, before I decided I was too ashamed of it and scrapped it XD

Still, yeah, I'm just being awkward in my event-based-ways...Still, if you're going to provide networking like you said, isn't it generally best to try and separate input and logic in those situations?
« Last Edit: February 16, 2010, 01:19:29 am by TheDarkJay »
Logged
Re: C++/Direct3D Pong Tutorial Series
« Reply #8 on: February 16, 2010, 02:42:59 am »
  • Minalien
  • *
  • Reputation: +10/-1
  • Offline Offline
  • Gender: Female
  • Posts: 2119
Well I wound up with something like with my method. I decided to drop the keyboard entirely, and make it only playable through the Game pad for simplicities sake (wouldn't have been to hard to add really). I also dismissed the multithreading and buffering concept as overly complicated and retarded.

The end result was it didn't poll every key (obviously), just the ones it was told to poll and then fired the related event if they came up as having changed, but it was still a pain and a half to keep logic and input separate, which was what I was trying to do.

Still meant I couldn't really change input 'on the fly' like I really wanted (as that'd still require polling every single button), and neither could your method since, again: still would need to poll every key to figure out what they just pressed to change the control scheme.

On the plus side it was fairly reusable and I was able to make PacMan, multiplayer Space Invaders, Pong, the usual test projects with it, alongside the Screen system I hacked together, before I decided I was too ashamed of it and scrapped it XD

Still, yeah, I'm just being awkward in my event-based-ways...Still, if you're going to provide networking like you said, isn't it generally best to try and separate input and logic in those situations?
The input manager merely reports the state of the various input devices. How does event-based input handling versus request-oriented input handling have anything at all to do with networking? :/ They're completely separate systems.
Logged
Quote
There's such a double standard about religion in the modern world. Catholics can gather, wear white robes, and say "In nomine Patris, et Filii, et Spiritus Sancti" and be considered normal.

But if my friends and I gather, wear black robes, and say  "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn", we're considered cultists.
  • Development Blog
Re: C++/Direct3D Pong Tutorial Series
« Reply #9 on: February 16, 2010, 11:27:46 am »
  • (y)(;>.<;)(y)
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3293
When you say networking you mean online multiplayer, that kind of thing, right?

From what I've seen it makes it easier to handle commands without the characters themselves having to explicitly know they're getting them from the networking. If each object that takes input is manually polling, you'd need separate classes for "LocalPlayer" and "NetworkedPlayer" that both inherit from "Player" and have completely different 'input' code.

My simple input -> event wrapper that I wrote would mean you could simple have a Player class capable of being bossed around by anything and everything it 'listened' to.
« Last Edit: February 16, 2010, 11:56:58 am by TheDarkJay »
Logged
Re: C++/Direct3D Pong Tutorial Series
« Reply #10 on: February 16, 2010, 08:51:26 pm »
  • Minalien
  • *
  • Reputation: +10/-1
  • Offline Offline
  • Gender: Female
  • Posts: 2119
Dude, you're totally not getting it. Using a method of querying the input manager versus calling an event is a completely separate issue from the implementation of the game/scene objects. Regardless of whether somebody uses a query method or an event method, scene objects will generally be handled the same way. I'm talking on the global level, not on the per-object level.

Stop assuming that the input manager has a direct relationship with scene objects. It doesn't. At all.
Logged
Quote
There's such a double standard about religion in the modern world. Catholics can gather, wear white robes, and say "In nomine Patris, et Filii, et Spiritus Sancti" and be considered normal.

But if my friends and I gather, wear black robes, and say  "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn", we're considered cultists.
  • Development Blog
Re: C++/Direct3D Pong Tutorial Series
« Reply #11 on: February 17, 2010, 03:29:03 am »
  • (y)(;>.<;)(y)
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3293
Sorry, hard to keep coherent between thoughts at 3am and 12pm, I actually had to try and figure out what my point there was actually since I'm too stubborn to go against something I say earlier, sorry :(

I think way back a few posts ago my original point was more "I prefer the event model, personal preference and it tends to fit my style of separating things into inherently unrelated (or loosely related) objects, and XNA made it harder for me to do that effectively when it could have provided easy access to both polling and event methods with very little fuss" and I sort-of drifted into lord-knows-where from there =P

I think somewhere in that I started making the argument that it's much harder to allow the "please press the key you want to do x" without polling every key multiple times in the system (since the internal logic of XNA, I'm guessing here, is probably going hardware poll -> OS event -> software storage -> software poll, and trying to go back to events there is adding more stages to that), but aborted it for no apparent reason XD

*sighs* Sleepy jason makes poor points, sorry XD
« Last Edit: February 17, 2010, 03:33:21 am by TheDarkJay »
Logged
Re: C++/Direct3D Pong Tutorial Series
« Reply #12 on: March 21, 2010, 08:58:17 pm »
  • Minalien
  • *
  • Reputation: +10/-1
  • Offline Offline
  • Gender: Female
  • Posts: 2119
Third tutorial is up, if anybody's actually going through them here.
Logged
Quote
There's such a double standard about religion in the modern world. Catholics can gather, wear white robes, and say "In nomine Patris, et Filii, et Spiritus Sancti" and be considered normal.

But if my friends and I gather, wear black robes, and say  "Ph'nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn", we're considered cultists.
  • Development Blog
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.107 seconds with 63 queries.