si ahí parecía ensalada ahora que parecerá...
acá dejo un link con el el super Game
[url]
http://maxiwork.comoj.com//flash_games/Game.swf [/url]
Código ActionScript :
package scriptgame.motor{
import scriptgame.util.KeyObject
import flash.ui.Keyboard;
import flash.display.MovieClip;
import flash.display.Stage;
import flash.display.DisplayObject;
import flash.display.Stage
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent
import flash.events.TimerEvent;
import flash.utils.Timer;
public class Player extends MovieClip
{
private var friccion:Number=0.63
private var yspeed:Number=0
private var grav:Number =0.4
private var salto:Number= 12
private var tsalto=0
public var ptBajo:Number=height/2
public var ptAlto:Number=-height/2
public var ptIzq:Number=-width/2
public var ptDer:Number=width/2
private var dx
private var dy
private var vel:Number = 2
private var maxvel:Number = 28
private var stageRef:Stage;
private var key:KeyObject;
private var $ground=Ground
private var gr_lv1
private var newPlay= this
private var newShot:Shot
private var mirar:Number
public function Player(stageRef:Stage,$_ground)
{
$ground = $_ground
this.x = 200
this.y = 150
this.stop();
this.stageRef = stageRef;
key = new KeyObject(stageRef);
var tiempo:Timer= new Timer(1,0)
addEventListener(Event.ENTER_FRAME, mover, false, 0, true);
tiempo.addEventListener(TimerEvent.TIMER,chkContact )
tiempo.start();
}
public function mover(e:Event) : void
{
if (key.isDown(Keyboard.LEFT))
this.dx -= this.vel,this.gotoAndStop(2),this.scaleX=-1,mirar=1
else if (key.isDown(Keyboard.RIGHT))
this.dx += this.vel,this.gotoAndStop(2),this.scaleX= 1,mirar=0
else if (key.isDown(Keyboard.UP))
{ y -= salto, tsalto++}
else if (key.isDown(Keyboard.DOWN))
{ this.gotoAndStop(3)}
else if (key.isDown(Keyboard.CONTROL))
{
newShot=new Shot(this.x,this.y,mirar)
stage.addChild(newShot)
}
else if (!key.isDown(Keyboard.LEFT)) this.gotoAndStop(1),this.scaleX=1
//
else if (tsalto >= 2)(salto=0)
gravedad();
iniPlay(this)
movesOn()
}
public function gravedad()
{
gr_lv1= $ground
if( gr_lv1.hitTestPoint (this.x,this.y+25,true))
{
y-=0,yspeed=0
}
else {yspeed += grav; newPlay.y += yspeed;}
}
private function iniPlay(mc):void
{
if (mc.dx==undefined){mc.dx=0,mc.dy=0}
}
public function movesOn():void
{
this.x+=this.dx;
this.dx*=this.friccion;
this.y+=this.dy;
if (this.dx > maxvel)this.dx=maxvel
else if (this.dx<-maxvel)this.dx=-maxvel
}
public function chkContact(evento:TimerEvent)
{
if (gr_lv1.hitTestPoint(this.x,this.y+ptBajo,true))
this.y-- ,this.dy =0 ;
if (gr_lv1.hitTestPoint(this.x,this.y+ptAlto,true))
this.y++ , this.dy =Math.abs(this.dy)
//Colicion en lado Izq
if (gr_lv1.hitTestPoint(this.x+ptIzq,this.y,true))
this.x++ , this.dx =0
if (gr_lv1.hitTestPoint(this.x+ptIzq,this.y+ptBajo/3,true))
this.x++ , this.dx =0
//Colicion en lado Derecho
if (gr_lv1.hitTestPoint(this.x+ptDer,this.y,true))
this.x-- , this.dx =0
if (gr_lv1.hitTestPoint(this.x+ptDer,this.y+ptBajo/3,true))
this.x-- , this.dx =0
}
}//End Class
}//End package