Jump to content

  • Log In with Google      Sign In   
  • Create Account


Mussi

Member Since 12 Oct 2004
Offline Last Active Yesterday, 03:55 PM
*****

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


#4896612 Generating animations at runtime

Posted by Mussi on 22 December 2011 - 01:20 PM

You could map the creature partially to the skeleton, ignoring the leg bones or you could map it fully and it'll look...weird I guess. You could also allow the user to set how much the bones actually influence the doodle.


#4896547 Generating animations at runtime

Posted by Mussi on 22 December 2011 - 09:30 AM

In 3D games creatures of different shapes and sizes often share the same skeleton, allowing one skeletal animation to be applied to different models. This works because the models are, so to speak, mapped to the skeleton.
I think you could something similar in 2D: create a 2D skeleton with animations and map the doodle to the skeleton and then deform it accordingly during animation. Mapping the doodle could be done manually or by some algorithm.


#4893478 3rd person camera collision response

Posted by Mussi on 13 December 2011 - 06:59 AM

Yes that's correct. Another option is to temporarily change the camera angle so that the camera goes up, in most games there's hardly any obstacle that prevents the camera from going up. I went with 'first person view' when the camera gets too close because the camera angle is of significant importance when using the mouse, sudden changes would be very annoying to play with.


#4893282 3rd person camera collision response

Posted by Mussi on 12 December 2011 - 04:33 PM

Im leaning towards option B. I think thats how most game cameras deal with intersections. Either way im doing a swept rectangle test. Except for option B i use the furthest position instead of closest.

What do you guys think? Would this produce satisfactory results? Is there a more efficient way?

From what point are you intersecting? I'd start from the player and backup until an intersection occurs, that'd be the nearest intersection. I use a sphere instead of a rectangle, easier to handle for me.


#4887042 How to call NPCs?

Posted by Mussi on 23 November 2011 - 05:00 PM

Joe, Sam, Margret etc.? You can throw in a prefix or suffix if you want to make clear what they're for.


#4885323 Cant get object to move at variable speed toward point [C++]

Posted by Mussi on 18 November 2011 - 08:52 AM

float s_s = r / WellStrength;

Acceleration.X -= ( dir.X * ( ( WellStrength * s_s ) - distance ) ) * DeltaTime;
Acceleration.Y -= ( dir.Y * ( ( WellStrength * s_s ) - distance ) ) * DeltaTime;

WellStrength is never used. s_s = r / WellStrength, then you multiply s_s by WellStrength again. WellStrength * s_s = r / WellStrength * WellStrength = r.

If you want strength to be equal to 0 on the edge of the radius and linearly increase to WellStrength when getting closer to the centre, you can use the following equation: strength = (1.0f - distance / radius) * WellStrength.

Does that answer your question?


#4883885 Cut triangle with circle

Posted by Mussi on 14 November 2011 - 01:11 PM

I'm not sure, but from looking at your picture I think a good place to start would be:

  • For every edge of the triangle, intersect the n-gon for the first vertex to the second vertex and the other way around. If there's an intersection and the intersection point does not overlap with an existing vertex of the n-gon, add the intersection point to the n-gon.
  • For every edge of the n-gon that lies within the triangle, look for a triangle vertex that makes up a non-intersecting triangle.
  • For every edge of the triangle that does not intersect with the n-gon, look for a n-gon vertex that makes up a non-intersecting triangle.
Let me know if you find a flaw in there :lol:.


#4872793 Beautiful code

Posted by Mussi on 15 October 2011 - 05:22 AM

Sometimes when I write a complex piece of code that's easy to reuse and loose coupled or something along those lines I can't help but think it looks beautiful :lol:. How many of you occasionally think their code looks absolutely beautiful?


#4872123 Using f10 keys in the game :(

Posted by Mussi on 13 October 2011 - 01:55 AM

Try adding this to your window procedure:

[source lang=cpp]case WM_SYSCOMMAND: switch (wParam) { case SC_KEYMENU: case SC_SCREENSAVE: //optional, prevents the screen saver from popping up return 0; } break;[/source]


#4863378 Getting variable address with the source code given

Posted by Mussi on 19 September 2011 - 09:40 AM

1. Can I calculate stuffs / do anything to get a variable address given a source code for that program? (I make a simple program that looks like this)

int dummy = -1; int main(int argc, char** argv) {   return 0; }


can I calculate the address of the 'dummy' global variable? (without helper tools like memory scanner, but just by reading its source code? I know it sounds stupid but meh)

You can create a pointer to store the address of the variable:
int dummy = -1; int* dummyPtr; //pointer that will hold the address dummyPtr = &dummy; //assign address to pointer

More on pointers here.

That means you'll have to recompile the program though, not sure if that is what you meant. If not, I think Antheus just gave you the answer to that.


#4826370 Engine components

Posted by Mussi on 22 June 2011 - 05:11 AM

Oh ok so your saying I shouldn't attempt to just learn a subject for the hell of it... instead learn it as the need arises in my games? That does make sense, so if I find that my physics really sucks and it needs to be improved.. I should then read a book/article on the topic and refactor my game with the new knowledge?

That's basically it, it'll make the why and the how much clearer to you.

The C4 Engine diagram looks mind boggling at first, but once you've programmed some of those components you'll find it much easier to understand.


#4824522 I think my GDNet+ is Broken...

Posted by Mussi on 17 June 2011 - 11:08 AM

In the Client Area you'll find a support section, you can add a support request there.


#4823827 The GDNet Birthday thread

Posted by Mussi on 15 June 2011 - 04:26 PM

Happy birthday! Thank you for establishing this great community, which has become the Mecca of game development :D.




PARTNERS