Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 12 Oct 2004
Offline Last Active Today, 04:48 AM

#5156774 Calculating healthbar percentage

Posted by Mussi on 29 May 2014 - 12:40 PM

Your currentHealth and maxHealth variables are integers, meaning that the result of currentHealth / maxHealth will also be an integer, which means the result of that operation will either be either 0 or 1. Integers are always rounded down, so you'll end up with 0 if currentHealth < maxHealth. You can go two ways here, cast the numbers to floating point numbers and cast back to an integer in the end, or simply multiply by 177 before you divide.

#5155749 Need help with 2D puddle

Posted by Mussi on 24 May 2014 - 05:09 PM

I'm not an artist, but maybe something like this?


#5155742 A list that does not disturb the order when pushed/popped?

Posted by Mussi on 24 May 2014 - 04:27 PM

I don't understand this new trend against new and delete. In a simple scenario like this, there's no reason not to use new and delete, it's ABC of programming with c++. If you can't handle a simple array of pointers, you have no hope with c++. It's a good exercise for the OP and understanding why he gets an error when deleting a player will save him a lot of troubles in the future.

It's the other way round, there's no reason to use new and delete here.

#5144646 Amusing glitch gallery

Posted by Mussi on 05 April 2014 - 06:25 PM

It seems that my vertex buffer stride was off-by-one. I call it "Origami World"...

I would drop all my plans and head into a new direction, that looks freaking awesome biggrin.png.

#5140275 Scoring system

Posted by Mussi on 19 March 2014 - 04:24 AM

Example: If both players started at 100 points and A wins 5 games straight, the scores would be 143 for A and 57 for B. After that, if B and A only win alternately, the scores will not equalize. A's score will fluctuate between 136 and 128, and B's score will fluctuate between 64 and 72. For B to bring A's score down to 100, B has to win 4 additional times to cancel A's lead in the beginning.

So if player B loses 10 games initially and then plays a 1000 games winning alternately the difference between player A and B is still the same as 1000 games ago? If so, those 10 games, which are a tiny fraction of the total amount of games, weigh more than the 1000 after that. Is that the behavior you're looking for? What are the scores supposed to represent?

#5139666 Assets for tech demos

Posted by Mussi on 17 March 2014 - 03:41 AM

Imrod is frequently used in tech demos:




The files can be found here: http://www.parkparkin.com/gallery/imrod_dw.html

#5138144 Are some people not cut out for programming?

Posted by Mussi on 11 March 2014 - 11:24 AM

The only people that aren't cut out for programming are the ones that don't enjoy programming. It takes years, dare I say decades, to become an expert programmer. Even then, you'll look at your code and think you could do better. In the end, the best code is code that works.

#5128405 c++11 move constructor question

Posted by Mussi on 03 February 2014 - 06:52 AM

That depends on the implementation of the move constructor and the data you're trying to access. The variable a has not been 'moved', it still resides in the same memory location occupying the same space. The variable that's been constructed in the vector can steal contents from a. If for example a holds a pointer to an array, this pointer could be copied and then set to null for a, accessing the pointer through a would then result in a nullpointer error.

#5120114 When to use polymorphism

Posted by Mussi on 30 December 2013 - 02:53 PM

Lets say you want all your mammals to run, with polymorphism you can put all your mammals in a single mammal array and call their run function. Without polymorphism you'll have to keep a list of dogs, cats etc. and call their run function.

#5118105 SDL Pong paddle issues

Posted by Mussi on 19 December 2013 - 07:29 AM

Instead of trying to keep your fps constant(which is not what's happening) you should move your paddle in proportion to the frame time.


Some problems I saw by glancing over your code:

  • You're frames per second calculation calculates the average fps for the entire duration of the game, you probably want to reset your frames counter when at least a second has passed. To correctly estimate the fps, you should divide your frames by currentTime - lastTime.
  • Your condition to call SDL_Delay is always true, SDL_GetTicks() - currenTime will practically always be 0.
  • 1000 / MAX_FRAMES will result in an integer instead of a float, resulting in 16 instead of 16.66.., this is a significant loss of accuracy.
  • Don't use the #define preprocessor to define constants, use const values instead.

Keeping fps constant is not easy if not impossible and what happens when a device can't make it past 30 fps? Your game will run at half the speed.

In order to move the paddles and the ball at constant speeds on varying frame rates you simply multiply the movement by the delta frame time(time difference between current and previous frame).


There is another thing you need to be aware of, most timers aren't nearly as accurate as you might think. Depending on your frame rate and the accuracy of the timer, you might not be able to detect a difference in time between two frames, i.e. delta time becomes 0. I'm not familiar with SDL so I don't know how accurate SDL_GetTicks() is(a quick search indicates it's about a millisecond), so you might have to use a more accurate timer.

#5114066 Suggestion for a cross-platform C++ 3D game engine/framework

Posted by Mussi on 03 December 2013 - 10:03 AM

Yes I know that Ogre is just a graphics engine. But it have "Addons" for OpenAL, ODE, CEGUI and etc.

What do you recommend then, apart from C4?

Setting up those libraries to work with Ogre3D isn't as simple as downloading and installing an add-on for some software. I recommend you go for a game engine that satisfies most of your needs in order to create the game you want to create. Why would you put together bits and pieces to create something that you already know you want, a game engine.

#5114047 Suggestion for a cross-platform C++ 3D game engine/framework

Posted by Mussi on 03 December 2013 - 09:11 AM

Ogre3D is just a graphics engine, you'll need different libraries for sound, physics, GUI, etc. I don't recommend it if you just want to get started on creating a game.

#5114022 Suggestion for a cross-platform C++ 3D game engine/framework

Posted by Mussi on 03 December 2013 - 07:46 AM

Have you taken a look at the C4 Engine? It's not free but it's a great engine with almost all the features you need(no lua or javascript based scripting), plus you get access to the source code. The community is also very active and helpful.

#5112085 std::string causing crashes!

Posted by Mussi on 26 November 2013 - 02:50 AM

In addition to what Brother Bob said, never use malloc in C++. Not only does new ensure that constructors are called, it's also more type safe and the C++ way of allocating memory.

#5108002 Looking for feedback on UI components (Video)

Posted by Mussi on 08 November 2013 - 07:24 PM

I'm not exactly sure what to multiply though, as it feels like the resulting INT may be out of bounds, and the integer value doesn't seem to have an easy way to refer to HSI or RGB?

You can extract RGB values by using bitshifts and bitmasks. You can find find tons of information on how to extract these values and put them together again out there, so that shouldn't pose a problem. However, I don't think you need to go that route. Looking at the StageXL library, you could probably use colorTransform() on a BitmapData object and pass the multipliers I described earlier.