This site is no longer active and is available for archival purposes only. Registration and login is disabled.

Objects accessing eachother (OOP question)


Objects accessing eachother (OOP question)

Postby Volte6 » Feb 18, 2004 @ 10:23pm

User avatar
Volte6
pm Member
 
Posts: 77
Joined: Feb 16, 2004 @ 8:14pm


Postby warmi » Feb 18, 2004 @ 10:32pm

Of course you are going to have to pass a pointer. I personally prefer to use some sort of rendering context class for the backbuffer ( basically a fancy wrapper around backbuffer) and a separate class for storing game images.
Each game object would then keep either a pointer or some sort of ID for the images associated with it and request at run time a pointer to the images it needs from the images repository class.

To access other classes (rendering context or images repository) generally you would have to either pass a pointer to your game objects class or create a global static class containing methods for obtaining pointers to various global classes and include header to it with every class definition.
warmi
pm Insider
 
Posts: 518
Joined: Aug 24, 2002 @ 8:07am
Location: Chicago USA


Postby Pam » Feb 18, 2004 @ 10:34pm

There are many ways to do this of course.

I have a RasterizerObject that handles all of the drawing and keeps track of the backbuffer, etc.

Your other objects can store a pointer to the RasterizerObject and call routines in that object to draw stuff on the screen.

Pam
All the easy problems have been solved.
User avatar
Pam
pm Insider
 
Posts: 449
Joined: Jan 24, 2002 @ 10:30pm
Location: Ohio


Postby Kzinti » Feb 18, 2004 @ 10:36pm

Kzinti
pm Member
 
Posts: 3238
Joined: Jan 13, 2002 @ 5:23am


Postby Pam » Feb 18, 2004 @ 10:43pm

All the easy problems have been solved.
User avatar
Pam
pm Insider
 
Posts: 449
Joined: Jan 24, 2002 @ 10:30pm
Location: Ohio


Postby Volte6 » Feb 18, 2004 @ 11:55pm

User avatar
Volte6
pm Member
 
Posts: 77
Joined: Feb 16, 2004 @ 8:14pm


Postby Dan East » Feb 19, 2004 @ 1:26am

I usually have a struct representing the System State. It contains objects and data that I want available to all components. Classes like the console and renderer, and data such as the current frame counter, length of current frame, current tick count, user input data (keystates and mouse position), etc. Then I pass a pointer to that struct to all functions.

Older games like Quake just make all that stuff global, which is bad for a number of reasons. Most importantly, some other mobile platforms do not support global variables.

Dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Return to Windows Mobile


Sort


Forum Description

A discussion forum for mobile device developers on the Windows Mobile platform. Any platform specific topics are welcome.

Moderators:

Dan East, sponge, Digby, David Horn, Kevin Gelso, RICoder

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum