Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your help!

We need 1 more developer from Canada and 12 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a $50 Amazon gift card. Click here to get started!


Bregma

Member Since 09 Dec 2005
Online Last Active Today, 05:31 AM

#5248978 What do you guys use as a key in RPG data structures?

Posted by Bregma on 26 August 2015 - 07:10 AM


There are "attack" objects, which all inherit from a base attack class (and may be composed of some other things in the future)—they do all the calculations given a character's stats and some damage multiplier. This will make it easier to give specific characters specific abilities. When performing an attack, one of these objects is created, passed to an attack-event, and an attack-handler applies all the appropriate damage.

An attack is an action, a verb.  You should not model verbs as nouns, or else you end up with anathemata like attack.do(hero, enemy) instead of a more natural hero.attack(enemy).  Attack handlers, attack events, attack objects:  what do those look like in real life?




#5248139 Memory management

Posted by Bregma on 21 August 2015 - 04:44 PM

So I ended up putting this in there:

virtual ~State() {};
For some reason the RAM still grows but after 5-6 switches between states it stabilizes. ohmy.png
I guess that solved it. Not to sure about why it keeps growing in the beginning though. Thank you!

 

 

First, your problem was you did not declare the destructor of State virtual (you have to explicitly do that, or the derived destructors do not get called when you delete by a pointer to the base class).  Traditionally in a pure virtual base class you do that by making it pure abstract virtual and giving it a body.  Like this.

class State {
    virtual ~State() = 0;
};

And in a .cpp file, add this.

State::~State()
{ }

You add the destructor body in a separate .cpp file because it tells some compilers where to emit code for the various virtual thunks (don't worry about it; trust me, it's a good idea when using certain compilers).  You could, for longer link times, just add it as an out-of-class inline member function definition.  In summary, the default compiler-supplied destructor does not do what you need here, so you have to provide your own.  There is always a default compiler-supplied destructor if you do not supply your own.  Even if you don't think there is one.

 

Second, it's very likely you're seeing memory growth at the start because standard library containers (including smart pointers) use a pooling allocator by default, which hangs on to its freed memory.  This is normal and under most circumstances a desirable thing.




#5248094 Memory management

Posted by Bregma on 21 August 2015 - 12:22 PM

I'm curious why you would have explicit init/destroy calls that get manually invoked after/before the constructor and destructos of your State class.  WHat would happen if you moved those functions into the constructor/destructor?




#5247846 Matching Parameter Names to Class Fields

Posted by Bregma on 20 August 2015 - 06:14 AM

I am not a fan of "coding standards" or other petty dominance games in general;  I have rarely seen them contribute positively to long-term overall productivity.  I also abhor the type wrats misnamed as Hungarian notation often used to obfiscate code.

 

That said, I find an appropriate naming convention to indicate scopishness in C++ to be a major win.  I have found over many years that decorating member variables and namespace-level variables while leaving local variables (including function parameters) undecorated to be a highly desirable habit.  It took me and my curmugeonly ways a long to ti arive at this conclusion, but I now embrace it.

 

Be wary of using an underscore prefix for this wart, because you stand a good chance of running afoul of language rules.  See ISO/IEC 9899:2011 [7.1.3](1) bullet 2, which effectively precludes the use of an underscore prefix for a member variable.




#5247842 C++ | Fixed Byte Size

Posted by Bregma on 20 August 2015 - 05:50 AM

Even these suggestions for uin16_t and such are technically wrong. The C/C++ standard does not guarantee that sizeof(uint16_t) == 2. It only guarantees that uint16_t is big enough to hold at least 16 bits.


The C programming language standard ISO/IEC 9899:2011 - Programming languages - C [7.18.1.1](2) says this about <stdint.h>.

The typedef name uintN_t designates an unsigned integer type with width N . Thus,
uint24_t denotes an unsigned integer type with a width of exactly 24 bits.

 
The C++ programming language standard ISO/IEC 14882:2014(E) – Programming Language C++ [18.4.1](2) has this to say about <cstdint>.

The header defines all functions, types, and macros the same as 7.18 in the C standard.


Sounds like they're pretty strictly defined to me.




#5247761 C++ | Fixed Byte Size

Posted by Bregma on 19 August 2015 - 04:22 PM

To be fair, he asked about C++, not C, so #include <cstdint> to use int32_t etc.  See a good C++ reference.




#5246451 A request for advice

Posted by Bregma on 14 August 2015 - 06:43 AM

1st Question: Do i use Flash and Javascript for my first creation or go straight for Unity and C# ?
This questions stems from my teacher saying Slash is basicly dead.

Yes, use what you know and focus on learning the new skills required for game development. Ignore your teacher here: you're not going to be writing a widely-distributed AAA game for your first few attempts.

2nd Question: What platform do i aim for ? do i go for the mobile devices such as android or do i go for my initial choice which is pc (and eventually make a game enjoyable enough to upload to kongregate/newgrounds/armorgames to get feedback).

GO for the PC. You have one (9 points), you're most familiar with it so you can focus on learning the new skills required for game development (another 9 points) and most of your friends and family you're going to show off to have one (3 points).

3d Question: Do you have any advice you could give to a greenhorn who has never actually made a game? are my expectations unrealistic? should i focus on the programming languages first instead of trying to do both?

Focus on the game programming first, and don;t set your expectations too high for your first few games. I'm not saying don't set you expectations high, I'm saying make your first goal a small simple game (say, Breakout, Pong, Tetris), then move on

You're going to know it's time to move on to something like C# and Unity when you can no longer do what you want using the tools you know to do the bugger stuff. By then, you'll already have a fundamental understanding of things like the game loop, asset management, and so forth.


#5246190 what to major in college?

Posted by Bregma on 13 August 2015 - 06:48 AM

This question in its basic form comes up frequently in these forums, and I always give basically the same answer.

 

You are not a career.  You are not an entry-level job.  When choosing your post-secondary education, persue the studies that you're most interested in.  If you like visual art, study visual arts and art history.  If basketweaving is your dirty little secret, there are degree programs in which that is prominently featured.  Just finish your degree or diploma.

 

You're probably going to have a lot of jobs (maybe multiple careers), but you're only going to have one life and most of it is going to not be spent as a worker cog.  When I was choosing my post-secondary education, the gamedev industry didn't exist; heck, the PC industry didn't even exist.  Life is short, make it wide and base your long-term decisions on that.




#5245938 Can game development excel with abstract concepts?

Posted by Bregma on 12 August 2015 - 05:00 AM


Electrical devices use power, and their relation is P = U * I, where P is the power delivered, U is the voltage, and I is the current. Cables have resistance (not much, but it's non-zero at room temperatures) as U = I * R. U is the voltage that you loose, I is again the current, and R is the resistance of the cable. It's constant, and decreases with diameter of the cable.

Power loss is proportional to the square of the current (P = I^2 * R  --  Ohm's law, arrived at empirically).  That's the key to AC superiority for a commercial electrical power distribution grid.  The result was arrived at through analysis.




#5245834 Breaking out of a nested loop

Posted by Bregma on 11 August 2015 - 03:30 PM


Here's the recommended way:

I see you're supporting Vista, ME, and XP, but not Mac OS X or Linux.  Is there a cross-platform version of your solution?




#5245832 Can game development excel with abstract concepts?

Posted by Bregma on 11 August 2015 - 03:17 PM

Well, now, the three main modes of problem solving are empirical, analogical, and analytical.

 

By trying to single-step through an iterative problem, you're engaging empirical problem solving.  You observe the problem until the solution is found (sometimes called 'brute force').

 

If you were to break the problem down into smaller sub-problems until you have a know solution to each one, you're being analytical.  You reduce the problem until the solution is found (analysis).

 

If you were to build a (mental) model in which you understood each part, you're being analogical.  You understand the problem in terms of known solutions until an appropriate one (an analog) is found.

 

All three modes have been used very successfully in the past, and often combined at different points.  For example, empirical analysis was used to create an mathematics of rotational symmetry, which was analysed to develop agebraic field theory which was later treated analogically to develop generalized linear algebra of arbitrary dimensions.  Technically, your favourite 3-D shooter got started as a game of spin-the-bottle.

 

Most people favour one mode over the others.




#5245436 C Language and SDL - Getting Ready for Vulkan API

Posted by Bregma on 10 August 2015 - 06:18 AM


Productivity is important. I don't want to use too many libraries for the first 6 months or so.

I think you have that backwards.




#5244927 Computer Science Master's, Thesis or Coursework Option?

Posted by Bregma on 07 August 2015 - 06:12 AM

Of all the prospective hires I've evaluated, it has never mattered what courses they've taken in school.  What has mattered is that they've graduated from a recognized institution.

 

It's true that if the title of their thesis is on their CV, it might influence me, but I've always found practical work more important than academic work.  I suggest the path you choose be more aligned with your personal preferences (eg.  if you're good at writing, a thesis, and if you prefer exams, courses) and not what you think will get you a job.  You will get a job, but you won't get a second chance at your degree.




#5243152 undefined symbol: curl_easy_setopt

Posted by Bregma on 28 July 2015 - 06:26 AM

It's highly likely you're going to need a whackload of additional libraries linked in statically.

 

For example, libcurl-gnutls will require libgnutls to also be lined in, which in turn requires libpgp-error, and so on.  It's turtles all the way down.

 

Also, statically linking security libraries used to be considered a severe security hole.  You'll need to rebuild most of those libraries yourself from source to statically link them because on Ubuntu, at least, the static versions are not available.




#5242752 Pimpl and potential alternatives

Posted by Bregma on 26 July 2015 - 07:59 AM

NVI is a better alternative to PIMPL much of the time.

 

NVI allows the explicit separation of your public interface (which is public and non-virtual) from your private/implementation interface (which is private, and possibly virtual).  It ends up accomplishing the same thing as the PIMPL but without a lot of code duplication and with more explicit self-documentation on functional variance across derived classes.

 

The only advantage of PIMPL of NVI is you can hide ABI changes behind PIMPL.






PARTNERS