The Daily Click ::. Forums ::. Klik Coding Help ::. Special Bullet Path (Math #2)
 

Post Reply  Post Oekaki 
 

Posted By Message

Blue66



Registered
  24/05/2008
Points
  1186

GOTW JUNE 2010 WINNER!Hero of TimeVIP Member
21st November, 2008 at 09:52:54 -

Hi again!
After I've received such a great help with my last math problem, here is another one I encountered lately.

I want a gun to shoot a specific "path" without using any actual paths. It should be handeled with a simple math formula, but again, I suck at math!

The bullet should fly in a boomerangly way like this:
Image

Right now I already made it shoot like this, but I use about 10 triggers to do so and it is inaccurate (looks like some math noob made some stuff that kinda looks like he is trying to be professional...)

Would be really great if someone could tell me a better way to handle this!

 
www.paulinthenet.de
www.gungirl2.com

Eternal Man [EE]

Pitied the FOO

Registered
  18/01/2007
Points
  2955

Game of the Week WinnerHero of TimeLOL SignI am an April Fool
21st November, 2008 at 15:28:52 -

Hm, what you've got there is a sinus wave which changes direction with 180 degrees after half a period. I'm not sure how to program it, but that should give you a good start.

 
Eternal Entertainment's Code'n'Art Man

E_E = All Indie


...actually Ell Endie, but whatever.
Image
Image

Joe.H

Evil Faker

Registered
  19/08/2002
Points
  3305
21st November, 2008 at 21:04:08 -

What you'd need to do is this:

On shooting the boomerang, you would need to start a counter/value that increases up to 180. You would then set a flag on after it reaches this, and continue to increase it, but just simply change the X direction of movement.

Eg

Upon shooting
+ no boomerangs on screen =
Boomerang set flag off
Alt Value A boomerang = 0
Player: set flag on

Always
+ player flag on
= Alt value A boomerang + 1
Set Y position of boomerang to Y("hand position) + (max height of flight path)*(sin (Alt value A boomerang))

OR if MMF works in radians Y("hand position") + (max height)*(sin ((pi/180)*Alt value A boomerang))

Always + boomerang flag off
= Set X position of boomerang to X("Boomerang") + 1 (or however much you want it to increase by each step

Always + boomerang flag on
= Set X position to X("Boomerang") - 1

Alt value A boomerang > 180
Set flag boomerang on


OR SOMETHING LIKE THIS

i dont have anything to test it on, but that's a basic idea of how it works.

 
My signature is never too big!!!

W3R3W00F

Drum and Bass Fueled Psycho

Registered
  08/11/2008
Points
  372

VIP MemberCardboard BoxThe Cake is a Lie
21st November, 2008 at 21:16:45 -


Originally Posted by Eternal Man [EE]
Hm, what you've got there is a sinus wave which changes direction with 180 degrees after half a period. I'm not sure how to program it, but that should give you a good start.



I believe you mean, SINE wave?

 
An old and washed up once-kid

Eternal Man [EE]

Pitied the FOO

Registered
  18/01/2007
Points
  2955

Game of the Week WinnerHero of TimeLOL SignI am an April Fool
22nd November, 2008 at 01:34:23 -


Originally Posted by The Dominant and Heartless Drawcula

Originally Posted by Eternal Man [EE]
Hm, what you've got there is a sinus wave which changes direction with 180 degrees after half a period. I'm not sure how to program it, but that should give you a good start.



I believe you mean, SINE wave?



Probably THE most annoying thing a person can do, but yes I meant SINE wave. It's called SINUS here in Sweden and should be called that EVERYWHERE ELSE since it's the original latin form of the word, but then it could also just be called JB derived from JIBA which is the older arabic word for the function or why the hell not just JIVA abbreviated from JYA-ARDHA which is the pure original sanskrit name for it.
SUCK to you for that.

 
Eternal Entertainment's Code'n'Art Man

E_E = All Indie


...actually Ell Endie, but whatever.
Image
Image

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
22nd November, 2008 at 01:41:15 -

Nevermind. >_>
 


Edited by OMC

 

  		
  		

Eternal Man [EE]

Pitied the FOO

Registered
  18/01/2007
Points
  2955

Game of the Week WinnerHero of TimeLOL SignI am an April Fool
22nd November, 2008 at 01:44:39 -


Originally Posted by OldManClayton
Nevermind. >_>
 



Thats right!
Run away!!!
Ha ha, just kidding.

 
Eternal Entertainment's Code'n'Art Man

E_E = All Indie


...actually Ell Endie, but whatever.
Image
Image

Pixelthief

Dedicated klik scientist

Registered
  02/01/2002
Points
  3419

Game of the Week WinnerWeekly Picture Me This Winner!You've Been Circy'd!VIP MemberI like Aliens!Evil klikerThe SpinsterI donated an open source project
22nd November, 2008 at 03:03:51 -

uh, how about this...

Y position = Sin wave
X position = Constant Acceleration with an initial velocity in other direction.


So like this:

Always:
Add 1 to "Boomerang" Value A
X("Boomerang") = ( X("Boomerang") + 20 - Value A)
Y("Boomerang") = Y("Player") + Sin(Value A * 20) * 50


tinker with the numbers a bit to get the effect you like

 
Gridquest V2.00 is out!!
http://www.create-games.com/download.asp?id=7456
   

Post Reply



 



Advertisement

Worth A Click