Jump to content

  • Log In with Google      Sign In   
  • Create Account

PeterStock

Member Since 17 Oct 2005
Offline Last Active Dec 03 2014 10:58 AM

#5179061 (Tower Defense) Template metaprogramming or Factory functions to avoid class...

Posted by PeterStock on 09 September 2014 - 05:35 AM

This is a good read. You might find it useful.

 

http://www.gameprogrammingpatterns.com/

 

In particular, these might be relevant:

 

http://www.gameprogrammingpatterns.com/type-object.html

http://www.gameprogrammingpatterns.com/subclass-sandbox.html




#5129290 fractal result by accident

Posted by PeterStock on 06 February 2014 - 06:59 AM

I am impressed with the patience shown here. It's a Moire pattern.




#5112196 How to stick on slopes?

Posted by PeterStock on 26 November 2013 - 12:35 PM

I had the same problem and my approach was to suck the character down to the ground when it was touching the ground last frame and <= [some limit] distance from the ground this frame. I set [some limit] based on the max x velocity and max slope of the ground.




#5102459 Embedding data into an executable.

Posted by PeterStock on 18 October 2013 - 12:01 PM

Resource scripts are just text files, and the ones I've used are really simple - just an integer ID and a filename of the data to embed.

 

The 'custom build step' tab in the project options is probably the place to do the compile-time generation.




#5101285 Physics / Calculus III Problem

Posted by PeterStock on 14 October 2013 - 07:28 AM


I figured that some of you may want some practice on this, and seeing as how I can visualize this problem but I do not know the proper steps to take, it could be helpful to all of us.

 

You should ditch physics and go into politics.




#5100103 Data Structures & Algorithms for Blackjack Simulator

Posted by PeterStock on 10 October 2013 - 02:29 AM

You know that the number of items (cards) is going to be very small (52), so I'd think that the O() order of performance doesn't matter so much.

 

I noticed one thing though - you mentioned extracting statistics for betting strategies. I think real-world shuffling is actually very un-random, if you do your shuffling as described it might not be such a good model. Maybe make N splits in the deck and re-arrange those stack of cards, repeated multiple times? I don't know how casinos do this though, maybe they have a machine or something?




#5094258 (HELP) The Noobie beginnings. Struggles in beginning Game Programming.

Posted by PeterStock on 15 September 2013 - 11:27 AM

All imperative/procedural languages have a lot in common, so switching from one to another isn't too hard once you're familiar with the basic concepts.

 

C++ has some parts that are complicated, but you don't need to use *all* the features it provides, so you don't need to learn it all to start with (or ever, if you don't need them).

 

C# and Java are a bit more friendly, due to not needing manual memory management.

 

There's no wrong choice, they're all right - use whichever you want :)




#5093050 How do I create the equation for a curve?

Posted by PeterStock on 10 September 2013 - 11:24 AM

If I remember correctly, Hermite curves are the simplest ones that go through all the points. It sounds like these might fit your requirements.

 

http://en.wikipedia.org/wiki/Hermite_curve




#5088742 optimization and power consumption rate

Posted by PeterStock on 24 August 2013 - 02:40 PM

Do the optimization made less power consumption on computers?

Yes, with the exception of the situation Adam described - if you use the extra time you have to do more stuff (render more frames), then that might not be lower power. But if you use the time to do nothing (your process/thread sleeps) then it's lower power.

When you have >60 fps then you might want to put in a frame limiter to throttle it to 60 and sleep during the 'spare' time. Or substitute whatever X you want instead of 60.


#5086832 I need help with learning game development

Posted by PeterStock on 17 August 2013 - 01:39 PM

Fair point, well made.

Actually I remember being impressed by some of the videos in the new wave of free university courses available now (I think that was udacity). And your point about doing is important - I agree you'll not get far with a book or lectures if you just read/listen and don't do exercises.

I should have qualified education with 'good' - agreed that not all are good.

I think the point I intended but may have failed to make is that programming is not all about learning the syntax of a certain language. My algorithms and data structures course from university was very useful, and showed me that for all the low-level optimisation you can do, it doesn't really count for much compared to the gains you can get from taking a better high-level approach to a problem.


#5086826 Efficient data packing

Posted by PeterStock on 17 August 2013 - 01:20 PM

I'll try splitting the buffer and see what happens, but just curious about something.
Every single example/tutorial I have seen always stores the object in a vector but never a pointer to that object, why is that?
std::vector<particle *> /////////<--------------------------- would this make no performance difference.

That might be more convenient if you want to have multiple lists of different particles (i.e. render all the 'fire' particles together in one way, all the 'water' ones together in a different way, but still simulate them all together in the same way). However, then they aren't necessarily consecutive in memory and you can't do your call to
glVertexAttribPointer(col, 3, GL_FLOAT, GL_TRUE, sizeof(particle), (GLvoid *)NULL + (6*4));
which incidentally looks dubious to me - the value of 6*4 might not work if a compiler does struct member packing differently, or you change the code later on.

If it's really performance-critical, I'd split out the positions into a float array, so it can be passed to GL in a simple, reliable way and store a pointer to the relevant index into this array within each instance of the particle class. All the other stuff I'd leave nice and tidy, wrapped up in particle.


#5086805 How to handle endianness?

Posted by PeterStock on 17 August 2013 - 12:07 PM

All modern computers I'm aware of have 8-bit bytes, and store integers in 2's complement. So you'd get the same thing on all platforms when you write bytes. Cast signed ints to unsigned before doing any bitwise operations on them (cast them back to signed on reading in, once re-constructed). Handle floats by making the bit pattern into an int, then decomposing to bytes as you would an int.

union IntOrFloat
{
int i;
float f;
};
 
float f = 1.0f;
IntOrFloat iof;
iof.f = f;
printf("%d", iof.i);
Oh, and you probably want to use defined width types rather than int and float, which will be different on different platforms (e.g. 32/64 bit OSes).

Don't do
float f = 1.0f;
int i = *((int *)&f);
because it might not do what you want. Look up 'aliasing' to find out why.


#5086544 First game project, a 2D platformer.

Posted by PeterStock on 16 August 2013 - 12:31 PM

a dude that shoots everything to smitherness

222px-Waylon_Smithers_1.png


#5082535 Rig controlled by simulated muscle

Posted by PeterStock on 02 August 2013 - 12:01 PM

Ambitious :)  Like many good ideas, something similar has been done before:

 

http://www.karlsims.com/evolved-virtual-creatures.html

 

If you've never heard of this you should totally take a look.




#5071434 Efficiency question

Posted by PeterStock on 20 June 2013 - 06:53 AM

In my opinion, clean design is much to do with minimising the connections between modules. Every program has to be decomposed into multiple modules (sub-problems), and the higher the independence between each of these, the cleaner the program design.

 

Of course, how you choose to divide a program up can be linked to the algorithms you choose to use. Going back and making a different choice can require a (very) different program architecture, or you end up with a horrible mess :)

 




PARTNERS