[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 483: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4688: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4690: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4691: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4692: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3823)
shmup-dev | forum - View topic - Complex pattern realization (C++)

Complex pattern realization (C++)

This forum is for discussing shmup development, tools, engines and techniques.
Posts: 2
Joined: Wed May 15, 2013 12:49 pm

Complex pattern realization (C++)

Postby Noro » Wed May 15, 2013 2:01 pm

Hello everyone.

I'm developing a danmaku shmup with lots of bullets on screen and complex patterns for a while now. I've used to hard-code some patterns with only giving some parameters(angles, number of bullets etc.) in script but now I realize that I need a full-scriptable system for creating patterns using only script language. So I started to develop it and at some point came to a fork without quite knowing what path to take.

Let me describe my problem.
Thanks to the tutorials from this site I have a nice and tight optimized array of bullets in memory represented by static structure. Each bullet have a pointer to a pattern object that process it's movement each frame. Currently I store all data needed for patterns in bullet structure so I never need to create a pattern objects more than once at the initialization of the program. But this can be tricky if the pattern object created from script and I never know how much parameters it need to operate. Even if I give some extra memory for bullet structure(say, large array of parameters that can be freely used by scripted patterns), this is not guarantee that it will be enough at some level of complex nested patterns. And it will bloat my neat array of bullets. The obvious alternative is to create pattern objects for each bullet and store all needed data in patterns. But this way I need to create and destroy a lot of objects during program execution. And I don't have strong enough programming experience to estimate performance impact in this case.

So if anyone implemented something like this, can you give me some advise of pros and cons of both approaches, please?

User avatar
Posts: 7
Joined: Mon Aug 13, 2012 7:40 am

Re: Complex pattern realization (C++)

Postby jbadams » Sun May 19, 2013 1:19 am

What platform(s) are you targeting? If you're on PC it's likely that you won't experience noticeable performance problems from creating those additional objects.

I'd suggest implementing the simplest solution first, and then if -- and only if -- you're experiencing performance problems use a code profiler to find the offending code rather than simply guessing at where best to optimise. If you're targeting mobile platforms however, you may want to put more thought into a more efficient solution, but otherwise it's likely to be wasted effort. :)
- Jason Astle-Adams
from : |

User avatar
Posts: 8
Joined: Sun May 19, 2013 1:01 am

Re: Complex pattern realization (C++)

Postby Square » Mon May 20, 2013 1:21 am

It's hard to answer, or visualise your problem entirely from a forum post :)

I don't fully agree with jbadams's solution, there is always danger in taking the non-optimised route.

I tend to think progress in games creation is about your own architecture and reasons for designing it that way if that helps weigh up the options.

Though, here a lot of professional programmers would test parts of both scenarios, I get the feeling that you should if you have the time to do that.
Or - simply jotting down the factors, making lists of pro/con estimations on paper or something similar. A diagram or two?

I think you'd be surprised what you can ascertain from getting the facts out of your head and in front of you.

User avatar
Posts: 76
Joined: Mon Aug 20, 2012 8:11 pm

Re: Complex pattern realization (C++)

Postby wondersonic » Mon May 20, 2013 6:29 am


User avatar
Posts: 34
Joined: Sun Jul 29, 2012 4:44 pm

Re: Complex pattern realization (C++)

Postby kdmiller3 » Wed May 22, 2013 2:00 am

Heavily scripted- or data-driven designs naturally trade some performance for flexibility but I wouldn't fret about it too much to start with. It's more important to get things working correctly and reliably. Unless you're doing something seriously sub-optimal and targeting an unusually weak platform, you'll be able to hit monitor refresh rate without trying.

"Premature optimization is the root of all evil (or at least most of it) in programming." --Donald Knuth

User avatar
Posts: 8
Joined: Sun May 19, 2013 1:01 am

Re: Complex pattern realization (C++)

Postby Square » Wed May 22, 2013 5:49 pm

Looking at the original post, I have to say I disagree.

There is nothing wrong with optimisation at this point. The quote by Donald Knuth I believe is not in terms of "don't optimise" and I don't believe Noro's solution is "premature optimization", from what I gather he can think about it a lot.

I'm just thinking about influence and what we are saying here, which is why I suggested he investigates the solutions.

User avatar
Posts: 7
Joined: Mon Aug 13, 2012 7:40 am

Re: Complex pattern realization (C++)

Postby jbadams » Thu May 23, 2013 10:24 am

- Jason Astle-Adams
from : |

Posts: 2
Joined: Wed May 15, 2013 12:49 pm

Re: Complex pattern realization (C++)

Postby Noro » Mon May 27, 2013 3:39 pm

(Have been on my leave, away from computer)

Thank you all for great advices. Have to remember em all if I'll be working on commercial project some day. But now I'm doing it for the fun of it and yes, for learning experience.
I think I'll try simplified examples of both approaches and look what I get from profiler, after all.

Posts: 1
Joined: Sat Jun 29, 2013 2:52 pm

Re: Complex pattern realization (C++)

Postby Odessi » Sat Jul 06, 2013 1:12 pm

I created a language for scripting bullet patterns a few years ago. It's here if you want to take a look: http://code.google.com/p/bulletscript/

Return to Development

Who is online

Users browsing this forum: No registered users and 3 guests