The Daily Click ::. Forums ::. Klik Coding Help ::. MMF not capable of shooting straight?
 

Post Reply  Post Oekaki 
 

Posted By Message

erghhhhx



Registered
  15/11/2007
Points
  311

Mushroom
6th December, 2007 at 19:04:40 -

I'm making a platformer where the player is controlled by the keyboard (awsd) and the aim is controlled by the mouse, but it doesnt shoot straight to the crosshair. It seems it only have like 20 directions to shoot, and that it chooses the one closest to the CH.

Here's an example http://www.box.net/shared/pltt1ikyk8

Help appreciated.

 
n/a

AsparagusTrevor

Mine's a pint of the black stuff

Registered
  20/08/2002
Points
  2364

Game of the Week WinnerHas Donated, Thank You!VIP MemberEvil kliker
6th December, 2007 at 19:29:18 -

Actually, it's only got 32 directions, not 20, which is still pretty shit anyway. You can make a custom 360 degree movement if you're any good at trigonometry, or look for a 360 shooting tutorial, I think there's a few. If it's MMF2 you're using, you can use the Vector movement for really easy 360 degree shooting.

 
Image

erghhhhx



Registered
  15/11/2007
Points
  311

Mushroom
7th December, 2007 at 01:08:56 -

Thank you, it will probably work fine.

But I still think 32 directions is way too few.!.

 
n/a

viva/volt

Awesome Sauce

Registered
  26/08/2006
Points
  1694

Game of the Week WinnerSilverNova MemberKlikCast StarVIP Member
7th December, 2007 at 01:14:01 -

You should make your own engine then

There are plenty of examples of 360 degree shooting.

 
Image
http://bfollington.tumblr.com

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
7th December, 2007 at 02:04:34 -


There are plenty of examples of 360 degree shooting.


..and I haven't seen one that works. MMF2 just doesn't allow enough decimal points on floats for it to move in truly 360 degrees (or more). The best I could get was a kind of 'homing missile'

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image

LIJI

Flava's Smarter Twin

Registered
  29/08/2006
Points
  2032

I like penguins
7th December, 2007 at 02:19:14 -

ARCO2 can make a custom race car movement with endless directions (360 + floating poing).
Advanced Direction Object can help you make nice aiming.

 
Service Unavailable

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
7th December, 2007 at 02:31:41 -

Eh? One decimal point isn't enough for you?

Assuming you mean places, it has enough for pretty much anything we're likely to need it for. My guess would be you were applying the calculations immediately to the position of the object, which means you lose all your fractions every loop. Common mistake.

 
n/a

Tim

I'm on here way too much

Registered
  25/08/2006
Points
  132

You've Been Circy'd!Clickzine StaffSilverNova MemberVIP MemberTurtle Power!Evil klikerWii OwnerHero of TimeGhostbuster!Pokemon Ball!
7th December, 2007 at 02:38:27 -


Originally Posted by LIJI.
ARCO2 can make a custom race car movement with endless directions (360 + floating poing).



*floating point

teehee!... *runs*

 
http://www.SilverNova.co.uk


Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
7th December, 2007 at 03:37:04 -

Well, where do I put the calculations then? I'd have to find a place that accepts floats and MMF 2 seems to just mix freely the actions that only calculate in integers with the floats. Is there like a document somewhere that shows which ones use floats and which use integers?

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image

viva/volt

Awesome Sauce

Registered
  26/08/2006
Points
  1694

Game of the Week WinnerSilverNova MemberKlikCast StarVIP Member
7th December, 2007 at 04:45:36 -

You calculate positions in alterable values then set the object to those values. Just a thought.

 
Image
http://bfollington.tumblr.com

erghhhhx



Registered
  15/11/2007
Points
  311

Mushroom
7th December, 2007 at 05:09:38 -

Well, that could work. But i want the platformer to shoot the bullet/or whatever it is.

I'll look into tthose tutorials.

 
n/a

Kirby Smith

Resident Slacker

Registered
  18/05/2003
Points
  479

VIP Member360 OwnerWii OwnerThe Cake is a Lie
8th December, 2007 at 10:21:51 -

What I found works is to run all my calculations based on "absolute positions" which I then translate into less precise pixel positions every program loop. By that I mean that if my game runs in 320x240 resolution, I'd have alterable values for x and y positions that run from 320,000 to 240,000 instead. Then you run all your calculations off those values and at the end of everything, set the objects x,y co-ordinates on screen to that value divided by 1,000. When the next program loop occurs, all your absolute positions are still accurate. Collision detection is still "only" pixel perfect, but nobody will notice and it won't effect game-play.

(edit): As for the actual 360-degree shooting. Do something like this:

Player presses 'fire' button
- create bullet object at player (hotspot) x,y position
- set alterable value bullet x,y position to bullet x,y (x1000)
- set alterable values for x and y movement per loop based on the angle that the cursor is away from the object times the speed of the object. You'll need some trig equations for this, but basically you're taking the overall speed of the bullet and making that the hypotenuse of your triangle, and then figuring out the ratio of the sides for the x and y position changes per loop (it's been a couple years since I took a trig class but you can find this stuff online and it's easy).
- Next, you just tell MMF to update the bullets absolute x,y positions by the amount of it's x,y movement alterable values every time the program loop runs. Then, once it's done that, take the absolute x,y positions and divide them by 1,000 to get their position on screen.

The advantage of using custom shooting engines is that you have significantly more control (read: you can actually do something to them) over your bullets once they've been fired. Using more advanced math, you can create homing missiles this way, or have a weapon that fires projectiles that follow a sine wave on their way to the target. You can also make them move faster than the maximum built into MMF. Keep in mind though that if you do, you'll have to work up a collision detection system that'll account for this. A good way to do that is through fast loops that, much like the sub-pixel positioning, actually move the bullet several times within each program loop before updating the screen.

If you haven't already done so, you should also consider creating a custom platform movement for your play so that he doesn't get stuck in ceilings and what-not. The built in platform movement in MMF is utter crap, and it'll improve the quality of your game tremendously if you create your own movement engine. Unlike the 360-shooting, there ARE several tutorials on this site under the "articles" tab that'll explain exactly how to do this.

Image Edited by the Author.

 
XBL Gamertag: Rampant Mjolnir

erghhhhx



Registered
  15/11/2007
Points
  311

Mushroom
8th December, 2007 at 12:18:35 -

rigrt eow i dont uderstand shit from that, but it looks relly good. thank u evryone who helps me

 
n/a

Muz



Registered
  14/02/2002
Points
  6499

VIP MemberI'm on a BoatI am an April FoolHonored Admin Alumnus
22nd December, 2007 at 17:14:36 -


Originally Posted by Benta Claus . __ .
You calculate positions in alterable values then set the object to those values. Just a thought.



I think I tried that. Didn't seem to work.

Lol, Kirby. Trig doesn't work well in MMF2. Not in my code at least :/. The only way I found that worked was setting the X,Y of the intended target of the bullet, and making it always 'look' in that direction using one of those direction objects. After it's in the location of the target, make it look in the direction relative from the shooter to the bullet (i.e. if bullet it 26 degrees from shooter, set bullet to moving at 26 degrees, not looking at target anymore) so they don't become homing missiles. I think a few other people who did '360 degree' engines also used the same method. It's a bit too accurate when shooting long distance, but you can add a random number when setting the X,Y, so that should fix it .

 
Disclaimer: Any sarcasm in my posts will not be mentioned as that would ruin the purpose. It is assumed that the reader is intelligent enough to tell the difference between what is sarcasm and what is not.

Image

viva/volt

Awesome Sauce

Registered
  26/08/2006
Points
  1694

Game of the Week WinnerSilverNova MemberKlikCast StarVIP Member
22nd December, 2007 at 17:54:56 -

If you want 360 shooting here's an example I found http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Board=5&Number=7807&Searchpage=1&Main=972&Words=360+shooting&topic=0&Search=true#Post7807

I remember Nifflas made one but I couldn't find that, this one makes things a little more complex than needs be but it works.

EDIT: Gotcha! http://www.ni2.se/files/mmf2_sources/360degreebullet.mfa for the Nifflas one.

Image Edited by the Author.

 
Image
http://bfollington.tumblr.com

DeadmanDines

Best Article Writer

Registered
  27/04/2006
Points
  4758
24th December, 2007 at 06:32:17 -

If you don't understand the maths, read this:

http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=67082#Post67082

(shameless plug of own article)

 
191 / 9999 * 7 + 191 * 7

Sagal



Registered
  17/10/2007
Points
  36
24th December, 2007 at 06:58:44 -

That Nifflas one doesnt work correctly atleast not the shooting for me.
THe bullets only go to 12 different directions

 
n/a
   

Post Reply



 



Advertisement

Worth A Click