Jump to content
  • Advertisement
Sign in to follow this  
Kid4Today

Makeing a flash game, need help

This topic is 4840 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, i am a student learning multimedia design and i am currently working on a flash game for a project. my aim is to succesfully make a beat-em-up similar to Ninja turtles, double dragon, etc. most of it is done, all my sprites and backgrounds are finished i have managed to succesfully program in the walking limitations and scrolling background, although the most trouble i am having it coding the enemies to not only move left and right, but up and down as well, i am stressing this very much. if anybody can point me to a site that explains how to do so, or a tutorial, or source file, or conteact me. i am desperate. any help would be greatly appreciated, thank you :)

Share this post


Link to post
Share on other sites
Advertisement
what exactly is your problem in getting them to move up and down? This is a very specific topic and I doubt that there are any resources available that directly address it.

perhaps if you posted a little bit more detail as to what the problem actually is someone would have better luck giving you a more detailed tip [smile]

I'll try to do my best with the information I have:

I'm assuming that you're storing enemy positions as well as their width and height, in order to make sure they don't go off the screen you are checking the x position as well as the x position + the width of the enemy. In order to keep the enemy from going off the bottom you should use the y position + the height to determine where their 'feet' are. Once this is done set a high/low boundary for the feet and enforce it just like the left/right boundary.

Share this post


Link to post
Share on other sites
ok here is a picture, Image hosted by Photobucket.com

my goal is to make that guy on teh right, automaticaly move closer to the hero on teh left as a steady pace. and stop when hes not so far away. and later figure out how to exchange damage

Share this post


Link to post
Share on other sites
Since you are a multimedia student I suggest you not to indulge in complex maths of programming physics algos right now but look at simpler codes of flash tuts/games instead at www.flashkit.com

Share this post


Link to post
Share on other sites
too late, i nee this thing done by friday, and thats why im desperate, i dont think i have to deal with anything "too" complicating, i need to find a way to just make "bad_guy" walk to "good_guy" thats it

Share this post


Link to post
Share on other sites
I dont see how making the enemies move closer vertically to the player is anymore difficult than making them move closer horizontally?

if the enemy is higher than the player, move down.
if the enemy is lower than the player, move up.
if the enemy is left of the player, move right.
if the enemy is right of the player, move left.

That's pretty much it unless you were after some more complex form of the enemy determining their path

Share this post


Link to post
Share on other sites
what you can do first of all i hope that you have save both x and y position of the bad guy and the hero as well then waht you need to do is

if(badguy_x>(hero_x+hero_w) And badguy_x<Screewidth)badguy_x=badguy_x-1 endif
if(badguy_x<(hero_x-hero_w) And badguy_x>0)badguy_x=badguy_x+1 endif

And you would do the same thing for the Y but this Time keeping track of the Height of the Screen in mind. Hope that helps

Share this post


Link to post
Share on other sites
this is how I have done it.

"temp" = the enemy



////////////////////////////////////////////////////////////////////
/////////////////////////This Part is for distance//////////////////
////////////////////////////////////////////////////////////////////
xdistance = player._x - temp._x;
ydistance = player._y - temp._y;

var distance = Math.sqrt((xdistance * xdistance)+(ydistance * ydistance));

if (distance < 50)
{
//enemy/player hitting code
}

//stun will toggle when enemy is hit by player lazer
if (stun == 1)
{

////////////////////////////////////////////////////////////////////
/////////////////////////This Part is for rotation//////////////////
////////////////////////////////////////////////////////////////////
TanY = gold1._y - temp._y;
TanX = gold1._x - temp._x;
temp._rotation = Math.round((Math.atan2(TanY,TanX) * 180/Math.PI + 90));

////////////////////////////////////////////////////////////////////
/////////////////////////This Part is for movement//////////////////
////////////////////////////////////////////////////////////////////
var x = temp._x + Math.round((Math.sin(Math.PI/180.0 * temp._rotation)) * enemyspeed);
var y = temp._y - Math.round((Math.cos(Math.PI/180.0 * temp._rotation)) * enemyspeed);
temp._x = x;
temp._y = y;
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!