cold_heats_.--.

Member
  • Content count

    30
  • Joined

  • Last visited

Community Reputation

127 Neutral

About cold_heats_.--.

  • Rank
    Member
  1. Predict collision between spheres

    Thank you for taking the time to reply . @Bacterius there is no physics involved so no siedways momentum .
  2. Predict collision between spheres

    A list of n spheres, each described by the (x,y,z) coordinates of its highest point and ® its radius, is given. The first sphere starts falling down vertically.If it touches another sphere during the fall , this one also starts to fall down and so on.The trajectory is not modified. The Oz axis is oriented vertically up.Find the number of spheres that will hit the ground. I know that if it were circles in 2D , the solution would be simple. I was thinking of projecting each sphere onto the plane determined by the normal of the direction and for each sphere test if its projection collides with the others .However my 3D math is not very good ... How do I do this ?
  3. Point-Plane distance

    @alvaro , the author does specify they are actually lines when we refer to 2D. My question is why does he say he computes the dot product between the vector-from-the-plane-to-point and plane-normal , if the line " distance = P[i].x*Planes[j].a + P[i].y*Planes[j].b + Planes[j].c; " calculates the dot product between the vector-from-the-origin-to-point and the plane-normal ?
  4. Point-Plane distance

    Hello. I am following WildBunny's tutorial regarding a simple physics engine : [url="http://www.wildbunny.co.uk/blog/2011/04/06/physics-engines-for-dummies/"]http://www.wildbunny...es-for-dummies/[/url] However, I have some trouble understanding this part : " [CODE]for all particles i { for all planes j { distance = P[i].x*Planes[j].a + P[i].y*Planes[j].b + Planes[j].c; if (distance < 0) { // collision responce } } }[/CODE] What this code is doing is finding, by projection, how much of the [color=#ff0000]vector from the plane to the particle[/color] is in the direction of the plane normal." If every particle is determined by its (x,y) point, isn't this a vector from the origin to that point ? This line : "distance = P[i].x*Planes[j].a + P[i].y*Planes[j].b + Planes[j].c" doesnt actually compute the dot product of the origin-point vector and plane normal rather than the plane-point(vector) and normal dot-product? I drew some sketches so you can see my point.I am testing a particle against the plane who's normal isnt normalized . [Sorry, I actually mean dot-product , not cross ] . [img]http://i.imgur.com/vsWSK.png[/img] [img]http://i.imgur.com/SonAB.png[/img] I know there's a flaw in my reasoning, but I dont seem to get it .
  5. Some good game design tips?

    Thank you Serapth, I'll be sure to check your tutorial [img]http://public.gamedev.net//public/style_emoticons/default/happy.png[/img] .
  6. Some good game design tips?

    Hello. Untill now , all my designs are a mess.I guess I violate any OOParadigm rule that ever existed.The nightmare starts when I try to add new characteristics. This is my biggest concern.Right now, I'm not interested in making my code re-usable for other game , rather I'd like to design the code such that adding new features wont be a pain . I've read articles about design patterns and such , but I fail to understand them [ althought it seems I allready made use of the facade pattern.] So , are there any good game design "patterns" out there? Could someone help me with some tips? Maybe articles about design patterns using examples from games would really help.
  7. [OOP] Two classes that can acces each other's members

    I'm bumping because I wanted to show you my design for the game. http://imgur.com/aez1h The dots represent pointers .Order of declaring classes is bottom up . Tell me , how bad is it ..
  8. [OOP] Two classes that can acces each other's members

    Thanks, I'll look at it .
  9. [OOP] Two classes that can acces each other's members

    Well, this is my second try to OOP design a game .I never would have thought this field is so complicated. It seems I missed a lot.It would have never occured to me to try an idea like hstubb's one. I guess I'll try for the moment Mussi's first suggestion. Thanks for the time to reply .
  10. [OOP] Two classes that can acces each other's members

    @Mussi Well the A and B are the player and the enemy. The enemy's AI is implemented as a state machine. By default , he leaves the player alone. The player can however trigger the "Attack" stance of the enemy, but for that he needs to read some info from the enemy object(the enemy position for example). In order to run the "Attack" stance, my enemy also has to read the player object's informations (like player position and speed for example); Also, he must modify the player's speed at begining of the "Attack" stance and set it back after the "Attack" finishes. I've adopted this method because it seems more logical to me. Only the enemy knows when he stops the attack and its reasonable that he reinitializes the player's speed too.There's no point in querying the player object " Are you in a "chased" stance ? " at each iteration, at least I dont think so. @Madhed C.How do I do that ? From what I know , if A is a friend of class B, then there must be an object of type B in A's declaration so that A can acces the private B's stuff. I used to classes just for this example.In reality , the player must acces the members of a second class too, C containing the obstacles .
  11. Hello. Suppose I have two classes : class A and class B . In my program , A needs to acces some of B's members but B also has to acces some of A's members. If it's possible, how do I implement this in C++ ? A and B are separate entities.I do not want to include one of them as a member of the other one .
  12. ==I figured it out === Please delete.
  13. Direction vector

    Gosh, I feel so stupid. Thanks for enlightening me xD !
  14. Direction vector

    Me again, with another question. Suppose I have two sprites on screen, sprite A at position (3,5) sprite B at (8,10).I want sprite B to move towards A with the speed of 1 pixel per second. So I calculate the direction vector from B to A : dir=B-A=(5,5) . Its length "L" will be sqrt(5*5+5*5)=sqrt(50). I normalize it dir=(5/L, 5/L).The components will now be : dir =(0.7,0.7) .I multiply each by the speed, but in this case they will stay the same. I update the new position B(8.7,10.7) but the components will have to be type casted to int when I call SDL_BlitSurface().So going by my logic, sprite B will always stay at the same position. What am I doing wrong ?
  15. Detect pixel color at a point

    Hi there. Suppose I have an array of block-like sprites.In the center of each sprite, the pixel is set to a color , say magenta.When my character moves, he does it with a fixed velocity and the sprites are displayed in such a way that when the caracter collides with them , he practically covers the whole sprite, not just a part of it .They all have the same dimensions. In my snake-like game, I have to check 2 arrays of coordinates and the "food" coordinates, regarding their collision with the head.Wouldnt it be easier to set in the center of each sprite a certain color and in the collision function to check wether the pixel color in center of the head's rectangle has those certain RGB values ? If it's possible, how could I do that in SDL ? My guess is that the blocks would first have to be blitted on the background and then the background to the display.