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 15 May 2010
Offline Last Active May 30 2015 05:04 PM

#5226151 Random Number Generation

Posted by boogyman19946 on 28 April 2015 - 03:06 PM

>Whatever you're trying to encrypt isn't nearly as important as you may think.


But it is, TO ME.


I'm sure the USA government thinks just as much of their own data, but not even they opt for such drastic measures. AES-128 and above are hard enough that even a super computer couldn't crack them within the lifespan of a human being. Unless you're storing the blueprints for Skynet-level AI, your methods are serious overkill.

#5225935 Spot the bug quiz.

Posted by boogyman19946 on 27 April 2015 - 03:36 PM

A friend of mine posted this little quiz on Google+ not too long ago, and I thought you guys might get a kick out of it if you haven't seen it before. I haven't seen C++ code in ages (I'm a Java-based code monkey myself), but I was still able to get some of the questions right. Fair warning: some of the code present is a major eye sore. Not quite THAT bad though.



#5225676 Why Does Everyone Tell Newbies To Make Games?

Posted by boogyman19946 on 26 April 2015 - 11:56 AM


It's because it is so much better to concentrate on small, really small, practical projects that you can actually stand a chance to complete than diving head first into making a game engine or a MMO.

If Pong seems like too much, then it would probably make sense to set the bar lower and pick a simpler project. smile.png

You learn more from finishing your projects, no matter how small/trivial they are.


Make games, not engines.

I try to tell Newbies to do that.

The simpler the game, the better.

No, I'm just saying that it's hard if you have no knowledge of a framework, and if there are no good tutorials tongue.png



Well, telling people to make games bares no influence on their choice of framework. Of course, the person giving this advice also has the option of suggesting frameworks with good and reliable resources. Besides, what else are you going to do? If you have no experience in doing something, what would you suggest a newbie should do to gain that experience? If you ask me, making a simple games gives fantastic insight and serves as a great stepping stone in the right direction.

#5132861 Better way to write this code

Posted by boogyman19946 on 19 February 2014 - 10:22 PM

The second return statement is necessary because the compiler can't just assume the first return statement will execute. There is no guarantee that a node in the list matches the argument key.


Therefore, the return statement in question should return a value that one would expect if there was no entry matching the given key. If you can't return null, you could write it like this:

public Coordinates GetNodeCoordinates(int number)
            foreach(Node node in nodes)
                if (node.Number == number)
                    return node.Coordinates;
            return new Coordinates(); 

But you won't be able to tell if you actually found a valid set of Coordinates unless you save that state somewhere. The above code is pretty much the same as yourself, with the exception that it only creates a new Coordinates at the last minute and only when needed. Not a great improvement, but some start.


I don't know C# very well. I thought it would have a reference system more similar to Java, but in Java you can return a null value for just about anything that's not a primitive.

#5131458 Trouble with strings and chars with arrays and loops

Posted by boogyman19946 on 14 February 2014 - 08:41 PM

I myself would prefer to use a simple table method although it really depends I guess. A HashMap will do the job and will probably be more straightforward (I guess it depends on what you're more used to), but if you are bound to using arrays, the following solution is probably what I'd use:

final char alphabet[] = "abcdefghijklmnopqrstuvwxyz".toCharArray(); // A little ugly over here, but, that's meh.

String str = "Some string text goes here";
char charArr[] = str.toLowerCase().toCharArray();

int charCounters[] = new int[alphabet.length];
for(char character: charArr) {
   for(int i = 0; i < alphabet.length; i++) {
      if(character == alphabet[i]) {

#5131455 Trouble with strings and chars with arrays and loops

Posted by boogyman19946 on 14 February 2014 - 08:24 PM

charAt( int ) returns the primitive char, so you can't call functions on it. The mistake is obvious: you need to use == instead of =. Single equal sign assigns to variables (which is why your compiler is complaining about needing a variable), and double equal signs compare equality (which is what the if-statement is expecting).

#5128270 GDI+ How to redraw screen?

Posted by boogyman19946 on 02 February 2014 - 05:13 PM

Thanks, but I don't know where in I have hand on "backbufferDC" to Graphics* m_pGraphics;

You create it yourself. You don't want the user to see you draw every piece of the UI manually, that's what creates the flicker. To solve this, you create a buffer off to the side, do all your drawing there, and when it's done, you show the results on screen.

#5126756 Figuring out normal force.

Posted by boogyman19946 on 27 January 2014 - 11:52 AM

On inclined surfaces the normal force will be equal with the sine or cosine of the inclined surface angle * gravity . Am I right?



I always remember it as the negative projection of the gravity force onto the normal vector of the surface where the object is rested.

#5126623 Figuring out normal force.

Posted by boogyman19946 on 26 January 2014 - 07:57 PM

It looks like you are making a step into the Continuous Collision Detection concept.

The idea is simple. You should first detect the collision between the two bodies, platform and player. When this type of collision is made, you mark it them as colliding, thus activating your continuous contact routines, which should apply the normal force. While they are marked as colliding, you should apply the normal, and keep in watch for a break of this contact, that could be caused by several things:

The player jumps

The player goes beyond the platform border

A new force is applied (a bomb, a bullet, a backflip kick from a rhino...)

Any force change (weakening gravity, variable magnetic force)


This is a simplified version of the theory, also notice that it is my own interpretation, but it is quite a complex algorithm and I am searching the Box2D code to understand its implementation myself; so I can't help you further, but if you like to read code, here is a link that can.

You could use a simpler but specialized version. It would probably perform even better.


This seems to be pretty much what I was looking for. I wasn't sure what to look up but I'll have a look at this when I have time and get back to you on that.


From your description, it sounds like the platform is not a collision object. If you make the platform a collision object, a collision will result (when appropriate) between the player and the platform, and provide the point of contact and the contact normal. (Many collision engines provide for a planar collision object with a normal, an extent, friction factors, etc.)


Am I understanding your question?


The platform is a collision object. The entire world in my game is actually made out of discrete objects. My question should have been "how do I know if I'm standing on a platform if I haven't detected collisions yet on this cycle." My physics simulator does things in the following order: sum forces, get acceleration, integrate acceleration and velocity, and with the resulting disposition, check collisions and respond. The problem with this is that I won't know if I'm standing on a platform until I check collisions, but I need to know that when I'm summing forces because of the normal force.



The normal force minus gravity equals 0 if you are standing on a platform.

N - G = 0 
N = G


The question isn't that simple I'm afraid. And I don't want to be a party pooper, but on an inclined surface, N != G.

#5126377 Figuring out normal force.

Posted by boogyman19946 on 25 January 2014 - 03:57 PM

Hello everyone!


I have a question that pertains to figuring out normal force. I seem to have a predicament that involves collision detection.


At the start I first sum all the forces acting on the object at hand. All external forces come from input or collisions that were maybe applied last cycle. Then all the internal forces: friction, gravity, and normal force. Gravity I can figure out, but figure friction requires me to know the normal but for that I have to know if I'm standing on a platform or not. My question is, is there some elegant way to solve this? For example, is it plausible to just omit the normal force on the first cycle, check collisions and apply the normal force on the next? Or should I make a deliberate check if player is standing on a platform?

#5126250 "Oh God, Who Wrote This?", "You Did", "Wait? I wrote Thi...

Posted by boogyman19946 on 24 January 2014 - 09:56 PM


Of course, everyone says I'm over reacting, but I've seen the effects of not caring, and I know how big of a benefit clarity and consistency carry.

There is definitely a balance to be struck there. Ideally you are able to write both sorts of code: the throwaway prototype you needed yesterday, and the carefully structured (and tested) code that is headed for production.



I agree that perhaps it's unnecessary to structure code with utmost care when prototyping, but even if prototyping I feel like there's still things one could do to write cleaner, albeit throwaway, code.


The poster in this thread is a prime example: http://www.gamedev.net/topic/652538-pathfinding-behaviour/


I wouldn't put code like this in production, but I would certainly not write it as throwaway either. I managed to fix an error in his adding function merely by giving the variables proper names, which, if he had done in the first place, he would have noticed the glaring logical error. 

#5125976 pathfinding behaviour

Posted by boogyman19946 on 23 January 2014 - 03:28 PM

The function that adds to heap does not seem correct to me. I tried to figure out what the proper name of the variables should have been, and it seems rather odd.

void addToOpenList(int x, int y)
	Openlist[openListNumber] = new Point(x, y);
	int child = openListNumber;
	int parent = child;
	int F = squareMap[x, y].F;
	Point temp;
	while (child > 1)
		parent = child / 2;
		if (squareMap[Openlist[child].X, Openlist[child].Y].F > F)
			temp = Openlist[parent];
			Openlist[parent] = Openlist[child];
			Openlist[child] = temp;
		child = parent;

Now this algorithm is much easier to understand. The if statement seems to be a likely culprit. You are comparing the cost of a child node to the cost of the inserted node. Notice however, that in the body of the if statement, you swap the parent (which hasn't been compared to anything yet) with the child node. I think you meant to say the following:

void addToOpenList(int x, int y)
	Openlist[openListNumber] = new Point(x, y);
	int child = openListNumber;
	int parent = child;
	Point temp;
	while (child > 1)
		parent = child / 2;
		int childCost = squareMap[Openlist[child].X, Openlist[child].Y].F;
		int parentCost = squareMap[OpenList[parent].X, OpenList[parent].Y].F;
		if (childCost < parentCost)
			temp = Openlist[parent];
			Openlist[parent] = Openlist[child];
			Openlist[child] = temp;
		child = parent;

Now at least the code clearly shows that it's moving the smallest node to the head of the tree. I think there's also a way to terminate the while loop early once the if statement evaluates false (since you're adding only one node and are moving up one branch of a binary tree).

#5125766 How do I fix my game in pygame

Posted by boogyman19946 on 22 January 2014 - 07:25 PM

Forum FAQ



Asking Questions:

  • Do not ask homework related questions, they will be closed on sight.

#5125665 pathfinding behaviour

Posted by boogyman19946 on 22 January 2014 - 10:28 AM

I think that might depend on which algorithm you're using. Some of the more naive ones can paint the whole darn thing yellow so that there wouldn't be any white left.


From the second picture it looks to me like you're using A* because the algorithm will start with checking paths that produce the shortest traveled distance + heuristic distance. It doesn't take into consideration the fact that there might be an obstacle on it's path. You can picture this in your own house for example. If you have two people standing on opposite sides of a wall, the straight line distance (commonly used as heuristic in A*) would direct A* at the wall first, but the actual shortest path might mean that you have to backtrack to get to the door. If there were no obstacles in your path, and all tiles had equal cost, you could probably just expect a single straight path to your goal.


The first one looks like it might have goofed up, unless some of the tiles incur significantly different costs.


But, all said and done, I've only ever really had to deal with pathfinding once, so my knowledge of it is rather limited.

#5125252 Pass entire vector of objects to constructor by reference?

Posted by boogyman19946 on 21 January 2014 - 12:05 AM

The vectors have incompatible types. Spell constructor is expecting std::vector<Hero>& and what you're giving it is... actually you're trying to perform an invalid operation on heroes so I'm not really sure what to say in this case.


There's a two main ways to go here. A) you change the std::vector<Hero>& inside of Spell to std::vector<Hero*>& and then change the push_back call to what Pachanoi said, or B) you change the type of std::vector<Hero*> to std::vector<Hero> and still change the push_back call to what Pachanoi said biggrin.png That will probably solve the problem. 


You might want to review the syntax for using pointers and references though to fully understand how to pass them to functions.