The Daily Click ::. Forums ::. Klik Coding Help ::. 360* Shooter (Overhead)?
 

Post Reply  Post Oekaki 
 

Posted By Message

G. Hull



Registered
  07/01/2009
Points
  125

Wii Owner
5th November, 2009 at 22:18:30 -

Hey, I have a question about 360* Overhead shooter codes. One, I don't know how to code it. Two, I have seen a bunch of tutorials for them, but none of them make it so I can fully understand what does what and why it does. If I could find some simple code for it, that would be great, otherwise, if it's complicated, please explain it pretty well.
All in all I want my guy with a gun to face the arrow, or cross-hair, and shoot pretty accurately at it. I want to be able to move the guy with 8-directional movement, but I want him to always face the cursor. Understand?
Thanks a lot people!

-Rannug

 
n/a

Watermelon876



Registered
  16/04/2009
Points
  27

I am an April FoolVIP Member
6th November, 2009 at 00:37:10 -

http://www.gamebuilder.info/world/content/survival-space
I updated it with source. It should help.

 
Awesomeness is Watermelon.
*/l、
゙(゚、 。 7
l、゙ ~ヽ
じしf_, )ノ
This is Koji. Copy and paste Koji to your sig so he can acheive world domination.

ELC_Games



Registered
  30/11/2008
Points
  17
8th November, 2009 at 23:48:51 -

I'll go and post my simple option here:

Take one small active object, no larger than 5x5 pixels, and give it an 8-directional movement. Next, create a larger active with the preferred character graphics you wish to give it, making sure to set the movement type to "static". Under runtime options, enable automatic rotations. Make sure to make each of their hot spots centered. In the event editor, set this code up.

Always->Active B(Static character object)->Position->Set position at 0,0 relative to Active A(8-direction object)


Duplicate the action if necessary. This will "bolt" the character down to the movement object, giving it an 8-directional movement.

Next, create another object, and set its position to 0,0 relative to your mouse. Even though I didn't do it, you can make the object move more efficiently with the mouse with this series of events:

Always->Active C(Cross-hair)->Position->Set X position to XMouse

Active C(Cross-hair)->Position->Set Y position to YMouse


Next, you'll want to get the character to always look at the crosshair. This is incredibly simple. Under your first "Always" condition, just put down "Active B->Look at (0,0) from Active C"

Here's the full example. While the collision and other junk aren't working as of yet, it has some code I hope will be helpful in it:

http://www.mediafire.com/download.php?yyhvztmyjym


 
There are those who live to win, and those who win to live. There is no in between.

Sumo148

Super amazing fantastic user

Registered
  26/01/2009
Points
  530

360 OwnerThe Cake is a LieVIP MemberPokemon Ball!I am an April FoolI donated an open source projectSanta Hat
9th November, 2009 at 02:58:15 -

Your example above isn't the best because that way only shoots in 32 directions, making the shooting inaccurate. You'll have to create a custom 360 shooting engine in order for it to be precise.

 
n/a

Rob Westbrook



Registered
  25/05/2007
Points
  193

360 OwnerVIP Member
9th November, 2009 at 17:39:43 -

You don't need the small 8-direction active with a custom movement either, since the movement of an active and its angle are totally separate in your case. For a true 360 degree shooting engine, there are a fair few articles and forum posts detailing how to set one up. All it takes is a basic knowledge of trigonometry!

If you're using MMF2 then it's a simple case of using the Advanced Direction Object and a single Player AO:

Always: Set Player Active's Angle to Direction( "Advanced Direction Object", X( "Player Active" ), Y( "Player Active" ), XMouse, YMouse)

That will mean the Player is always looking at the mouse and the Advanced Direction Object does all the trig for you. Although, for a 360 degree shooting engine, to get perfect accuracy you'll need to use Float values rather than Integers. Since MMF and things only generally work in Ints, it's a good idea to work through Alterable Values for Angle, X and Y and sticking a "+0.0" onto the end of every calculation, then setting the actual angle and position variables to those Alt Values. Again there's a bunch of articles on that subject as well!

Sketchy's article on useful formulae is one of the most helpful things ever to come out of TDC's forums x)
http://www.create-games.com/article.asp?id=1898

Hope that helps!

 
There are 10 types of people in the world: Those who understand binary and those who don't.

Watermelon876



Registered
  16/04/2009
Points
  27

I am an April FoolVIP Member
9th November, 2009 at 23:51:54 -

Or just download my example... Sorry, off-topic! Won't happen again!

 
Awesomeness is Watermelon.
*/l、
゙(゚、 。 7
l、゙ ~ヽ
じしf_, )ノ
This is Koji. Copy and paste Koji to your sig so he can acheive world domination.

GamesterXIII



Registered
  04/12/2008
Points
  1110

I am an April Fool
10th November, 2009 at 00:22:23 -

Rob, your statement has me a bit confused. I have created a 360 degree shooting engine without float values and it seems to be perfectly accurate at any distance across the screen.

 
n/a

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49567

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
10th November, 2009 at 00:39:07 -


Originally Posted by GamesterXIII
Rob, your statement has me a bit confused. I have created a 360 degree shooting engine without float values and it seems to be perfectly accurate at any distance across the screen.



It's not, unless you stored the starting value of the bullet and recalculated the distance every time with a new distance multiplier. Even so mmf would still be using floats in it's own math.

You "can" avoid using floats but it isn't accurate at small distances. Try moving an object at an angle of 1 degree at 1 pixel per loop. See! It will only move right the entire time, and not account for all the small increments toward a higher y value overtime cause mmf will round those numbers off.

 
n/a

GamesterXIII



Registered
  04/12/2008
Points
  1110

I am an April Fool
12th November, 2009 at 18:03:09 -

oh man my bad.

I must have been dead tired or on crack or something when I posted that because I definitely DID use float values in it. I know zero about trig. . . I played with it for 2-4 weeks to get a 360 degree engine down and still don't know anything about it.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click