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
Online Last Active Today, 04:49 AM

#4960926 Inventory System

Posted by Mussi on 19 July 2012 - 07:36 AM

How about something like this(just a rough and simple outline):

[source lang="cpp"]enum ItemSlot{ HEAD, CHEST, WEAPON, MAX_SLOTS};class Item{ ItemSlot slot; String name; // other base class stuff doStuff(); // maybe?};class ItemWeapon{ doStuff(){ /* special stuff */ }};class Player{ Item inventory[]; Item equipment[MAX_SLOTS]; equip(int i) { Item item = inventory[i]; // check if something else is equiped and revert stats if so equipment[item.slot] = item; // equip item // apply stats }};[/source]

Forgot about consumables when writing that, left some blanks as well, but I think this can get you going.

#4960477 Calculating curvature of CatMullrom interpolated spline

Posted by Mussi on 18 July 2012 - 07:56 AM

Your derivatives seem to be incorrect:

q(t) = 0.5 * ( (2 * P1) +
(-P0 + P2) * t +
(2*P0 - 5*P1 + 4*P2 - P3) * t^2 +
(-P0 + 3*P1 - 3*P2 + P3) * t^3)

q'(t) = 0.5 * ( (-P0 + P2) +
2 * (2 * P0 - 5*P1 + 4*P2 - P3) * t +
3 * (-P0 + 3*P1 - 3*P2 + P3) * t^2)

Second derivative should be easy to derive from this.

#4959393 Zombie game wave difficulty progression

Posted by Mussi on 15 July 2012 - 06:18 PM

It mostly comes down to play testing, once you have an idea of what difficulty requires what spawn count you can try to do some curve fitting. I guess the hardest part is finding the appropriate group of people, for the play tests, that represent your target audience.

#4959373 Classes, Engine and Ownership.

Posted by Mussi on 15 July 2012 - 04:27 PM

It depends on the complexity of your project, the time frame you have to finish it and your personal preference to name a few things. With that being said, I don't think you should ever place game logic into something like a grid class. Drawing or input handling could be in or outside the class depending on the project, but I think separating them is neater(using controllers and such).

For a simple Tic-Tac-Toe game though, I wouldn't use controllers since you know the boundaries of your game pretty well and they're fairly small. Adding controllers would add unnecessary complexity, unless you add them for educational purposes.

To come back to your original question, your Grid should have a reset method that resets the grid and your GameEngine should handle when that method gets called.

#4959307 CouchDB for player accounts

Posted by Mussi on 15 July 2012 - 11:26 AM

So do I do that on the C++ side and then send the hashed username and password? How do I unhash it on the server?

Yes and you don't. You store and compare hashes.

#4959166 Fast way to smooth a 2D polygon

Posted by Mussi on 14 July 2012 - 07:06 PM

What about a simple Catmull-Rom spline? It has the advantage of passing through all of the control points and is fairly easy to implement. You could subdivide every edge into two or more edges and use Catmull-Rom to calculate the points in between.

#4957638 OOP design question

Posted by Mussi on 10 July 2012 - 10:07 AM

I think the answer has something to do with semantics. I for one expect a function with the word calculate in it's name to return something and not hide the result somewhere in the background. Design A is also not very explicit in what it does, the function name informs us it assigns a value to c, but I don't think it's the right place for that. The function name should specify what it calculates(what is c?) and the variable you assign it to then speaks for itself.

I always try to write code that doesn't require documentation to understand what's going on, it's easier to maintain and share that way.

#4956931 Loading a tile-maps from text files.

Posted by Mussi on 08 July 2012 - 07:53 AM

I'm not aware of a C++ alternative, but there are some things that you'll have to take into consideration when using strtok(). It's not thread safe, so be careful with that when mutli-threading. It also modifies the original string, it returns a pointer to the start of the token and places a null terminated character at the start of the delimiter, so if you need the original string for some reason(I don't think you do in your case) you'll have to make a copy or restore the string.

You could also write your own strtok() like function that's thread safe and doesn't modify the original string.

#4956925 Loading a tile-maps from text files.

Posted by Mussi on 08 July 2012 - 07:28 AM

You could also use strtok, it's a C style function but it gets the job done. You can also specify a delimiter this way.

#4956837 Rendering text using OpenGL

Posted by Mussi on 08 July 2012 - 12:25 AM

Have you tested your resize function? Make sure that works first. Are you sure the wc variable is correctly set?

#4956834 Platforming Game Level Programming

Posted by Mussi on 07 July 2012 - 11:53 PM

I appreciate both responses, though they seem a bit conflicting. Many of the sprites will be the same. Similar to Terraria, there will only be a few different types of blocks, which will be repeated several times.

They seem conflicting because it's situational. I'm not sure how efficient Processing is in rendering a large amount of tiles, but it wasn't good enough in my situation. You're not using Processing, so you might not run into the same problem. I actually used a tileset from Terraria btw.

It sounds like I can always go back and find more efficient methods of displaying many sprites later on, if it comes down to them causing too much of a problem, so perhaps I can just see what happens when I place all of them, and change it if needed.

I'd suggest you do that, don't need to fix what isn't broken. However, If you do find it to be insufficient, the solution I posted is probably as efficient as it can get.

#4956800 Platforming Game Level Programming

Posted by Mussi on 07 July 2012 - 09:03 PM

I recently made a platformer using Processing(Java) and for simplicity's sake I rendered each tile individually. It turned out to be too slow so I rendered the static parts of the world into much larger sprites(512x512), which reduced the amount of draw calls from about 800 to 2. I know that you can destroy/build tiles in Terraria, so if you're going for something like that you'll have to update the larger sprites when necessary.

As for keeping track of the entire level, I'd advise you to only render what's on screen. It's fairly easy to implement.

#4917463 How would a filling clock drawing algorythm work?

Posted by Mussi on 28 February 2012 - 12:46 PM

Is this thread of any use to you?

#4899759 check if enemy is in range to fire.

Posted by Mussi on 04 January 2012 - 05:38 PM

That is not what you're looking for. You want the tower to shoot when the enemy is in range of the tower right? To calculate the distance between two positions you'll have to use Pythagora's theorem. To keep things simple, to calculate the distance from point A to point B you get this:
D = A - B;

distanceSquared = D.x*D.x + D.y*D.y;

distance = sqrt(distanceSquared);

Now if you want to check if something is in range, you don't need to calculate the actual distance, you only need to compare the squared distances. In your case you only have to check whether distanceSquared <= radius*radius.

If any of that is unclear, let me know and I'll try to explain in more detail.

#4899748 check if enemy is in range to fire.

Posted by Mussi on 04 January 2012 - 05:13 PM

Why do you think this is the correct way to check if something is in range? Try looking at your if statement and interpret what it actually is that you're checking for.

A hint for the correct way to approach this problem: check if the squared distance to the enemy is smaller or equal to the squared bullet radius.