User Tag List

Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 24

Thread: Need help and opinion on tank game problem

  1. #11
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    UltimateWalrus's Avatar
    Join Date
    Jul 2006
    Posts
    824
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Need help and opinion on tank game problem

    In mathematics, angle "0" generally points right, and then rotates counter-clockwise (i.e. it goes "up" from that point). So I guess I can see why Clickteam decided they'd do sprite rotation this way.

    However, on a computer screen, (0,0) is the upper-left corner, and (contrary to traditional mathematical coordinate systems) the Y value increases in the down direction. The original reason for this is because a computer monitor draws pixels from top to bottom.

    Personally, I think that Clickteam should have made the sprite rotation consistent with the flipped y-axis... but what's done is done, and if they changed it now, they'd break everyone's code. :P

  2. #12
    No Products Registered

    Join Date
    Oct 2009
    Posts
    480
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Need help and opinion on tank game problem

    I'm not sure I understand the math behind this, so you are using atan to get the angles of two points and are adding them together to get the angle of the slope?

    -Variant

  3. #13
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    UltimateWalrus's Avatar
    Join Date
    Jul 2006
    Posts
    824
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Need help and opinion on tank game problem

    Quote Originally Posted by variant
    I'm not sure I understand the math behind this, so you are using atan to get the angles of two points and are adding them together to get the angle of the slope?

    -Variant

    No, that's not it.

    What I'm doing is subtracting the vector "wheel1" from the vector "wheel2" to get a new vector that points from one wheel to the other. Hopefully this picture should help:



    The X-component of this vector is X("wheel2")-X("wheel1").
    The Y-component of this vector is Y("wheel2")-Y("wheel1").

    If I feed this vector into atan2, it'll give me the angle of the vector (which gives us the angle from wheel1 to wheel2).

    Sorry if that makes it more confusing. That's just the way I look at it.

    Altenatively, I think the Advanced Direction object has an "angle from point A to point B" function.

  4. #14
    No Products Registered

    Join Date
    Oct 2009
    Posts
    480
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Need help and opinion on tank game problem

    So your finding the distance between two wheels and setting the angle to the angle of the line connecting the two wheels?

    -Thanks, Variant

  5. #15
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    UltimateWalrus's Avatar
    Join Date
    Jul 2006
    Posts
    824
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Need help and opinion on tank game problem

    In Euclidean geometry, a "vector" is an entity that has a magnitude and direction. It's one of the most useful mathematical concepts that a game programmer can be familiar with.

    A vector is technically a magnitude and direction, but most of the time we write it as its x component and y component. For example, some random vector V could be (45,-2.34). It's kind of like an X,Y coordinate, but you should think of it as a magnitude and direction.

    There are basic rules of vector math that are useful for game programming. For example:
    (a,b) - (c,d) = (a-c, b-d)
    That's the rule I used to find a vector that points from wheel1 to wheel2. I'm not technically finding the distance between the two wheels. I'm finding a vector that points from one wheel to another.

    Once I find that, I can just plug the vector's components into the atan2 function and it'll churn out the angle of the vector.

  6. #16
    No Products Registered

    Join Date
    Oct 2009
    Posts
    480
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Need help and opinion on tank game problem

    Quote Originally Posted by UltimateWalrus
    In Euclidean geometry, a "vector" is an entity that has a magnitude and direction. It's one of the most useful mathematical concepts that a game programmer can be familiar with.

    A vector is technically a magnitude and direction, but most of the time we write it as its x component and y component. For example, some random vector V could be (45,-2.34). It's kind of like an X,Y coordinate, but you should think of it as a magnitude and direction.

    There are basic rules of vector math that are useful for game programming. For example:
    (a,b) - (c,d) = (a-c, b-d)
    That's the rule I used to find a vector that points from wheel1 to wheel2. I'm not technically finding the distance between the two wheels. I'm finding a vector that points from one wheel to another.

    Once I find that, I can just plug the vector's components into the atan2 function and it'll churn out the angle of the vector.
    I understand the concept and the process pretty well, but I struggle to understand what a "vector" is. The only thing I've used atan for is for my player to "look" at the mouse or some other object.

    -Thanks, Variant

  7. #17
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    UltimateWalrus's Avatar
    Join Date
    Jul 2006
    Posts
    824
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Need help and opinion on tank game problem

    Well, another way of looking at it is that I'm making the first wheel "look" at the second wheel. Except instead of setting the wheel's angle, I'd set the tank's angle.



    Here are some helpful vector explanations, if you're still curious:
    http://mathforum.org/library/drmath/sets/select/dm_vectors.html

  8. #18
    No Products Registered

    Join Date
    Oct 2009
    Posts
    480
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Need help and opinion on tank game problem

    Quote Originally Posted by UltimateWalrus
    Well, another way of looking at it is that I'm making the first wheel "look" at the second wheel. Except instead of setting the wheel's angle, I'd set the tank's angle.



    Here are some helpful vector explanations, if you're still curious:
    http://mathforum.org/library/drmath/sets/select/dm_vectors.html
    Now that makes sense. I'll remember this when I make moving vehicles. It is amazing what math can do! Thanks!

    -Variant

  9. #19
    Clicker Fusion 2.5 DeveloperHTML5 Export ModuleSWF Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jul 2006
    Location
    USA
    Posts
    2,982
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Need help and opinion on tank game problem

    Thanks UltimateWalrus, that helps a lot. When I have time I'll go back and plug that in

  10. #20
    Clicker Fusion 2.5 DeveloperHTML5 Export ModuleSWF Export ModuleInstall Creator Pro
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Fusion 2.5+ DLC (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jul 2006
    Location
    USA
    Posts
    2,982
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Need help and opinion on tank game problem

    Quote Originally Posted by UltimateWalrus
    The exact expression you should use looks something like this:


    Tank sprite --- Set Angle to:
    -1*ATan2(Y("wheel2")-Y( "wheel1" ), X("wheel2")-X( "wheel1" ))
    Okay I'm having a syntax error, and I'm not exactly sure what you are doing at the comma here. How do I make this into a valid equation in the MMF2 expression editor?

Page 2 of 3 FirstFirst 1 2 3 LastLast

Similar Threads

  1. Game Cutscenes - Your opinion
    By Renatos in forum iOS Export Module Version 2.0
    Replies: 6
    Last Post: 26th April 2012, 11:22 AM
  2. Simple Tank Battle from templetes: Problem
    By scurvy in forum The Games Factory 2 - Technical Support
    Replies: 2
    Last Post: 18th February 2008, 03:58 AM
  3. Help with a tank game
    By AusZero in forum The Games Factory 2 - Technical Support
    Replies: 6
    Last Post: 4th June 2007, 02:55 PM
  4. Tank Game With Gravity?
    By Nicholas Martin in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 24th November 2006, 11:31 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •