don't click here

Homing Attack Help

Discussion in 'Fangaming Discussion' started by Light Matter, Jan 8, 2015.

  1. Light Matter

    Light Matter

    Member
    11
    0
    0
    Making a Sonic the Hedgehog engine in Flash w/ AS3.
    Hey, You!

    That's right- I know that you are you!

    Alright. All silliness aside- I'm in need of help, just for a bit of code. Could anyone (experienced with Flash ActionScript 3.0) possibly give me some code for a homing attack?
    Yeah. I know that little. Great.
    But really, I really need some code which is like 2D Sonics homing attack? Just a basic one, with conditions being 1; the enemy must be within a certain range; and 2; Sonic smoothly, not just clipping/blinking over.

    I don't intend if any of this came out rude or demanding (if so, I apologize)- I am just asking the community for help. After all- Sonic Retro is Sonic Retro because of its community.

    Thank you. ;)
     
  2. winterhell

    winterhell

    Member
    1,165
    7
    18
    This is not the appropriate subforum and if you have to ask about this, then you need to learn a lot. Anyway I did this pseudo code just because. Hope it helps.

    Code (Text):
    1.  
    2. isPerformingHomingAttack:boolean
    3. isConnected:boolean
    4. targetX:integer
    5. targetY:integer
    6.  
    7. .............
    8. //this is in some loop
    9. range=100;
    10. moveSpeed=5;
    11. if(enemyX-range<playerX AND playerX < enemyX+range)
    12.     if(enemyY-range<playerY AND playerY < enemyY+range)
    13.     if(Button2 == Pressed)
    14.     {
    15.          isPerformingHomingAttack=true;
    16.      targetX=enemyX;
    17.      targetY=enemyY;
    18.     }
    19.    
    20.    
    21. if(isPerformingHomingAttack)
    22. {
    23. if(playerX<targetX)
    24. {
    25.   if(playerX+moveSpeed<targetX)
    26.     playerX=playerX+moveSpeed;
    27.     else
    28.     {
    29.     playerX=targetX;
    30.     isConnected=true;
    31.     }
    32. }
    33. if(targetX<playerX)
    34. {
    35.   if(targetX<playerX-moveSpeed)
    36.     playerX=playerX-moveSpeed;
    37.     else
    38.     {
    39.     playerX=targetX;
    40.     isConnected=true;
    41.     }
    42. }
    43.  
    44. if(playerY<targetY)
    45. {
    46.    if(playerY+moveSpeed<targetY)
    47.     playerY=playerY+moveSpeed;
    48.     else
    49.     {
    50.     playerY=targetY;
    51.     isConnected=true;
    52.     }
    53. }
    54. if(targetY<playerY)
    55. {
    56.   if(targetY<playerY-moveSpeed)
    57.     playerY=playerY-moveSpeed;
    58.     else
    59.     {
    60.     playerY=targetY;
    61.     isConnected=true;
    62.     }
    63. }
    64. }
    65. if(isConnected)
    66. {
    67. //do your rebound, special effects and kill badnik
    68. isPerformingHomingAttack=false;
    69. isConnected=false;
    70. }
    71.  
     
  3. Light Matter

    Light Matter

    Member
    11
    0
    0
    Making a Sonic the Hedgehog engine in Flash w/ AS3.
    Thanks a bunch! ;)

    Also, for future reference, where should I post things like this?
     
  4. DigitalDuck

    DigitalDuck

    Arriving four years late. Member
    5,418
    492
    63
    Lincs, UK
    TurBoa, S1RL
  5. TheInvisibleSun

    TheInvisibleSun

    OVER THE TOP TECHNO-BLAST Member
    1,636
    197
    43
    Buffalo, NY, USA
    The Water
    But E&RE is specifically for hacking right? Maybe the Fangaming subforum should have its own Basic Q&A thread.
     
  6. Light Matter

    Light Matter

    Member
    11
    0
    0
    Making a Sonic the Hedgehog engine in Flash w/ AS3.
    I don't even know- this is my 2nd post, excluding my applications!
     
  7. BlazeHedgehog

    BlazeHedgehog

    A "Community Enigma"? Oldbie
    1,472
    18
    18
    Yeah, I'll second the fact that it seems weird to make this subforum just a fangame circle jerk

    Surely it's about fangame development too, and questions pertaining to that stuff should be allowed. Probably doesn't keep things strictly organized but if that's the case then why have the fangame subforum at all?
     
  8. Light Matter

    Light Matter

    Member
    11
    0
    0
    Making a Sonic the Hedgehog engine in Flash w/ AS3.
    Well, yeah! I reckon, maybe we should contact ScarredSun. She could create a subforum (or whatever they're called) for help. After all- Sonic Retro is getting an overhaul anyway, right?
     
  9. winterhell

    winterhell

    Member
    1,165
    7
    18
    Pinned Q&A topic seems reasonable.
     
  10. Overlord

    Overlord

    Now playable in Smash Bros Ultimate Moderator
    19,490
    1,092
    93
    Long-term happiness
    It'll be a topic at best, yes. Not an entire subforum.