Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Czar05

Member Since 20 Jun 2011
Offline Last Active Nov 24 2014 11:07 PM

Topics I've Started

Trajectory of a projectile

09 November 2014 - 12:04 AM

I am having trouble getting the right parabolic trajectory for my projectile. So far, I have managed to figure out the initial velocity for the projectile. The projectile can launch, but I am not sure how I can get the proper parabolic trajectory. I know the only force that should be applied to the projectile is a vertical force (gravity or acceleration), but I can't seem to get it right.

m_Gravity = sf::Vector2f(0.0f, 9.81);
m_Max_Height = 180.0f;

I have tried using the following Newtonian Formulas http://en.wikipedia.org/wiki/Projectile_motion, but I keep mentally drawing blanks on the code implementation.

 

Below is what I have now

 

Input Function:

void Cannon::Input()
{
    if(m_barrel.getRotation() <= 105.0f)

    {

      if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right))

      {

        m_barrel.rotate(1.0f);

        m_ball.rotate(1.0f);

        

      }

    }

    else if(m_barrel.getRotation() > 105.0)

    {

        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right))

        {

            m_barrel.rotate(0.0f);

            m_ball.rotate(0.0);

        }

    }



    if(m_barrel.getRotation() > 1.0)

    {

        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left))

        {

            m_barrel.rotate(-1.0f);

            m_ball.rotate(-1.0f);

        }

    }

    else if(m_barrel.getRotation() <= 1.0)

    {

        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left))

        {

            m_barrel.rotate(0.0f);

            m_ball.rotate(0.0f);

        }

    }

    

    if(sf::Keyboard::isKeyPressed(sf::Keyboard::Space))

    {

        m_ball.move(m_initialVelocity);

        m_fired = true;

    }

}

Update Function:

 
void Cannon::Update()

{
    m_Newtime = m_clock.getElapsedTime();

    m_dt = m_Newtime - m_Oldtime;

    m_Oldtime = m_Newtime;



    float theta = ConvertToRadians();



    float Speedxi = 160.0f * sin(theta);

    float Speedyi = -160.0f * cos(theta);

    m_initialVelocity = sf::Vector2f(Speedxi, Speedyi);


}

 

Can somebody push me in the right direction on the code implementation. Thanks in advance.


Will OpenGL 4.3 work on a 4.0 machine?

08 October 2014 - 04:17 PM

Can a graphics card that has OpenGL 4.0 handle OpenGL 4.3 features. The reason I am asking is because I am about to buy a book that talks about 4.3 functionality and I am not sure if its a good idea to purchase it if my hardware can't handle it. When I look at the details in OpenGL Extension Utility, some features in version 4.1, 4.2, and 4.3 are supported, and some aren't and I am not 100% sure how I am suppose to interpret this. Will the code examples from the book (OpenGL superbible) work on my machine?

 

Thanks in advance.


Clarification on SAT?

08 June 2014 - 02:36 PM

Hi, I have been reading up on the Seperating Axis Theorem, and I have some questions.

 

http://www.codezealot.org/archives/55

 

The article does a great job on explaining what the SAT is, but I want to know what axes is the author referring to exactly. Would I use the X and Y axes or make my own arbitrary axes?

 

Also the author talks about "flipping the coordinates and negating one." in orderto get the normals for the edges. What did he mean by that?

 

Thanks in advance.


How collision detection relates to Quadtrees

18 May 2014 - 09:17 PM

I have been researching quadtrees for quite some time now and I have some questions concerning quadtrees and how they relate to collision detection.

 

Does each individual sub-node check for collision detection within its own cell? Or does each sub-node check for collision with its neighboring cell?

 

What are the depth levels when concerning Quadtrees?

 

Thanks in advance.


Textfile or 2D array

25 January 2014 - 11:16 PM

Which method is the most efficient when it comes to tile maps. Or does it depend on the situation at hand.


PARTNERS