2 Replies - 668 Views - Last Post: 02 July 2012 - 07:35 AM Rate Topic: -----

#1 N1G3L2  Icon User is offline

  • New D.I.C Head

Reputation: 4
  • View blog
  • Posts: 28
  • Joined: 25-October 11

Java Game- Shooting bullet with mouse

Posted 01 July 2012 - 09:59 PM

Hey people,
I have been messing around a little bit with the code from brackeen's game tutorial (http://www.brackeen.com/javagamebook/#download) and now have a start for a nice little top down tile-based game/engine. I have the basics done, and now want to implement some sort of shooting/attack for the player. I have made little games in the past where a bullet image would be added and it's x value would be increased/decreased. But I would really like to be able to have the bullet follow the direction of a mouse click. I have also done this in the past, but am having a problem now because when i try to use the Point class, it only accepts integers. So, basically my question is...What would be the best way to go about overwriting the Point class to accept floats as parameters?
I can include some code if it is necessary, but it seems pretty straightforward enough. Any suggestions are welcome. Thanks ahead of time people I really appreciate it =)

Is This A Good Question/Topic? 0
  • +

Replies To: Java Game- Shooting bullet with mouse

#2 CasiOo  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 995
  • View blog
  • Posts: 2,209
  • Joined: 05-April 11

Re: Java Game- Shooting bullet with mouse

Posted 02 July 2012 - 02:21 AM

No need to make your own, you can use the Point2D.Float class :)
Was This Post Helpful? 0
  • +
  • -

#3 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 9039
  • View blog
  • Posts: 33,526
  • Joined: 27-December 08

Re: Java Game- Shooting bullet with mouse

Posted 02 July 2012 - 07:35 AM

Or Point2D.Double for better precision. Avoid floats unless there is a compelling reason to use them.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1