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

Some newbish C++ questions


Some newbish C++ questions

Postby Volte6 » Feb 17, 2004 @ 7:16pm

I'm just looking for some direction. I have no problem researching the answers, but don't really know what to look for or where to start.

1.) What is the standard method for dynamically allocating memory. For example, if I don't know how much memory will be needed for a string (Do I just cap it somewhere and assume that to be the max?), or if I don't know how many players, how do I dynamically add another object, and track it? Do I ALWAYS pre-allocate the maximum amount, or is there a way I can deal with the unknown?

2.) What about stuff that is only around some of the time? For example, I've created a demo of some balls bouncing around the screen. I know upon compile time that I want 100 balls bouncing. I do a for-loop through an array, and call the move() method on each one. BUT, what if those balls aren't going to exist until 20 minutes into the game... I shouldn't be calling a for loop, right? Is there some sort of convention regarding 'registering' created objects with a 'master' controller object of some sort? Or what if I want a custom SIP? I don't want it waiting for input constantly... but only when applicable.

3.) Finally, what is a standard way to accept input from a user (character/integer wise)? If I want to create a custom SIP (For a full screen app), I think I need to know how to GET that info from them... I'm guessing this is actually directly related to the SIP object though.

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


Postby fast_rx » Feb 17, 2004 @ 8:15pm

Using the STL vector or list is one way to handle the second part of #1 and #2.

It will allow you to add and delete your "objects" as needed...

This post http://www.pocketmatrix.com/forums/view ... hp?t=14968
was just talking about loading a string from a file when you don't know how long it is.
User avatar
fast_rx
pm Member
 
Posts: 660
Joined: Jun 10, 2003 @ 4:24pm


Postby Volte6 » Feb 17, 2004 @ 8:27pm

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


Postby fast_rx » Feb 17, 2004 @ 8:46pm

I don't quite follow why you're concerned about the adding and deleting when that's what you want... You only add and delete when you need to.

There's not as much overhead as you think... I'm using a vector of structures for particle effects that constantly goes from a few to hundreds and back constantly and have great performance.
User avatar
fast_rx
pm Member
 
Posts: 660
Joined: Jun 10, 2003 @ 4:24pm


Postby Volte6 » Feb 17, 2004 @ 8:57pm

You're probably right. I'm [USED] to Actionscript where every bit counts ;) I've been turned completely paranoid of wasting processing power hehe.
Last edited by Volte6 on Feb 18, 2004 @ 12:45am, edited 1 time in total.
User avatar
Volte6
pm Member
 
Posts: 77
Joined: Feb 16, 2004 @ 8:14pm


Conceptual question

Postby Volte6 » Feb 18, 2004 @ 12:45am

Okay, in terms of concepts and organization, here is what i'm thinking... can anyone tell me what is wrong with this, or if there is a more standard method? Is this acceptable for a game program?
I am excluding the processing of input, background drawing, etc.,.. I'm more interested in knowing if I have this conceptually correct.
Objects:

1.) My Application object. It manages everything from the highest level. It calls the maintaining methods from the following internal objects:
1a.) My Game object. It manages things like bullets, bad guys, player, animation, etc.
1b.) My Menu object. It manages menus, Popups, buttons, and so on.

The game objects maintenance method checks if any objects are in action, and calls THEIR maintaining functions (Enemy AI, drawing, movement, whatever).

The Menu object does the same, for menus. It can also disable processing of the game object (For example, if game action should pause when a menu displays).

The main application loop will call those methods in those objects each frame.

This may be pretty basic stuff, I don't know. This is how i'm thinking it over in my head, but I don't want to get crazy going in this direction if I've got it all wrong... Is this acceptable?
User avatar
Volte6
pm Member
 
Posts: 77
Joined: Feb 16, 2004 @ 8:14pm


Postby mlepage » Feb 18, 2004 @ 4:18am

You should probably take a look at the source code to some exisitng Pocket PC games. There is some floating around. It may not be perfect but it is one way of doing it and that's a start.
www.scalenesoftware.com
Great games for your Palm and Pocket PC!
User avatar
mlepage
pm Insider
 
Posts: 1050
Joined: Aug 3, 2003 @ 4:47am
Location: Canada


Postby Volte6 » Feb 18, 2004 @ 7:31pm

Well, since nobody has really OBJECTED to my structure, I'll assume it's sound enough, thanks :)
User avatar
Volte6
pm Member
 
Posts: 77
Joined: Feb 16, 2004 @ 8:14pm


Postby angedelamort » Feb 19, 2004 @ 5:16pm

Usually, when I make a game, it's really simple:

main Loop
{
- check inputs
- update all timer
- Draw on the screen
}

For the rest, like your structures, it's developper specific... If you think it will works, go for it. I don't see any problems right now with it. But like someone suggest, you may have a look at some ppc source code to see how it's done.
User avatar
angedelamort
pm Member
 
Posts: 304
Joined: Mar 7, 2002 @ 11:16pm
Location: Montreal, Quebec


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

cron