Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 12 Oct 2004
Offline Last Active Yesterday, 08:09 PM

#5207471 Is it a very bad idea for a class to pass (*this) into a function? Strange bu...

Posted by Mussi on 29 January 2015 - 11:46 AM

The solution is to understand the Rule of Three (this rule has recently grown a bunch of different names, but I think this still is the best name).

Rule of 0/3/5

#5206545 Is it a very bad idea for a class to pass (*this) into a function? Strange bu...

Posted by Mussi on 25 January 2015 - 08:53 AM

There's nothing wrong with dereferencing the this pointer, your error has most likely something to do with your code(I'm guessing the second parameter is of type ClassA&).



Also, I know that "this" is a pointer... and since * is used to dereference a pointer, does that mean passing (*this) is pass-by-value?

That depends on the argument type in functionB, it could be by value, reference, const reference etc.

#5188057 Deciding on a Game Engine?

Posted by Mussi on 19 October 2014 - 07:14 PM

If licensing is your biggest hurdle, you'll want to check out the C4 engine by Terathon. It just had it's licensing model changed, there was a post about this on this forum here. No royalties, single payment of $88, 1 year of free updates. It doesn't get any better than that.

#5187583 Acceptable resolution for character turning?

Posted by Mussi on 16 October 2014 - 10:31 PM

I'm using 2 bytes for orientation of players in my multiplayer game, this gives you a resolution of 1/182 of a degree, which is more than plenty.

#5181615 Temporal coherence and render queue sorting

Posted by Mussi on 19 September 2014 - 02:50 PM

Wouldn't it be faster to just remove the no-longer present sub-meshes and leave the existing sub-meshes sorted?

Try to imagine what steps need to be taken to remove existing indices or to build a new array without these indices. Now compare that to creating an array from 1, 2, ... N.

#5176484 Welcome your new Visual Arts forum moderator

Posted by Mussi on 27 August 2014 - 01:07 PM

Welcome and good luck on your endeavors!

#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.