Ir para conteúdo
Fórum Script Brasil
  • 0

Car Game multiplayer


Sir.Lima

Pergunta

Boas, podem-me colocar 2 carros nesse tutorial? Eu já consegui colocar as teclas porém fazendo a cópia das camadas não funciona, alguém me poderá ajudar?

Esse código é com as teclas AWSD

function step(who) {
	//check to see if the li in question is controlled by the player1 or by the computer1
	if (_root["li"+who].code == "player1") {
		//we will constantly decrease speed by multiplying it with a number below 1
		if (this["speed"+who]>0.3) {
			this["speed"+who] *= _root.speedDecay;
		} else {
			this["speed"+who] = 0;
		}
		//the li will react to certain keys
		//accelerate
		if (Key.isDown(87) && this["speed"+who]<_root.maxSpeed) {
			this["speed"+who] += _root.acceleration;
		}
		//brake (reverse)
		if (Key.isDown(83)) {
			this["speed"+who] -= _root.backSpeed;
		}
		//steer left
		if (Key.isDown(65) && this["speed"+who]>0.3) {
			_root["li"+who]._rotation -= _root.rotationStep*(this["speed"+who]/_root.maxSpeed);
		}
		//steer right
		if (Key.isDown(68) && this["speed"+who]>0.3) {
			_root["li"+who]._rotation += _root.rotationStep*(this["speed"+who]/_root.maxSpeed);
		}
		this["rotation"+who] = _root["li"+who]._rotation;
		//we calculate the two components of speed (X axis and Y axis)
		this["speedx"+who] = Math.sin(this["rotation"+who]*(Math.PI/180))*this["speed"+who];
		this["speedy"+who] = Math.cos(this["rotation"+who]*(Math.PI/180))*this["speed"+who]*-1;
		//apply the components on the actual position of the li
		_root["li"+who]._x += this["speedx"+who];
		_root["li"+who]._y += this["speedy"+who];
		//position the shadow of the li
		_root["shadow"+who]._x = _root["li"+who]._x-4;
		_root["shadow"+who]._y = _root["li"+who]._y+2;
		_root["shadow"+who]._rotation = _root["li"+who]._rotation;
	}
	if (_root["li"+who].code == "computer1") {
	}
}

http://www.emanueleferonato.com/2007/05/15/create-a-flash-racing-game-tutorial/

Editado por Sir.Lima
Link para o comentário
Compartilhar em outros sites

0 respostass a esta questão

Posts Recomendados

Até agora não há respostas para essa pergunta

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152k
    • Posts
      651,8k
×
×
  • Criar Novo...