My Situation:
I guess in a sense, I’m trying to create a game with similar game play to *Legend of Zelda: A Link to The Past. *Except, with much more advanced AI. First of all, I don’t want to make it a tile-based game, because it’s a serious pain, at least to me. I’m relatively new to flash scripting I suppose, but I’m trying my best at studying it. I’m at the foundation of programming the game play.
My Problems / Needed Advice:
I know I might be asking for a lot, but here’s what I need help on.
First of all, having the enemy face you when you move around it. Seeings as you move in four directions instead of left and right, I want the enemy to face the player in all four directions. Of course, theoretically, instead of have a regular X and Y coordinate plane (a cross) you would essentially need a diagonal coordinate plane (an X). Without that (unless there is a different way to do it) the program gets “confused” (for lack of a better word) and it can only tell whether you’re on the left side, or the right side of the enemy, and face either two sides, or above the enemy or below the enemy, and face those sides, and visa-versa. It can’t tell if you’re diagonal to the enemy. I need advice on how to do this (as if it were in Legend of Zelda: A Link to the Past).
Rou is the player name of the player instance by the way. Frames 1-4 are the sides the enemy is facing.
onClipEvent (load) {
var scale:Number = this._xscale;
}
onClipEvent (enterFrame) {
var distance:Number = 150;
var tx:Number = this._x;
var ty:Number = this._y;
var sx:Number = _root.Rou._x;
var sy:Number = _root.Rou._y;
if (Math.sqrt((sx-tx)*(sx-tx)+(sy-ty)*(sy-ty))<distance) {
if (tx<sx) {
this.gotoAndStop(3);
this._xscale = +scale;
}
if (tx>sx) {
this.gotoAndStop(2);
this._yscale = +scale;
}
if (ty<sy) {
this.gotoAndStop(4);
this._yscale = +scale;
}
if (ty>sy) {
this.gotoAndStop(1);
this._xscale = +scale;
}
}
if (Math.sqrt((sx-tx)*(sx-tx)+(sy-ty)*(sy-ty))>distance) {
_root.enemy.gotoAndStop(1);
}
if((_currentframe==3)and(this.hitTest(_root.Rou))) {
_root.hp.health--
}
}
Another problem I WILL have with this, is associating how the enemy attacks from each side. I don’t want the player to be at the left of the enemy, turn towards the enemy, and then the enemy attacks to the right instead of left. However, I’m sure that once someone tells me how to fix the first problem, I’ll easily be able to figure this out myself.
Another problem I have is having the health bar, data, inventory, ect, stay on the same spot on the screen and follow the player simultaneously as the screen moves.
The last problem I have is when the enemy is hit, how do I get him to bounce back in the direction opposite to which he was hit?
Please help!
I use **Macromedia Flash 8: Professional.
**Sincerly,
Saiya Uchima