Results 1 to 3 of 3

Thread: Projectile Motion with C - XY conversion

  1. #1
    Theoretical Element Spud1's Avatar
    Join Date
    Jul 2003
    Location
    North West
    Posts
    7,508
    Thanks
    336
    Thanked
    320 times in 255 posts
    • Spud1's system
      • Motherboard:
      • Gigabyte Aorus Master
      • CPU:
      • 9900k
      • Memory:
      • 16GB GSkill Trident Z
      • Storage:
      • Lots.
      • Graphics card(s):
      • RTX3090
      • PSU:
      • 750w
      • Case:
      • BeQuiet Dark Base Pro rev.2
      • Operating System:
      • Windows 10
      • Monitor(s):
      • Asus PG35VQ
      • Internet:
      • 910/100mb Fibre

    Projectile Motion with C - XY conversion

    OK i'll do my best to explain this well

    Part of my assignment this year is to make a game with a tank shooting at an alien - and it has to include some semi realistic physics.

    this basically means that the projectile has to travel along a realistic path to hit the alien. The calculations easy enough, and it produces an X co-ordinate and a Y co-ordinate for a given time index
    Code:
    int getProjectileX(float timeIndex, float theta, float velocity)
    {
    	return ((velocity*cos(theta*_PI_/180))*timeIndex);
    }
    
    int getProjectileY(float timeIndex, float theta, float velocity)
    {
    	return (velocity*sin(theta*_PI_/180))*timeIndex-0.5*_GRAVITY_*(timeIndex*timeIndex);
    }
    nothing wrong with that, it produces accurate values as far as i can see.

    the problem comes when drawing the projectile, as it draws it upside down cos of the computer having a retarded Y-axis

    so my basic question would be how could I convert the co-ordinates so that they make the projectile display properly - ie the right way up. any ideas?

    if you need stuff clarifying just reply here, i'm not the best at explaining my problems

    ty

    spud

  2. #2
    One skin, two skin......
    Join Date
    Jul 2003
    Location
    Durham
    Posts
    1,705
    Thanks
    0
    Thanked
    1 time in 1 post
    new y = max y - old y

  3. #3
    Theoretical Element Spud1's Avatar
    Join Date
    Jul 2003
    Location
    North West
    Posts
    7,508
    Thanks
    336
    Thanked
    320 times in 255 posts
    • Spud1's system
      • Motherboard:
      • Gigabyte Aorus Master
      • CPU:
      • 9900k
      • Memory:
      • 16GB GSkill Trident Z
      • Storage:
      • Lots.
      • Graphics card(s):
      • RTX3090
      • PSU:
      • 750w
      • Case:
      • BeQuiet Dark Base Pro rev.2
      • Operating System:
      • Windows 10
      • Monitor(s):
      • Asus PG35VQ
      • Internet:
      • 910/100mb Fibre
    thx for you help it set me off on the right track

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Access VBA - Variable conversion
    By Raz316 in forum Software
    Replies: 0
    Last Post: 28-05-2004, 12:03 PM
  2. MP3 Conversion
    By Slick in forum Consumer Electronics
    Replies: 7
    Last Post: 13-11-2003, 01:17 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
  •