Comunidad de diseño web y desarrollo en internet online

Driving game

Citar            
MensajeEscrito el 13 Dic 2008 09:20 pm
Hice un auto MC y puse este codigo:

onClipEvent (load) {
speed = 0
xspeed = 0
yspeed = 0
acceleration = Number(_root.saccel)
turnfriction = Number(10 - _root.shand)
maxspeed = 0
topspeed = Number(_root.sspeed/4)
}
onClipEvent (enterFrame) {

maxspeed = topspeed

_x += xspeed
_y += yspeed
if(Key.isDown(Key.UP)){speed += acceleration}
if(Key.isDown(Key.DOWN)){if(speed > 0){speed -= acceleration}}
if(speed >0){speed -= acceleration/2}
if(speed <0){speed += acceleration/2}
if(Key.isDown(Key.LEFT)){_rotation -= speed/turnfriction}
if(Key.isDown(Key.RIGHT)){_rotation += speed/turnfriction}
if(speed > maxspeed){speed = maxspeed}

xspeed = speed*Math.cos((_rotation)*Math.PI/180);
yspeed = speed*Math.sin((_rotation)*Math.PI/180);
}


NO encuentro el error,,,no se mueve

Por Juaniix

85 de clabLevel



 

firefox
Citar            
MensajeEscrito el 14 Dic 2008 07:23 pm
xd Gracias x nada baa, igual me ayudaron en un par de cosas...

Aquí les doy el código correcto (arreglado) para los que quieran hacer un juego tipo el mio...(autos):

onClipEvent (load) {
speed = 0
xspeed = 0
yspeed = 0
acceleration = .5
turnfriction = 2
maxspeed = 0
topspeed = 15
}
onClipEvent (enterFrame) {

maxspeed = topspeed

_x += xspeed
_y += yspeed
if(Key.isDown(Key.UP)){speed += acceleration}
if(Key.isDown(Key.DOWN)){speed -= acceleration}
if(speed >0){speed -= acceleration/2}
if(speed <0){speed += acceleration/2}
if(Key.isDown(Key.LEFT)){_rotation -= speed/turnfriction}
if(Key.isDown(Key.RIGHT)){_rotation += speed/turnfriction}
if(speed > maxspeed){speed = maxspeed}

xspeed = speed*Math.cos((_rotation)*Math.PI/180);
yspeed = speed*Math.sin((_rotation)*Math.PI/180);
}

Les cambian la velocidad del auto a su gusto ;D

Por Juaniix

85 de clabLevel



 

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.