• 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.
Sign in to follow this  
Followers 0
Icebone1000

How/Who create the GameObjects?

41 posts in this topic

[source lang="cpp"]class Game{

list < GameObjects * > m_gos;

void Update(float delta){

for(list::it goIt ..)
(*goIt)->Update(delta);
}

...
};[/source]


Pseudo code..

Id like to make the Class Game the sole responsible for the creation and deletion of the gameobjects.
I always do this with a template function:
[source lang="cpp"]template< class derivedGO>
derivedGO* Create(){

derivedGO *p = new derivedGO();
m_gos.add(p);
return p;

}[/source]
And this is the only way to give the Game class the objects (so if they got created externally, they will not be part of the game).
The only (really annoying imo) problem is that derivedGO must provide a compatible constructor, this sucks, cause I always, then, have to create a Init(params) function that is always called just after calling create..

Is this poor design? Edited by Icebone1000
0

Share this post


Link to post
Share on other sites
[quote name='L. Spiro' timestamp='1350950978' post='4992943']
For example, objects don’t exist inside the game, they exist inside scenes.
[/quote]

What about game objects that need to persist across scenes? Like puzzle logic state that spans levels? Or the main player character + all of his stats/score/whatever?
0

Share this post


Link to post
Share on other sites
Data that needs to persist across scenes/states goes on the Game class. That is specifically its job if nothing else.
But that does not mean the 3D or 2D rendering data for your main character etc. That just means your current level, current HP, etc. The bare minimum that could be accessed by any part of the game at any time.

[EDIT]
Note that I failed to mention that all that data that belongs just to one game or another should be part of your “MyGame” class which inherits from “Game”.
Game itself is general across all games and should obviously not be the place for that kind of data.
[/EDIT]


L. Spiro Edited by L. Spiro
0

Share this post


Link to post
Share on other sites
To represent different scenes:

enum { SCENE_LOGO, SCENE_TITLE, SCENE_OPTIONS, SCENE_PLAY, SCENE_GAME_OVER };
int c_scene=SCENE_LOGO; // current scene
-4

Share this post


Link to post
Share on other sites
nox_pp: I agree that OOP sucks :) C++ is for newbies who know nothing about real programming, but I must admit that uglybdavis presented some smart code. I admire that.

typedef struct {
void *p;
int x, y, w, h,
bpp, key, alpha;
} IMAGE;

int load_image(IMAGE *i, char *file);
void move_image(IMAGE *i, int x, int y);
void draw_image(IMAGE *i);

My ASM programming site: http://sungod777.zxq.net/
-22

Share this post


Link to post
Share on other sites
[quote name='rdragon1' timestamp='1350971519' post='4992990']
What about game objects that need to persist across scenes? Like puzzle logic state that spans levels? Or the main player character + all of his stats/score/whatever?
[/quote]

Switching betwen scenes also presents a pretty good chance to save your data to disk, then re-read it when the next scene loads. Rather than using globals to track things you could just treat data as data. This might not be a good case for a lot of things, but it works out very well with iCloud.

[quote name='uart777' timestamp='1350993240' post='4993065']

My ASM programming site: http://sungod777.zxq.net/
[/quote]
Assemblers are dumb and they suck. ASM is is for newbies who know nothing about how to code. Real programmers use butterflies. They open their hands and let the butterflies delicate wing flap once. The disturbance ripples outwards, changing the flow of the eddy currents in the upper atmosphere; these cause momentary pockets of high pressure air to form. These pockets act as lenses that deflect incoming cosmic rays focusing them to strike the drive platter and flip the desired bits. It's all explained right here: http://xkcd.com/378/
1

Share this post


Link to post
Share on other sites
"I don’t get the point of this post" - I merely demonstrated that OOP is not neccessary.

"When will an image have a negative width or height?" - When it's invalid/inverted (-1/0xFFFFFFFF).

"Why do you have to move the image in a separate step from drawing it?" - Because it's faster to send less parameters, but you don't know anything about push-call sequences.

L. Spiro: Let me show how to draw/paint/airbrush/sculpt anything: [url="http://www.facebook.com/uart777/photos_stream"]http://www.facebook....7/photos_stream[/url] You think you're so right, but you don't even know what your code converts to. How can you expect anyone to use your library?

uglybdavis: Forgive me for complimenting you [img]http://public.gamedev.net//public/style_emoticons/default/tongue.png[/img] "Assemblers are dumb and they suck. ASM is is for newbies who know nothing about how to code" - This statement shows how little you know about programming. You defined a PIXEL wrong. Alpha should be in leftmost byte (0x*AA*BBCCDD). Stop changing byte orders [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img] You disrespect ASM because you don't know anything about the processor's language.

"It's all explained right here" - Dummy [img]http://public.gamedev.net//public/style_emoticons/default/tongue.png[/img] Edited by uart777
-12

Share this post


Link to post
Share on other sites
spiro: Cool drawing [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

jbadams: Sorry, it just seems that gamedev has changed so much since it was released. This defensive-ness is caused by the disrespect towards ASM programmers like Lamothe and myself. "Acting like you're better than everyone else" - Ultimately, no one is better than anyone else. We're all just little specks of Stardust. I apologize if this is your perception of me. "You've now asserted the alpha should always be the leftmost byte of a pixel" - Yes, that's how it was originally: AA.RR.GG.BB. Otherwise, it requires shift+and. Why change it? Why store things upside down and backwards? Why cause millions of headaches?

Back to the subject: OOP is not required. Never needed it. Edited by uart777
-5

Share this post


Link to post
Share on other sites
[quote name='uart777' timestamp='1351174823' post='4993797']
spiro: Cool drawing [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]
[/quote]
Coming from an artist such as yourself, that is a compliment. Thank you.
Your Simba t-shirt is also top-notch quality.


[quote name='uart777' timestamp='1351174823' post='4993797']
jbadams: Sorry, it just seems that gamedev has changed so much since it was released. This defensive-ness is caused by the disrespect towards ASM programmers like Lamothe and myself. "Acting like you're better than everyone else" - Ultimately, no one is better than anyone else. We're all just little specks of Stardust. "You've now asserted the alpha should always be the leftmost byte of a pixel" - Yes, that's how it was originally: AA.RR.GG.BB. Otherwise, it requires shift+and. Why change it? Why store things upside down and backwards? Why cause millions of headaches?
[/quote]
How it was originally?
I feel that you are a prime example of what was mentioned [url="http://www.gamedev.net/topic/633214-struct-vs-classes/page__st__20__p__4993348#entry4993348"]here[/url].
You learned early-on what compilers do internally and took it to heart.
You changed the way you coded based on what you learned from one compiler. You didn’t know that other compilers behave differently and may easily generate different code.
I can tell you for sure that there are rare cases in which my C compiler will generate horribly slow code for some switch cases.

How C++ code becomes machine-language is not strictly specified and you should understand that what my code “becomes” can vary depending on the compiler I use.

Don’t spend your time studying how some compiler created some code.
It would be better to spend your time reading the C/C++ specifications, and if you are so inclined make your own compiler. You will definitely learn a lot that way.


L. Spiro
2

Share this post


Link to post
Share on other sites
[quote name='uart777' timestamp='1351174823' post='4993797']
jbadams: Sorry, it just seems that gamedev has changed so much since it was released.
[/quote]

Ah, yes, I remember the old gamedev.net. You know, back in August of 2012 when you joined. Those were the days, eh?

[quote]
This defensive-ness is caused by the disrespect towards ASM programmers like Lamothe and myself.
[/quote]

I've heard of Lamothe. Got a couple of his books. Much respect for that dude, he's been around awhile.

Never heard of you, though.

[quote]
"You've now asserted the alpha should always be the leftmost byte of a pixel" - Yes, that's how it was originally: AA.RR.GG.BB. Otherwise, it requires shift+and. Why change it? Why store things upside down and backwards? Why cause millions of headaches?
[/quote]

How things were originally has exactly 0 bearing on how things are now. Pixel formats now have everything to do with hardware support. Modern hardware can handle RGBA data in so many different formats, that you are basically free to pick your preferred method.
0

Share this post


Link to post
Share on other sites
Spiro: My only intention is to defend ASM programmers like Andre Lamothe, Michael Abrash and Diane Gruber, the queen of graphics programming. She's hot, too :) Wouldn't you love to have a girl like her who does programming?
:) "Coming from an artist such as yourself, that is a compliment" - Thank you ;) Simba's my baby.

"I can tell you for sure that there are rare cases in which my C compiler will generate horribly slow code" - Creating a HL compiler is all about converting standard/infix expressions to RPN. You can perform optimizations in RPN format: Resolve constant subexpressions, replace mul/div with shifts by power of 2, reorder cumulative operations, double jmps/jxx, etc.

Jason: Sorry again for being way off subject, but the issue was brought up and I responded. Spiro, let's create another post about writing HL compilers :)
0

Share this post


Link to post
Share on other sites
fleblanc: "Modern hardware can handle RGBA data in so many different formats, that you are basically free to pick your preferred method" - Yes, but RGBA requires shift c>>8 and &0xFFFFFF. Please respond to this.
-2

Share this post


Link to post
Share on other sites
Who gives a shit? That's my response. Any code where you might conceivably have to shift and & is not going to be performance critical, and if it is performance critical, and you are noticeably slowed down by a shift and bitwise &, then you have seriously fouled up your design somewhere and you really ought to go back to the design table rather than worrying about pixel formats. Why are you worried about the performance of shifting and bit-wise operations anyway? Is this still 1996? If you need to switch something around, just swizzle in your shader and stop bringing up old shit and thinking it's a valid argument in the modern world.
2

Share this post


Link to post
Share on other sites
"Why are you worried about the performance of shifting and bit-wise operations anyway?" - Because it occurs milions of times per second in game/graphics programming. For example, one 1024x768x32 screen is 786,432 pixels which translates to 3,145,728 bytes. Multiply this by FPS.
-2

Share this post


Link to post
Share on other sites
[quote name='uart777' timestamp='1351182549' post='4993837']
"Why are you worried about the performance of shifting and bit-wise operations anyway?" - Because it occurs milions of times per second in game/graphics programming. For example, one 1024x768x32 screen is 786,432 pixels which translates to 3,145,728 bytes. Multiply this by FPS.
[/quote]

are you writing software renderers?
0

Share this post


Link to post
Share on other sites
Are you sure about that? Which driver team (NVidia, ATI, Intel) are you a member of, that you know what the driver is doing millions of times per second?

Like I said, is this still 1996? These days, performance critical code runs on the GPU, and the optimization landscape for modern GPUs is so much more complicated than "We must optimize out bitshifting and AND for performance" that it's actually hilarious that you still think the way you do.
2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0