The Daily Click ::. Forums ::. Klik Coding Help ::. Shooting limited directions
 

Post Reply  Post Oekaki 
 

Posted By Message

Don Luciano

Heavy combat pancake

Registered
  25/10/2006
Points
  380

VIP Member
12th March, 2007 at 08:38:56 -

Is there a way to increase the standard 24 directions shooting, to more directions. at least to 360.

I am making tbstrategy and...
My enemies are 16x16 pixels, and bullets if shooten from far away from them just go above or underneath my enemies. Making it hard to check for collisions.

Is there maybe some other simple way not using shooting to simulate 360 direction shooting?

Any tips or help is welcome.

I searched a little over the board. and found some tuts and stuff, yet there are nothinig regarding mmf2.360

Image Edited by the Author.

Image Edited by the Author.

 
Code me a sausage!

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
12th March, 2007 at 10:10:46 -

If you couldn't find anything on 360 degree shooting, then you weren't looking hard enough, as that is probably one of the most freqently asked questions on these forums. And it's the same for MMF2 as for MMF1; trigonometry and math doesn't change in any way.

Here's how you do it:

[event]
- Create Bullet at (0;0) from Player
- Bullet: Set angle to [some angle]
- Bullet: Set Xpos to X("Player")
- Bullet: Set Ypos to Y("Player")

* Always
- Bullet: Set Xpos to Xpos("Bullet") + Cos(Angle("Bullet")) * Velocity("Bullet")
- Bullet: Set Ypos to Ypos("Bullet") - Sin(Angle("Bullet")) * Velocity("Bullet")
- Bullet: Set X position to Xpos("Bullet")
- Bullet: Set Y position to Ypos("Bullet")

[event] is the event which makes the player fire the bullet. [some angle] should be the angle in which the bullet is fired (it depends on what sort of game you're making). Xpos, Ypos and Velocity are all alterable values. Remember to give Velocity an initial value.

Image Edited by the Author.

 
n/a

Don Luciano

Heavy combat pancake

Registered
  25/10/2006
Points
  380

VIP Member
12th March, 2007 at 10:20:09 -

thx very much axel...
One more question.
How do i determine the angle based on xy distance from shooter to target?
I use mouse right click on enemy to shoot the bullet.

 
Code me a sausage!

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
12th March, 2007 at 10:30:16 -

http://www.create-games.com/forum_post.asp?id=184225

 
n/a

Don Luciano

Heavy combat pancake

Registered
  25/10/2006
Points
  380

VIP Member
12th March, 2007 at 11:02:33 -

I tried that tan thing but it doesn't work or i m doing something wrong


This is what i did to get angle from two object and bullets always go just plain left

these gruops r fixed values in event so that s not the problem

Tan(-1)*((Y( "Group.Keys" )-Y( "Group.Enemies" ))/(X( "Group.Keys" )-X( "Group.Enemies" )))

Image Edited by the Author.

 
Code me a sausage!

Hernan



Registered
  04/03/2003
Points
  707

VIP Member
12th March, 2007 at 13:01:27 -

What pixelthief meant with in that post is to use the arctangent function. He used "Tan^(-1)" to denote that. The function for MMF is ATan().

Edit: also, using groups in that expression will most likely lead to wrong values.

Image Edited by the Author.

 
This space is for rent
   

Post Reply



 



Advertisement

Worth A Click