• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

Normie

OOP Help

4 posts in this topic

I''m making a game in 2D through Direct3D (I know which forum this is, keep reading). I have a class that looks something like this:
class CDirect3D  
{
public:
	void Update();
	void Render();
	CDirect3D();
	virtual ~CDirect3D();

private:
	IDirect3DTexture8* m_pTextures[256]; //arbitrary limit
	IDirect3D8* m_pD3D;
	IDirect3DDevice8* m_pDevice;
	ID3DXSprite* m_pSprite;
};
 
I was thinking of creating a new class to encapsulate m_pTextures in, so I have more control over each sprite. However, I''d need the new class to access members from CDirect3D (namely, m_pDevice). Having the new class inherit from CDirect3D just for the data members, however, seems a bit extreme. Is there a way to make some of the data members of CDirect3D accessible to the new class without making them global (or public static, or anything like that)? Also, the work I''ve done so far made me realize that I don''t know squadoo about organization in OOP. I know most of the technical details by heart, but my inability to create really good classes is seriously putting my game engine in jeopardy. Can anyone point me to a tutorial or something like that for OOP organization, esp. in video game development? Thanx, Normie "But time flows like a river... and history repeats." ... So...what about beaver dams?
0

Share this post


Link to post
Share on other sites
There are a few ways that you can do this. Some ways are easier than others and some ways are more object oriented than others. Here are some ideas:

a) Use C++ ''friend'' declarations to make member functions or variables available to your texture class.

b) Have a static member of your texture class that you set at some point with a pointer to the D3DDevice. In this way, you have access to the Device from all textures without storing a hundred copies of it. (This only works if you only have one D3DDevice in your entire app)

c) Pass in the device pointer everytime you need it. This is a bit of a hassle, but not a completely unrealistic choice.

Hopefully, these will give you some ideas. I''m sure there are more alternatives.
0

Share this post


Link to post
Share on other sites
Wow, thanks for the advice! Completely forgot about using friends (back to my C++ books for me, I guess ), and that static variable idea... damn, never even occured to me. Just to make sure I''m clear on the static variable idea...I assume you mean a private IDirect3DDevice8* in the sprite class, with a static function in the sprite class to set it? (I think I got it right, just want to check)

Oh yeah, and thanks for the third idea there...would probably just use that and be done with it, but that would be a serious violation of my "Lazy Programmer''s Doctrine"(tm)

-Normie, Lazy and Damned Proud
0

Share this post


Link to post
Share on other sites
Yes, I follow that same doctrine as much as possible too. I think most programmers do. Why else would we have ''printf'' instead of ''print_formatted_string'' and ''int'' instead of ''integer''?

As for your question, yes you have the right idea. Just make sure that you set that pointer before trying to do any drawing and also make sure you don''t try to release the device more than once.
0

Share this post


Link to post
Share on other sites
Your CDirect3D class could have a
CMyTextureClass* CreateTexture(...);
method that creates and initializes textures.

Magmai Kai Holmlor
- Not For Rent
0

Share this post


Link to post
Share on other sites