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.

Photo

Just an algorithm


  • Please log in to reply
6 replies to this topic

#1 Wolfy87

Wolfy87

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:01:06 PM

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.

BC AdBot (Login to Remove)

 


#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:07:06 AM

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.

#3 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:01:06 PM

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 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:07:06 AM

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.

#5 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:01:06 PM

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 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:07:06 AM

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.

#7 Wolfy87

Wolfy87
  • Topic Starter

  • Members
  • 414 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:England
  • Local time:01:06 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users