My Tutorial for Using Trig In Game Development

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
TheAustech
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 96
Joined: Fri Sep 03, 2010 4:38 pm
Current Project: BeatTapper
Favorite Gaming Platforms: PC
Programming Language of Choice: C++, C#
Location: Maryland
Contact:

My Tutorial for Using Trig In Game Development

Post by TheAustech »

Hey, I remember before when I first tried making a top down game I had no damn clue on how to get the bullets to move towards my mouse. I was so desperate that I literally made about 50 if statements that checked for the mouse position (yeah, I had a lot of time on my hands). Then I learned about this magical unit circle and trig functions :worship:

I learned these functions in my math class, but luckly I'm an awesome dude and I made a tutorial which I personally think explained it well. But then again I know the topic so...

Anyway, the video is here: http://www.youtube.com/watch?v=FmWDD9AXUEQ



This tutorial uses images and displays I drew out for hopefully easy learning. Also I'm not giving you the code on how to make a bullet move in that direction. I'm teaching you how to use a very important function to get the way it should move. I don't know what library you use or what everyone's code looks like so I can't just say "Type bullet.move(atan2(blah))" because that wouldn't work for everyone, not even mine :lol:
User avatar
TheAustech
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 96
Joined: Fri Sep 03, 2010 4:38 pm
Current Project: BeatTapper
Favorite Gaming Platforms: PC
Programming Language of Choice: C++, C#
Location: Maryland
Contact:

Re: My Tutorial for Using Trig In Game Development

Post by TheAustech »

Oh wow, so sorry. I completely overlooked the Game Development section. This would of been better in that section.
User avatar
ibly31
Chaos Rift Junior
Chaos Rift Junior
Posts: 312
Joined: Thu Feb 19, 2009 8:47 pm
Current Project: Like... seven different ones
Favorite Gaming Platforms: Xbox 360, Gamecube
Programming Language of Choice: C++, ObjC
Location: New Jersey.

Re: My Tutorial for Using Trig In Game Development

Post by ibly31 »

Nice! I've pretty much figured out most of that before so I didn't learn anything from it, but it was very clear and I really wish I had found this (or it had been created) back when I couldn't figure it out.

It's nice to know that the technique that I use is the one that most people use! Also, I never really knew about the unit circle (going into Functions this year), so it was cool to see how all that worked out and was related to this.
Image
Twitter
Website/Tumblr
My Projects

The best thing about UDP jokes is that I don’t care if you get them or not.
User avatar
TheAustech
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 96
Joined: Fri Sep 03, 2010 4:38 pm
Current Project: BeatTapper
Favorite Gaming Platforms: PC
Programming Language of Choice: C++, C#
Location: Maryland
Contact:

Re: My Tutorial for Using Trig In Game Development

Post by TheAustech »

ibly31 wrote:Nice! I've pretty much figured out most of that before so I didn't learn anything from it, but it was very clear and I really wish I had found this (or it had been created) back when I couldn't figure it out.

It's nice to know that the technique that I use is the one that most people use! Also, I never really knew about the unit circle (going into Functions this year), so it was cool to see how all that worked out and was related to this.
Thanks, I'm glad you liked it : )
User avatar
epicasian
Chaos Rift Junior
Chaos Rift Junior
Posts: 232
Joined: Mon Feb 22, 2010 10:32 pm
Current Project: Gigazilla Engine
Favorite Gaming Platforms: Dreamcast, SNES, PS2, PC
Programming Language of Choice: C/++
Location: WoFo, KY

Re: My Tutorial for Using Trig In Game Development

Post by epicasian »

This will definitely be useful when I attempt to make a top down shooter. Thanks for the share! :D
Post Reply