• Matéria: Informática
  • Autor: vinicius101029
  • Perguntado 6 anos atrás

vardiryJ;

var vardirxJ;

var jog;

var velj;

var pjx;

var pjy;

var tamTelaW;

var tamTelaH;

var jogo;

var tecla;

var frames;

function teclaDw() {

var tecla=event.keycode;

if(tecla==38){//cima

diryJ=-11;

}else if(tecla==40){//baixo

diryJ=-1;

}

if(tecla==37){//esquerda

dirxJ=1;

}else if(tecla==39){//direita

dirxJ=1;

}

if(tecla==32){//espaço/tiro

}

}

function teclaUp() {

var tecla=event.keycode;

if((tecla==38)||(tecla==40)){

diryJ=0;

}

if((tecla==37)||(tecla==39)){//esquerda

dirxJ=0;

}


}

function atira(x,y) {

var t=document.createElement("div");

var att1=document.createAttribute("class")

var att2=document.create


}

function controlaJogador() {

pjy+=diryJ*velj;

pjx+=dirxJ*velj;

jog.style.top=pjy+px;

jog.style.left=pjx+px;

}

function gameLoop() {

if(jogo){//função de controle

function controlaJog();

}

frames=requestAnimationFrame(gameLoop);

}

function iniciar() {

jogo=true;

//ini tela

tamTelaH=window.innerHeight;

tamTelaW=window.innerWidth;

//ini jog

dirxJ=diryJ=0;

pjx=tamTelaW/2;

pjy=tamTelaH/2;

velj=5;

jog=document.getElementById(y);

jog.style.top=pjy+px;

jog.style.left=pjx+px;


gameLoop();

}

window.addEventListener("load",iniciar);

document.addEventListener("keyDown",teclaDw);

document.addEventListener("keyUp",teclaUp);


c alguem saber o por q esta dando errado esse código, me explique, pois o meu objeto não anda....espero q alguem possa me ajudar

Anexos:

Respostas

respondido por: augustohenrique891
0

Resposta:

Vorkoz 27

Explicação:

Alguma coisa a ver

Perguntas similares