The Daily Click ::. Forums ::. Non-Klik Coding Help ::. Enemy Attack Distances
 

Post Reply  Post Oekaki 
 

Posted By Message

Cyrillus



Registered
  13/08/2008
Points
  5
13th November, 2008 at 17:54:07 -

Alright, so, long story short, I've been working on a NES-style Mega Man game for the past few months. For the most part, everything's been coming along rather nicely. However, now that I've moved onto the addition of enemies, I've hit somewhat of a snag... What I'm trying to do is make an enemy jump and land at Mega Man's exact location, or shoot a projectile in an arc which will always land where Mega Man is standing. Both these attack methods are fairly common in Mega Man games, so I feel it's important I learn how to implement this myself. I've already used Pythagoras Theorem to calculate the distance between Mega Man and the enemy at all times, but how would I go about using this information in an event? (or events...) I must say, this has me completely stumped... Any help at all would be greatly appreciated.

 
n/a

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
13th November, 2008 at 19:15:40 -

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


or in other words, if you're using velocities:

Given (X1,Y1) & (X2,Y2)
D = Sqr((X2^2 - X1^2) + (Y2^2 - Y1^2))
S = Projectile speed in Pixels/Frame, for overall movement
gives:
X velocity = ((X2 - X1) / (D / S))
Y_velocity = (Y2-Y1)/(D/S) - (Gravity*(D/S))/2


Image Edited by the Author.

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

Cyrillus



Registered
  13/08/2008
Points
  5
13th November, 2008 at 19:25:25 -

It would be great if I could view the example projectile.gam file in that topic, but I need KCamath.cox, the Advanced Math Object Multimedia Fusion. I've been searching for it for a while now, and all I can find are dead links. Do you know of any place I'd be able to download it?

 
n/a

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
13th November, 2008 at 19:29:47 -

http://claniraq.googlepages.com/kcamath.cox

three more words

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

Cyrillus



Registered
  13/08/2008
Points
  5
13th November, 2008 at 19:34:54 -

Thanks a lot, man. I really appreciate it.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click