Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 07 Aug 2011
Offline Last Active Jan 22 2014 02:50 AM

#5123344 What types of math are used a lot when developing games?

Posted by on 13 January 2014 - 01:23 PM

For working with 3D graphics Matrices are what you'll most likely be working with as they make complex problems relatively simple and are very powerful. Understanding trigonometry both in 3D and 2D space is quite helpful as well.

Depending on what you are doing in your game you can scale through lots of levels of math, but just remember you don't have to be a genius in math to program them. Formulas already exist and I think it's more important to know how to look at a concept or loose formula and implement it. Knowing the math makes it easier, but without doesn't make it impossible.

#5123140 Component based game and component communication

Posted by on 12 January 2014 - 03:53 PM

I think if you want to send data between components, you should have them an anchor to a common root which actually handles sending the information between components.

For example, in my game, I have components bound to individual entities which gives them functionality. I also have some specialized components such as an InputComponent and a RenderComponent. Each component haves a pointer back to it's root entity and my entity has a function called BroadCastMessage( MessageClass data ) which calls the function RecieveMessage( MessageClass data ) for all bound components. All my component has to do is use it's pointer to its root entities to broadcast a message to other components.

My MessageClass is basically this:

struct MessageClass
   char* pchName;
   void* pvData;

You would use the name to listen for certain events from other components like maybe "UpdateXPos" or something to that effect. Also since I know how a message would be built based on the name, I'll know how to typecast the data to its correct format. Another way you might do it, but it leads to a bit more work, is to use an array of bytes for the data. You would have to break down the data you need to send into individual bytes and then rebuild it up when a component receives it.


Here's a complete example:

void KeyPressed( char chKey )
   if( chKey == 'w' )
      int iMovement = 10;
      pEntity->BroadcastMessage( MessageClass( "UpdateXPos", &iMovement );

void RecieveMessage( MessageClass data )
   if( strcmp( data.pchName, "UpdateXPos" ) == 0 )
      m_iPosX += *((int*)data.pvData);

#5094573 Getting Started with Graphics. Help?

Posted by on 16 September 2013 - 08:30 PM

If you want to tackle the basics of a game engine either for learning or you want to make your own game entirely from scratch, I'd say go for OpenGL. Unlike DirectX it's cross platform. It's not as well documented and you can find lots of conflicting tutorials such as ones that use old deprecated methods.

If you want to go further, look into GLFW3, GLEW, OpenGL, and SOIL. Remember that these are just for graphics and user input. You'll also need things like OpenAL for sound and maybe other libraries.

#5094508 Resources to research rpg level growth + combat damage

Posted by on 16 September 2013 - 01:06 PM

I'd imagine the math that they use in combat calculation and the growth of characters in a level style game wouldn't go any further than the bare minimum required in Highschool Math.

Traditionally it has been that the basic stats would corellate with basic effects on the character. Strength is to damage, vitality is to health, dexterity is to attack speed, luck is to chance of "critical" hits, etc..

But there have been other types of systems that while they do stick somewhat to the roots, they have weapons scale to the stats of the character. For example in a game like Dark Souls I believe the katana type weapons were based heavily on the Dexterity attribute. Raising your Strength did little to improve the damage you did with a Katana.

Simply looking at the graphs of linear and exponential functions should reveal effect they have. A game doesn't require complex math for the calculation of damage inflicted, or the players health, or the speed at which a player attacks.

// Players damage is influenced by his strength and his skill with a sword
Player.Damage = Player.Strength + ( Player.SwordSkill / 2 );

// Players health is 1.25x his vitality attribute
Player.Health = Player.Vitality * 1.25;

// Players attack speed relies on dexterity, but having a higher strength makes him move slower.
Player.AttackSpeed = Player.Dexterity - ( Player.Stength * 0.05 );

These are all simple calculations but will get the job done.

#5094477 Freshie!

Posted by on 16 September 2013 - 10:33 AM

So what are you asking for friend? Are you looking for some tutorials? Could you provide some specifics as to what kind of games and/or the mechanics you'd like to implement so someone can shoot you on the right way?

Also this:


I have done several stuff in this like simple adder, subtracter, multiplier, power function, if-then-else-statements, cost-function, profit-function and such. Have got a good hand over it.

Is more basic math than it is programming. You're going to need a lot more under your belt biggrin.png

If you're doing C++ and are interested in OpenGL, here are some things i've picked up...


These tutorials use varying libraries, so these are the ones I've opted for all my development: SOIL( Graphics loading library ), GLFW3( Window and input handling ), and GLEW( Extension loading library ).

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

Posted by on 14 September 2013 - 04:47 AM

There's lots of different ways you can start off. Either starting down in the low levels of a language like C or C++ or jumping right into game development with Unity or the UDK.

If possible, I'd like to give a bit more guidance to one of your paths. C++ and C are good hardy languages and the skills you learn will make you a very robust programmer that extends past just game programming, but yes it can be quite difficult at times and this especially true with the complication of game development.


Perhaps I can give some more stuff for you to research so you can ultimately find something that suits you best; going with C++ and C I recommend looking up GLFW3, GLEW, and OpenGL. These will give you the bare bones of doing rendering which I think is good. These alone don't provide sound, image loading, resource handling, advanced rendering, new techniques, etc.. by default. You have to dive in and figure it out for yourself which I think can be a very rewarding experience. You'll begin focusing on correct architecture and class design which are very useful skills later on for other things.

The only downside is you won't be popping out games after a few days. I think, since you're just starting out, you'll be lucky to be able to render an image to a screen in the first week let alone create a system that can manage everything going on. It's hell, it sucks, it's riddled with bugs and errors, your using a couple megs of ram for a 10kb image. It's horrible. It's, well, it's pretty freaking awesome.

#5093798 Pong game - Computer AI and criticism

Posted by on 13 September 2013 - 10:34 AM

If you think of it like air hockey there are usually 2 ways that people will mess up. One is being too slow to move to the balls position which you seem to have already implemented, and the other is being unable to track the ball because it's moving too fast. You can implement the latter rather easily.

When tracking the movement of the ball, don't do it always. Only do it 30 times every second( 30fps which is the average speed the human eye can capture images ). So every 1/30th of a second figure out where the ball is in and give instructions to the paddle to move to that point on the y axis. Difficulty could be changed by changing both the speed of the paddle, and the speed that the ai "eye" can track the ball.

I think this will add a very human element to your AI and make it a bit more believeable. For some of the more difficult AI, Omid's idea is really good. I'd imagine really good air hockey players would be able to figure out where a puck is going to end up and move accordingly rather than just following the puck around.

#5093796 What programming language to use?

Posted by on 13 September 2013 - 10:23 AM

Depends on efficiency in your OpenGL project, you can use Java, C++ or C# with it. Minecraft is an example of an OpenGL game written in Java. Java does compile to native code (via the JIT compiler) and does provide facilities for calling native code libraries such as OpenGL (via JNI)


Bare in mind, OpenGL is not a programming language  OpenGL is a framework, a precompiled library in external DLLs.


There is no such thing as a special language. Use the comfortable tool for the job.

Also on this you should note howmuch ram and cpu Minecraft eats up because of Java. The fault is in part the programmers because I really doubt they were geniuses when they began working on Minecraft( Notch alone ) and I still doubt they are that they are any more better. But Java does not help any bit. If redone in C++ or C the game could sped up by amazing amounts even if done by a person skilled in C as Notch was skilled in Java.

#5092932 IDE for C++ Programming

Posted by on 10 September 2013 - 02:35 AM

Well CB doesn't offer the features that visual studio does, but it's a bit more flexible. You can use any compiler you want, the VC++ compiler if you want, while visual studio is stuck to it's only one.

If your all windows then VC++ should do you fine, but if you like portability and moving around, CB and other IDE's might be better since they're not coupled with Windows. I also don't like how VC++ has to have its own libraries ( "Visual C++ Redistributable Package" )

#5092923 IDE for C++ Programming

Posted by on 10 September 2013 - 02:17 AM

I use Code::Blocks. Hasn't done me any wrong so far.

#5092697 Best free Unity3D modelling software?

Posted by on 09 September 2013 - 06:38 AM

You could try Anim8or

#5092306 Help on basic Pong Ball AI

Posted by on 07 September 2013 - 10:36 AM

You don't need to split up the paddle into multiple sections. When the ball collides with the paddle get the distance from the y position of the ball( if the position correlates to the center of the ball ) to the y position of the paddle( if the position correlates with the center of the paddle ).

YDistance = Ball.y - Paddle.Y;

From that you'll get a value ranging from half of the paddle width to negative half of the paddle width. You can go ahead and turn it into a range from [-1,1] by dividing.

YVelocity = YDistance / ( PaddleLength / 2 );

This way the y velocity will depend on where you hit the ball with the paddle( hitting it on the top will make it have a velocity of -1, hitting it with the bottom will make it have a velocity of 1, and every position and velocity in between is attainable ) OR Vice Versa on velocities depending on where you treat the origins of x and y.

Another way to make the game more interesting is to check if the paddle is moving up or down when the ball collides and add a multiplier( negative or positive depending on where the hit happens ) which makes the ball move faster.

YVelocity = YVelocity + ( YVelocity * PaddleMultiplier );
// Paddle multiplier should be positive if moving downwards, negative when moving upwards, and 0 when not moving at all.

Take a look at this example. If the ball hits the bottom of the paddle, it's velocity will equal -1 and with a multiplier of 0.5( paddle moving down ) will make it's new velocity of the ball equal -1.5. The ball is faster because you hit it while moving downwards. However, if the multiplier is -0.5( paddle is moving up ), the ball moves slower as a penalty for hitting it on the wrong side.

Should add some fun to the game and make things interesting.

#5092188 Merge tools

Posted by on 06 September 2013 - 06:32 PM

I find git with TortoiseGit( I'd assume TortoiseHG operates the same ) to be one of the easiest to use. I don't even utilize the interface and simply right click directories for all my merging needs. Really haven't had much trouble with conflicts either.

#5091742 How do I implement gravity after walking off a tile?

Posted by on 05 September 2013 - 02:28 AM

So the way to implement realestic jumping and falling is to have a force acting on your object, gravity. This is simply a negative acceleration( distance^2/time ). When you jump you apply a positive velocity( distance/time ) which gives that you slow down as you reach the top of your jump and you speed up as you start falling down. You can look up kinematic equations for doing these.

As for the falling down when stepping over a tile, or while falling and you hit the ground. You can check 1 pixel below each of the bottom corners and see if there's nothing below you. If so you enable gravity to pull you down. If there is, then you disable gravity. and plant yourself.

However, on what I said above. If you are moving say 3 pixels per second, but only check 1 pixel below, you'll clip into the ground. You can fix this by seing if your stuck in the tile and pop yourself up until you're free, or you do smart checking and check the distance of the rate you travel and then see the exact coordinates you should stop and wait to reach those coordinates and then stick yourself to them.


I made some pseudo code which may help explain:

//Called every tick
YAcceleration = -5;

if( GravityIsEnabled() )
    // v = v0 + at ( equation )
    YVelocity = YVelocity + ( YAcceleration * TimeSinceLastTick );

//Called when player presses jump key.
if( KeyPressed( KEY_SPACE ) )
    YVelocity = 10;

//Checking tiles down below us for possible collision
if( check_future_collision_rect( player.pos, tile.under, YVelocity ) )
    //Check if player has reached the future points of contact 
    if( player.pos >= get_future_collision_rect() )
        //We've hit the ground
        YVelocity = 0;

//Check tile directly underneath us.
if( NoTileUnderneathUs )

#5091265 Matching the rotation of one object with another

Posted by on 03 September 2013 - 05:43 AM

I think the problem is your rotating both around their respective center and thus not making them rotate together. Rotate both around a common point, probably the center of the bottom part in this case.

//Do this for both pieces
glTranslatef( Bottom.x, Bottom.y, Bottom.z );
glRotatef( Rotation, 0.0f, 1.0f, 0.0f );

This is if you're using OpenGL( deprecated method shown ), but the same idea would apply.