Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 22 Mar 2013
Offline Last Active Nov 19 2014 03:22 AM

Posts I've Made

In Topic: Strange memory allocation bug with new[]

27 December 2013 - 09:07 AM

Thank you for replies, especially Samith. But I have checked it and when I created other project, and then created an array of objects using new, the returned value was the same as the pointer value.

Olof Hedman - I also tried to overload the new operator, so it returns malloc(), but nothing changed. 


The problem is in the allocation itself, because if I do myAlloc(), and right after it _msize(), I get a heap corruption error.

In Topic: Using global variables - really so bad?

04 October 2013 - 01:06 AM

Okay, I get why global variables can be bad, but I still don't know how to replace them. In my example it was easy to set correct sound to be played. Now let's say I don;t want to use the global SoundSystem. I could make SoundSystem member of a Game class. But how do I set the correct sounds now, when the "Player" class inside the State, which is already inside the game class, doesn't have access to the SoundSystem. It was easy to check.. if(playerState==state_attacking) g_SoundSystem->PlaySound("swordfling.wav");


Another idea was to pass the m_SoundSystem(member of the game class), to the State->Logic, and then to the Player.Logic() but that makes no sense to me. Well, at least I have never seen a source code/example with such a solution.


Or maybe I don't need anything like SoundSystem? Maybe simple function playing sounds is enough? However I find SoundSystem much more useful, as it can track which sounds are playing so I don't get the "100000 sounds at a time" effect etc.


Any tips from more advanced coders? ;)

In Topic: Code Review - Pong clone..

02 June 2013 - 12:47 AM

Wow.. thats.. quite a lot :) I will definitely keep your advices in mind when creating next project. There were some problems, that I couldn't solve other way than doing things such as

if(score.AddPoint(ball.Logic(deltaT.asSeconds(), paddle1, paddle2))) Reset();

I admit that it is not the best way, but at this point I couldn't make up any other, working solution. You can probably see that I am not the best in creating object oriented code :) I'm still learning what to make public/private, how to change the private fields etc.. As for putting C in the class names. Well.. it helps me :) I don't think it confuses other people, and if it does just tell me :) Thanks for advices! :)

In Topic: Code Review - Pong clone..

01 June 2013 - 01:41 PM

Thanks for your feedback

As for the SFML advices: I am new to sfml, I have just moved from SDL.. well.. previous bad and ugly pong was written using SDL. But I find SFML much more friendly. Anyway, thanks for advices. In the classes, I prefer to describe the private fields first. It is the core of a class, when I look at it I can see what it really is :) But as you said, it is a matter of preference :)

In Topic: Simple, game structuring problem

31 May 2013 - 12:36 PM

I was thinking about creating the exit flag, so when user wants to exit(in the event part), the "exit" flag is set to true. Then on the beginning of the logic part, the flag is checked

if(exit) return STATE_EXIT;


.//rest of the logic part