BleepingComputer.com: Just an algorithm

Jump to content


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.

Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Just an algorithm No specific language

#1 User is offline   Wolfy87 

  • Senior Member
  • PipPipPipPip
  • Find Topics
  • Group: Members
  • Posts: 414
  • Joined: 25-July 08
  • Gender:Male
  • Location:England

  Posted 04 May 2009 - 05:13 PM

Hi, the other day I was thinking "I want to make a 2D shooter" but how would I shoot at angles, I think I have worked it out but just wanted to run it past you guys.

Say I wanted to shoot up and right a small amount I would do y-1 every refresh and add to an array every refresh, once the array = 3 I would do x+1 thus creating a diagonal line or path of a bullet, I think this would work but just to check.

Thanks, Wolfy87.

#2 User is offline   groovicus 

  • Hail Groovicus!
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Moderator
  • Posts: 9,522
  • Joined: 05-June 04
  • Gender:Male
  • Location:Centerville, SD

Posted 04 May 2009 - 05:44 PM

That would work great if you only wanted to shoot on 45 degree paths, but most shooters use all 360 degrees. That requires using trigonometry to determine the trajectory of the bullet; there are probably some standard libraries. Have you been following any game development forums at all? The reason I ask is that it is a bit sily to try and reinvent the wheel when there are already people that have done that for you.

http://www.gamedev.net/
http://www.devmaster.net/
http://www.dpfiles.com/

Plug game development forums into your favorite search engine and see what you can find. It only makes sense.
"Take the risk of thinking for yourself, much more happiness, truth, beauty, and wisdom will come to you that way" - Christopher Hitchens

#3 User is offline   Wolfy87 

  • Senior Member
  • PipPipPipPip
  • Find Topics
  • Group: Members
  • Posts: 414
  • Joined: 25-July 08
  • Gender:Male
  • Location:England

Posted 05 May 2009 - 04:22 PM

Ok, I know you don't like people doing this but could you send me a link to a good tutorial or a VERY simple example, I have found some tutorials on the sites you linked me but I really don't understand them all I have gathered from them are that it involves sin cos etc...thaw about it but not how to implement it.

Thankyou very much for any help, Wolfy87.

#4 User is offline   groovicus 

  • Hail Groovicus!
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Moderator
  • Posts: 9,522
  • Joined: 05-June 04
  • Gender:Male
  • Location:Centerville, SD

Posted 05 May 2009 - 04:51 PM

I don't know of any good tutorials or simple examples. What you are trying to do requires trigonometry, which is what you found. It may very well take you a few weeks to figure out how to use the resources that you found. Sorry, but that is what programmers do. They define a problem (how to target), see what other people have done (which are the links I gave you), and then they figure out how to use it, which requires effort on your part. Sometimes there are no simple examples, and sometimes it takes a long time to figure out how to do things, and sometimes it means learning other skills. In this case, you may need to spend some tie talking to a math teacher about trigonometry, or spend time with a math book.
"Take the risk of thinking for yourself, much more happiness, truth, beauty, and wisdom will come to you that way" - Christopher Hitchens

#5 User is offline   Wolfy87 

  • Senior Member
  • PipPipPipPip
  • Find Topics
  • Group: Members
  • Posts: 414
  • Joined: 25-July 08
  • Gender:Male
  • Location:England

Posted 05 May 2009 - 06:00 PM

Ok then and if I learn trigg in normal math can I incorporate that into my code? Ie dose it do roughly the same thing.

Thanks for the advice, Wolfy87.

#6 User is offline   groovicus 

  • Hail Groovicus!
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Moderator
  • Posts: 9,522
  • Joined: 05-June 04
  • Gender:Male
  • Location:Centerville, SD

Posted 05 May 2009 - 06:05 PM

I don't know what you mean by 'normal' math? Trigonometry is trigonometry, regardless of if you do it with a paper or pencil, or as part of a program.
"Take the risk of thinking for yourself, much more happiness, truth, beauty, and wisdom will come to you that way" - Christopher Hitchens

#7 User is offline   Wolfy87 

  • Senior Member
  • PipPipPipPip
  • Find Topics
  • Group: Members
  • Posts: 414
  • Joined: 25-July 08
  • Gender:Male
  • Location:England

Posted 06 May 2009 - 07:14 AM

Ok, thats sort of what i wanted to know anyway so thanks, off to trigg tutorials :thumbsup:

Thanks, Wolfy87.

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users