Sonic and Sega Retro Message Board: Homing Attack Help - Sonic and Sega Retro Message Board

Jump to content

Hey there, Guest!  (Log In · Register) Help
Page 1 of 1
    Locked
    Locked Forum

Homing Attack Help Could anyone maybe help with some code? :/

#1 User is offline Light Matter 

Posted 08 January 2015 - 10:09 AM

  • Posts: 11
  • Joined: 23-August 14
  • Gender:Male
  • Project: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. ;)
This post has been edited by Light Matter: 08 January 2015 - 10:12 AM

#2 User is offline winterhell 

Posted 08 January 2015 - 11:09 AM

  • Posts: 1023
  • Joined: 16-October 10
  • Gender:Male
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.

isPerformingHomingAttack:boolean
isConnected:boolean
targetX:integer
targetY:integer

.............
//this is in some loop
range=100;
moveSpeed=5;
if(enemyX-range<playerX AND playerX < enemyX+range)
    if(enemyY-range<playerY AND playerY < enemyY+range)
	if(Button2 == Pressed) 
	{
         isPerformingHomingAttack=true;
	 targetX=enemyX;
	 targetY=enemyY;
	}
	
	
if(isPerformingHomingAttack)
{
if(playerX<targetX)
{
  if(playerX+moveSpeed<targetX)
	playerX=playerX+moveSpeed;
	else 
	{
	playerX=targetX;
	isConnected=true;
	}
}
if(targetX<playerX)
{
  if(targetX<playerX-moveSpeed)
	playerX=playerX-moveSpeed;
	else 
	{
	playerX=targetX;
	isConnected=true;
	}
}

if(playerY<targetY)
{
   if(playerY+moveSpeed<targetY)
	playerY=playerY+moveSpeed;
	else 
	{
	playerY=targetY;
	isConnected=true;
	}
}
if(targetY<playerY)
{
  if(targetY<playerY-moveSpeed)
	playerY=playerY-moveSpeed;
	else 
	{
	playerY=targetY;
	isConnected=true;
	}
}
}
if(isConnected)
{
//do your rebound, special effects and kill badnik
isPerformingHomingAttack=false;
isConnected=false;
}


This post has been edited by winterhell: 08 January 2015 - 11:15 AM

#3 User is offline Light Matter 

Posted 08 January 2015 - 12:08 PM

  • Posts: 11
  • Joined: 23-August 14
  • Gender:Male
  • Project: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 User is online DigitalDuck 

Posted 08 January 2015 - 12:50 PM

  • Arriving four years late.
  • Posts: 4191
  • Joined: 23-June 08
  • Gender:Male
  • Location:Lincs, UK
  • Project:TurBoa, S1RL

View PostLight Matter, on 08 January 2015 - 12:08 PM, said:

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


Basic Questions & Answers thread in E&RE.

#5 User is offline TheInvisibleSun 

Posted 08 January 2015 - 03:25 PM

  • OVER THE TOP TECHNO-BLAST
  • Posts: 1295
  • Joined: 09-December 09
  • Gender:Male
  • Location:Buffalo, NY, USA
  • Project:Sonic 1 Color Contrast
But E&RE is specifically for hacking right? Maybe the Fangaming subforum should have its own Basic Q&A thread.

#6 User is offline Light Matter 

Posted 09 January 2015 - 05:31 AM

  • Posts: 11
  • Joined: 23-August 14
  • Gender:Male
  • Project:Making a Sonic the Hedgehog engine in Flash w/ AS3.

View PostTheInvisibleSun, on 08 January 2015 - 03:25 PM, said:

But E&RE is specifically for hacking right? Maybe the Fangaming subforum should have its own Basic Q&A thread.


I don't even know- this is my 2nd post, excluding my applications!

#7 User is offline BlazeHedgehog 

Posted 09 January 2015 - 09:09 AM

  • A "Community Enigma"?
  • Posts: 1391
  • Joined: 23-January 05
  • Gender:Male
  • Wiki edits:51
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 User is offline Light Matter 

Posted 09 January 2015 - 09:22 AM

  • Posts: 11
  • Joined: 23-August 14
  • Gender:Male
  • Project:Making a Sonic the Hedgehog engine in Flash w/ AS3.

View PostBlazeHedgehog, on 09 January 2015 - 09:09 AM, said:

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?


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 User is offline winterhell 

Posted 09 January 2015 - 09:38 AM

  • Posts: 1023
  • Joined: 16-October 10
  • Gender:Male
Pinned Q&A topic seems reasonable.

#10 User is offline Overlord 

Posted 09 January 2015 - 05:39 PM

  • Substitute Meerkovo IT Chief
  • Posts: 15990
  • Joined: 12-January 03
  • Gender:Male
  • Location:Berkshire, England
  • Project:VGDB
  • Wiki edits:3,204
It'll be a topic at best, yes. Not an entire subforum.

Page 1 of 1
    Locked
    Locked Forum

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users