The Daily Click ::. Downloads ::. Tutorial ::. Pixel-Perfect (better than 360 degrees) Shooting T
 

Pixel-Perfect (better than 360 degrees) Shooting T
Author: Jack Zhou Submitted: 10th July, 2009 Favourites:0
Genre: Tutorial Downloads: 562
Rated:


Edited By Jack Zhou on 7/11/2009

I really needed one of these for a bullet hell shmup I'm making, but I could not find a tutorial online... so I spent the 10 minutes to think about it, and worked out a nearly flawless pixel-perfect shooting engine. It uses no extensions.

There is no complicated math in there, just Pythagorean Theorem, and similar triangles. If there is something you don't understand or want clarification on, feel free to leave a message.

This should not have any problems (if you want to see this engine at its best, change the "User Clicks With Left Button" to repeat while left mouse is held down; then, click your mouse, drag, and be amazed ;D), but if it does, please tell me and I'll see what I can do about it.

The only real problem I can see with this is having it function under heavy stress (timer screwing up, etc). I'm going to stick it in my shmup anyway and see how it turns out.

For MMF/MMF2, but should be easy enough to replicate even on TGF.

Quick edit:
TGF owners and those who want a clearer explanation should look here: http://www.create-games.com/article.asp?id=2129.

Review This Download



 


http://awcentre.netfirms.com/shooter.mfa (51.17 kkb )



Posted by [DELETED] 10th July, 2009
Rated :

Very effective, however, when the 0.01's counter reaches it's max, the bullets will cease to move. When you shoot, they are created but will stay where they were spawned. Therefore, necessary to add an event where when the counter reaches its maximum, reset it. And it will continue to work, I just tested that.

Also, is this versatile for adaptation? To multiple enemies, players etc.

In any case I will hold on to this, it's extremely useful!
 
Posted by Jack Zhou 10th July, 2009

I'm testing adaptability now, although I don't think the 0.01 timer maxing will be a problem. A quick calculation tells me that it would take over 115 days for it to reach 999999999, which is its technical max value. Unless I'm mistaken about the max, it shouldn't matter. If you start at -999999999 instead, you get twice as much time to work with the counter, so may use that. Thanks for your comment Image
Comment edited by Jack Zhou on 7/10/2009
 
Posted by b0z0 11th July, 2009
Rated :

Could you maybe post the events here? I only have TGF atm and would like to try this out.
 
Posted by Jack Zhou 11th July, 2009

Graawr, made one here:

http://www.create-games.com/article.asp?id=2129.

Enjoy!
 
Posted by b0z0 11th July, 2009
Rated :

Looks solid. I'll try it out now. Thanks a million dude.
 
Posted by b0z0 11th July, 2009
Rated :

Okay, I dunno how to get this working with TGF.. We cant have more then 3 alterable values on a single object from what I can tell.
Is there a way around this?
 
Posted by Jack Zhou 11th July, 2009

That's true, a silly oversight by me. Maybe create two additional objects (at the same time as the bullet, and store the same A value) to store 6 extra alterable values?
 
Posted by b0z0 11th July, 2009
Rated :

That could work except TGF has a pretty low object limit. Guess I should just upgrade to TGF2 or MMF2, eh?
 
Posted by Jack Zhou 11th July, 2009

Heh, probably. Forgive me for this oversight, it's been a long time since I've used TGF1. It'll work fine for top-down 2D shooters though, I think, if you need the pinpoint accuracy. Plus, bullets get erased often, so the additional objects get deleted too. If I find my copy of TGF, I'll try to make an example sometime, but yeah, consider upgrading =P.
 
Posted by b0z0 11th July, 2009
Rated :

Well I'm dropping it for now. I'll keep a look out for your possible TGF example though. Thanks for the help.
 
Posted by Marko 11th July, 2009
Rated :

Just downloaded this and had a look - seems pretty simple in hindsight when i look at the code but exceptionally clever all the same. Excellent work, Jack Zhou!
 
Posted by Kazuma 11th July, 2009
Rated :

b0z0, TGF's object limit shouldn't really hurt you. If it's really THAT hard to make more objects and use their values, get the 1000 Global Value object or use a useless object's values (an animated tree, for example).

I like simple things. Good job.
 
Posted by phanto 11th July, 2009
Rated :

Works great
Comment edited by phanto on 7/11/2009
 
Posted by steve 14th July, 2009

very nice. But when I added a quick movement test on the gun (8 dir movement) the bullets become homing missiles .. is that intentional?
 
Posted by Jack Zhou 14th July, 2009

Bullets should travel in a straight line from the shooter to the crosshair, so if that's what you mean, then yes. However, if it's curving (as "homing missiles" suggests), then it must be a bug or something. I've tried adding movement to the gun, and it seemed to work fine (although you shouldn't use the 8 dir since the shooter always looks at the crosshair (i.e. if deceleration is not maxed, it'll slide towards the crosshair).
 

 



Author

Favourite



Advertisement

Worth A Click