Skip to content
Snippets Groups Projects
Commit 96b7a69c authored by bhm15's avatar bhm15
Browse files

Merge com atividade do quebra cabeca

parents de7f3baa 872a4b09
Branches
No related tags found
No related merge requests found
www/assets/atividade_quebracabeca/moldura_quadro.png

310 KiB

www/assets/settings_menu/return_arrow.png

2.54 KiB

<!DOCTYPE html>
<head>
<html lang="pt-br">
<html>
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<meta charset="UTF-8">
<link rel="stylesheet" href="css/index.css">
<title>JAPA</title>
<head>
<style>
body {
margin: 0 !important;
padding: 0 !important;
}
</style>
<title>Pointer Movement Test</title>
<script type="text/javascript" src="js/phaser.min.js"></script>
<script type="text/javascript" src="js/dif.js"></script>
......
......@@ -26,13 +26,25 @@ function InicScore_F(){
scoreIniciado=true;
}
function difAtividade_F(numeroAtividade,acertosAtuais){
function difAtividade_F(numeroAtividade,acertosAtuais=0){
acertosAtuais = typeof acertosAtuais !== 'undefined' ? acertosAtuais : 0; //se acertosAtuais nao for passado, ele vale 0
if(numeroAtividade==1){ //SE FOR A ATIVIDADE DAS MASCARAS
var aux = (scoreAtiv[1]*3 + acertosAtuais);
if(aux>=15){ return 5; }
return(20 - aux); //RETORNA 20 menos 3 vezes a pontuacao da pessoa menos os acertos, porem retorna no minimo 5
}
if(numeroAtividade==2){ //SE FOR A ATIVIDADE DO QUEBRA CABECA
var retorno = {};
retorno.tempo = 15 - (scoreAtiv[2] % 5); // retorna 15, 14, 13, 12 ou 11
retorno.nErradas = 1 + (scoreAtiv[2]-(scoreAtiv[2] % 5))/5; //retorna 1, 2 ou 3
if (retorno.nErradas > 3){
retorno.nErradas = 3;
retorno.tempo = 11;
}
return retorno; //retorna objeto
}
}
function imprimeNumero(numero,posiX,posiY){
......
......@@ -46,19 +46,19 @@ AtividadeMascara.prototype = {
//--------------------Define os botoes e coloca na tela-----------------//
addBotoes: function() {
botaoFeliz = game.add.button(0, 0, 'botaoFeliz', this.clickBotaoFeliz, this, 0, 0, 1);
botaoFeliz.scale.setTo(0.0002*LARGURA,0.0004*ALTURA);
botaoFeliz.scale.setTo(0.20,0.20);
botaoFeliz.input.useHandCursor = true;
botaoRaiva = game.add.button(0, 0, 'botaoRaiva', this.clickBotaoRaiva, this, 0, 0, 1);
botaoRaiva.scale.setTo(0.0002*LARGURA,0.0004*ALTURA);
botaoRaiva = game.add.button(LARGURA * (65.25/100), 0, 'botaoRaiva', this.clickBotaoRaiva, this, 0, 0, 1);
botaoRaiva.scale.setTo(0.20,0.20);
botaoRaiva.input.useHandCursor = true;
botaoSusto = game.add.button(0, 0, 'botaoSusto', this.clickBotaoSusto, this, 0, 0, 1);
botaoSusto.scale.setTo(0.0002*LARGURA,0.0004*ALTURA);
botaoSusto = game.add.button(LARGURA * (65.25/100), ALTURA * (76.66/100), 'botaoSusto', this.clickBotaoSusto, this, 0, 0, 1);
botaoSusto.scale.setTo(0.20,0.20);
botaoSusto.input.useHandCursor = true;
botaoTriste = game.add.button(0, 0, 'botaoTriste', this.clickBotaoTriste, this, 0, 0, 1);
botaoTriste.scale.setTo(0.0002*LARGURA,0.0004*ALTURA);
botaoTriste = game.add.button(0, ALTURA * (76.66/100), 'botaoTriste', this.clickBotaoTriste, this, 0, 0, 1);
botaoTriste.scale.setTo(0.20,0.20);
botaoTriste.input.useHandCursor = true;
},
......@@ -113,16 +113,16 @@ AtividadeMascara.prototype = {
masc_aux.y = 0;
masc_aux = botoes[1];
masc_aux.x = LARGURA - botoes[1].width;
masc_aux.x = LARGURA * (65.25/100);
masc_aux.y = 0;
masc_aux = botoes[2];
masc_aux.x = LARGURA - botoes[2].width;
masc_aux.y = ALTURA - botoes[2].height;
masc_aux.x = LARGURA * (65.25/100);
masc_aux.y = ALTURA * (76.66/100);
masc_aux = botoes[3];
masc_aux.x = 0;
masc_aux.y = ALTURA - botoes[3].height;
masc_aux.y = ALTURA * (76.66/100);
},
/*===========Funcao que embaralha vetor============*/
......
//O NUMERO DESTA ATIVIDADE EH 2
var AtividadeQuebraCabeca = function () {
LARGURA = W; //Refere-se ao W definido em Splash.js
ALTURA = H; //Refere-se ao H definido em Splash.js
LIMITE_ERROS = 3; //Numero maximo que error que uma pessoa pode ter
tamanhoPedaco = 256;//tamanho da imagem (peças) quadrada
tempo = [];
tempo.tempo=0;
tempo.deltaTime=0;
tempo.inicioAtividade = game.time.now;
nPecas=9;
imagemTeste = [];
nPecas=16;
imagemPrincipalQuebraCabeca = [];
botaoMovendo = null;
vetorPosicaoCelulas = [];
moldura = null;
background = null;
tamPecas = LARGURA/12;
};
AtividadeQuebraCabeca.prototype = {
loadImages: function() {
game.load.image('fundo', 'assets/atividade_mascara/fundo.png',LARGURA,ALTURA);
game.load.image('moldura', 'assets/atividade_quebracabeca/moldura_quadro.png');
},
loadSpritesSheet: function() {
game.load.spritesheet('mascaras','assets/atividade_mascara/mascaras/vetorMascaras.png', 550, 515);
game.load.spritesheet('numeros','assets/primos.png', 200, 300);
game.load.spritesheet('monstros','assets/atividade_mascara/monstros/vetorMonstros.png', 1024, 1024);
for(var i=1; i<=4; i++){
for(var j=1; j<=4; j++){
game.load.spritesheet( (i-1)*4+j+"", 'assets/atividade_quebracabeca/'+i+'-'+j+'.png', tamanhoPedaco, tamanhoPedaco);
}
}
game.load.spritesheet('errada1', 'assets/atividade_quebracabeca/errada1.png', tamanhoPedaco, tamanhoPedaco);
game.load.spritesheet('errada2', 'assets/atividade_quebracabeca/errada2.png', tamanhoPedaco, tamanhoPedaco);
game.load.spritesheet('errada3', 'assets/atividade_quebracabeca/errada3.png', tamanhoPedaco, tamanhoPedaco);
game.load.spritesheet('botaoFeliz', 'assets/atividade_mascara/buttons/botaoFelicidade.png', 2048/2, 475);
game.load.spritesheet('botaoRaiva', 'assets/atividade_mascara/buttons/botaoRaiva.png', 2048/2, 475);
game.load.spritesheet('botaoSusto', 'assets/atividade_mascara/buttons/botaoMedo.png', 2048/2, 475);
game.load.spritesheet('botaoTriste', 'assets/atividade_mascara/buttons/botaoTristeza.png', 2048/2, 475);
},
preload: function() {
this.loadImages();
this.loadSpritesSheet();
game.load.audio('meow', 'assets/atividade_mascara/audio/meow.mp3');
},
create: function() {
background = game.add.sprite(0, 0, 'fundo');
background.width = game.width;
background.height = game.height;
//Moldura e ajuste do tamanho da mesma
var recuoX = LARGURA/4 - 2.5*tamPecas;
var recuoY = ALTURA/2 - 2.5*tamPecas;
moldura = game.add.sprite(recuoX,recuoY,'moldura');
moldura.width = tamPecas*5;
moldura.height = tamPecas*5;
estadoAtual = "AtividadeQuebraCabeca";
game.physics.startSystem(Phaser.Physics.ARCADE);
var auxRecuo = -2;
//Diz a posicao das celulas da imagem
var recuoX = LARGURA/4 + auxRecuo*tamPecas;
var recuoY = ALTURA/2 + auxRecuo*tamPecas;
var aux = 0;
for(i=0; i < 4; i++){
for(j=0; j < 4; j++){
vetorPosicaoCelulas[aux] = {};
vetorPosicaoCelulas[aux].x = recuoX;
vetorPosicaoCelulas[aux].y = recuoY;
vetorPosicaoCelulas[aux].ocupado = null;
recuoX += tamPecas;
aux++;
}
recuoX = LARGURA/4 + auxRecuo*tamPecas;
recuoY += tamPecas;
}
for(i=0;i<nPecas;i++){
imagemTeste[i] = game.add.sprite(50*i, 0, 'botaoFeliz');
imagemTeste[i].width/=10;
imagemTeste[i].height/=5;
imagemTeste[i].inputEnabled = true;
imagemTeste[i].events.onInputDown.add(this.clicouBotao, this);
recuoX = LARGURA/4 + auxRecuo*tamPecas;
recuoY = ALTURA/2 + auxRecuo*tamPecas;
var n;
imagemTeste[i].podeMoverObj = 0;
var trocaErrada = [];
for(var i = 0; i < difAtividade_F(2).nErradas; i++)
trocaErrada[i] = this.retornaPecaQueFalta(i+1);
game.physics.enable(imagemTeste, Phaser.Physics.ARCADE);
for(i=0; i < 4; i++){
for(j=0; j < 4; j++){
n = (i*nPecas/4)+j;
imagemPrincipalQuebraCabeca[n] = null;
for(var cont=0; cont < trocaErrada.length; cont++){
if(trocaErrada[cont]-1 == n && imagemPrincipalQuebraCabeca[n] == null)
imagemPrincipalQuebraCabeca[n] = game.add.sprite(0, 0, "errada"+(cont+1) );
}
if(imagemPrincipalQuebraCabeca[n] == null)
imagemPrincipalQuebraCabeca[n] = game.add.sprite(0, 0, ""+(n+1) );
vetorPosicaoCelulas[n].ocupado = imagemPrincipalQuebraCabeca[n].key;
game.physics.enable(imagemPrincipalQuebraCabeca[n], Phaser.Physics.ARCADE);
imagemPrincipalQuebraCabeca[n].width=tamPecas;
imagemPrincipalQuebraCabeca[n].height=tamPecas;
imagemPrincipalQuebraCabeca[n].x = recuoX;
imagemPrincipalQuebraCabeca[n].y = recuoY;
recuoX += tamPecas;
imagemPrincipalQuebraCabeca[n].inputEnabled = true;
imagemPrincipalQuebraCabeca[n].events.onInputDown.add(this.clicouBotao, this);
imagemPrincipalQuebraCabeca[n].podeMoverObj = false;
game.physics.startSystem(Phaser.Physics.ARCADE);
//Diz a posicao das celulas da imagem
var aux = 0;
for(i=0; i<3; i++){
for(j=0; j<3; j++){
vetorPosicaoCelulas[aux] = {};
vetorPosicaoCelulas[aux].x = i*103;
vetorPosicaoCelulas[aux].y = j*93;
aux++;
}
recuoX = LARGURA/4 + auxRecuo*tamPecas;
recuoY += tamPecas;
}
recuoX = 3*LARGURA/4;
recuoY = ALTURA/2 - 2*tamPecas;
var posi = imagemPrincipalQuebraCabeca.length;
for(var i=0; i < 3; i++){
if(i < trocaErrada.length)
imagemPrincipalQuebraCabeca[posi] = game.add.sprite(0, 0, ""+trocaErrada[i] );
else
imagemPrincipalQuebraCabeca[posi] = game.add.sprite(0, 0, "errada"+(i+1) );
game.physics.enable(imagemPrincipalQuebraCabeca[posi], Phaser.Physics.ARCADE);
imagemPrincipalQuebraCabeca[posi].width=tamPecas;
imagemPrincipalQuebraCabeca[posi].height=tamPecas;
imagemPrincipalQuebraCabeca[posi].x=recuoX;
imagemPrincipalQuebraCabeca[posi].y=recuoY;
imagemPrincipalQuebraCabeca[posi].inputEnabled = true;
imagemPrincipalQuebraCabeca[posi].events.onInputDown.add(this.clicouBotao, this);
imagemPrincipalQuebraCabeca[posi].podeMoverObj = false;
posi++;
recuoY+=tamPecas*1.5;
}
//Coloca o primeiro tempo(base) para quando iniciar a atividade
this.zeraTempo();
this.updateTime(); //Atualiza o tempo na tela
this.atualizaImagemNumeros(); //Atualiza o tempo na tela
},
/*=====Funcao que realiza atualizacao do tempo restante para a realizacao da rodada na atividade=====*/
updateTime: function() {
var auxTempo = parseFloat(difAtividade_F(1, acertosLocal)) - parseFloat(tempo.tempo/1000);
atualizaImagemNumeros: function() {
var auxTempo = parseFloat(difAtividade_F(2,0).tempo) - parseFloat(tempo.tempo/1000);
imprimeNumero(auxTempo, game.world.centerX, 50);
},
......@@ -89,29 +164,32 @@ AtividadeQuebraCabeca.prototype = {
/*====Funcao chamada quando a atividade for finalizada====*/
finalizaAtividade: function() {
this.dispose();
var auxTempo = parseFloat(difAtividade_F(2,0).tempo) - parseFloat(tempo.tempo/1000);
if (auxTempo <= 0){
alert("Acabou o tempo!");
}
game.state.add("mapState", mapState);
game.state.start("mapState");
},
/*====Funcao chamada para atualizar o tempo====*/
atualizaTempo: function() {
tempo.deltaTime=(game.time.now-tempo.inicioAtividade);
tempo.inicioAtividade = game.time.now;
tempo.tempo+= tempo.deltaTime;
},
/*====Funcao para zerar o tempo, para o jogador poder jogar a fase novamente====*/
zeraTempo: function() {
tempo.tempo=0;
tempo.deltaTime=0;
tempo.inicioAtividade = game.time.now;
},
/*====Funcao para conseguir mover as imagens====*/
moveObjMouse: function(obj) {
if(obj.podeMoverObj){
var posiMouse = {};
posiMouse.x = game.input.x;
posiMouse.y = game.input.y;
obj.body.x = posiMouse.x - obj.width/2;
obj.body.y = posiMouse.y - obj.height/2;
}
......@@ -119,9 +197,9 @@ AtividadeQuebraCabeca.prototype = {
},
percorreImagens: function(obj) {
for(i=0;i<nPecas;i++){
if(imagemTeste[i].podeMoverObj){
this.moveObjMouse(imagemTeste[i]);
for(i=0;i<imagemPrincipalQuebraCabeca.length;i++){
if(imagemPrincipalQuebraCabeca[i].podeMoverObj){
this.moveObjMouse(imagemPrincipalQuebraCabeca[i]);
}
}
},
......@@ -138,17 +216,49 @@ AtividadeQuebraCabeca.prototype = {
menor.indice = i;
}
}
if(menor.indice!=-1){
if(menor.indice!=-1 && vetorPosicaoCelulas[menor.indice].ocupado == null){
botaoMovendo.x = vetorPosicaoCelulas[menor.indice].x;
botaoMovendo.y = vetorPosicaoCelulas[menor.indice].y;
vetorPosicaoCelulas[menor.indice].ocupado = botaoMovendo.key;
}
botaoMovendo.podeMoverObj = false;
botaoMovendo = null;
if(this.verificaCerto()){ //Verifica se a imagem usada para completar o quebra cabeça é a correta
scoreAtiv[2]++;
this.finalizaAtividade();
}
}
else{
botaoMovendo = botao;
//Reinstancia para debugar o layer
var auxBotao = botao;
for(var i = 0; i < imagemPrincipalQuebraCabeca.length; i++){
if(imagemPrincipalQuebraCabeca[i] == botao){
imagemPrincipalQuebraCabeca[i].destroy();
imagemPrincipalQuebraCabeca[i] = game.add.sprite(0, 0, auxBotao.key);
imagemPrincipalQuebraCabeca[i].inputEnabled = true;
imagemPrincipalQuebraCabeca[i].events.onInputDown.add(this.clicouBotao, this);
imagemPrincipalQuebraCabeca[i].podeMoverObj = false;
game.physics.enable(imagemPrincipalQuebraCabeca[i], Phaser.Physics.ARCADE);
imagemPrincipalQuebraCabeca[i].x = auxBotao.x;
imagemPrincipalQuebraCabeca[i].y = auxBotao.y;
imagemPrincipalQuebraCabeca[i].width = auxBotao.width;
imagemPrincipalQuebraCabeca[i].height = auxBotao.height;
botao = imagemPrincipalQuebraCabeca[i];
}
}
//
botao.podeMoverObj = true;
botaoMovendo = botao;
for(i = 0; i < 16; i++){
if(vetorPosicaoCelulas[i].ocupado == botao.key)
vetorPosicaoCelulas[i].ocupado = null;
}
}
},
......@@ -164,6 +274,29 @@ AtividadeQuebraCabeca.prototype = {
return dist;
},
/*===Funcao criada para verificar qual peça foi tirada do quebra cabeça principal, e qual deve ser randomizada===*/
retornaPecaQueFalta: function(pecaErrada) {
var vetorImagens = [];
vetorImagens[1] = [6,7,10,11];
vetorImagens[2] = [6,7,14,15];
vetorImagens[3] = [9,10,11,12];
return vetorImagens[pecaErrada][Math.floor(Math.random() * vetorImagens[pecaErrada].length)];
},
verificaCerto : function(){
for(var i = 0; i < 16; i++)
if(vetorPosicaoCelulas[i].ocupado != ""+(i+1))
return 0;
return 1;
},
dispose: function() {
for(var i = 0; i < imagemPrincipalQuebraCabeca.length; i++){
imagemPrincipalQuebraCabeca[i].destroy();
}
background.destroy();
},
update: function() {
if (estadoAtual == "AtividadeQuebraCabeca") {
......@@ -172,10 +305,10 @@ AtividadeQuebraCabeca.prototype = {
this.percorreImagens();
this.updateTime();
this.atualizaImagemNumeros();
var auxTempo = parseFloat(difAtividade_F(2,0).tempo) - parseFloat(tempo.tempo/1000);
if(auxTempo <= 0)
this.finalizaAtividade();
}
......
......@@ -22,10 +22,13 @@ MainMenu.prototype = {
create: function() {
game.state.add('mapState', mapState);
<<<<<<< HEAD
//musica do menu
musicaMenu = game.add.audio('musicaMenu');
musicaMenu.play();
=======
>>>>>>> AtividadeQuebraCabeca
background = game.add.sprite(0, 0, 'background');
background.width = game.width;
background.height = game.height;
......
//var game = new Phaser.Game(screen.width, screen.height, Phaser.AUTO, 'game'), Main =
var game = new Phaser.Game(window.innerWidth, window.innerHeight, Phaser.AUTO, 'game'), Main =
function() {};
numeroAtividades = 1;
numeroAtividades = 2;
estadoAtual = "";
Main.prototype = {
preload: function () {
......
......@@ -34,10 +34,13 @@ mapState.prototype = {
ocean = game.add.sprite(0, 0, 'ocean');
ocean.width = game.width;
ocean.height = game.height;
<<<<<<< HEAD
//som do oceano
somOceano = game.add.audio('somOceano');
somOceano.play();
=======
>>>>>>> AtividadeQuebraCabeca
ilhaTerror = game.add.sprite(W/5, H/5, 'ilhaTerror');
ilhaTerror.animations.add('ilhaTBrilha', [2, 3, 2, 3, 2, 3, 2, 0], 7, false);
......
var settingsMenu = function() {
var background;
var islandMapButton;
var goBack;
};
settingsMenu.prototype = {
loadScripts: function() {
game.load.script('MainMenu', 'states/MainMenu.js');
},
loadImages: function() {
game.load.image('background', "assets/level_select/background.jpg");
game.load.image('return_arrow', "assets/settings_menu/return_arrow.png");
},
preload: function() {
this.loadScripts();
this.loadImages();
},
create: function() {
game.state.add('MainMenu', MainMenu);
background = game.add.tileSprite(0, 0, window.innerWidth, window.innerHeight, 'background');
goBack = game.add.button(750, 550, 'return_arrow', this.toMainMenu, this, 0, 0, 0);
goBack.anchor.setTo(0.5, 0.5);
goBack.scale.setTo(0.8, 0.8);
},
dispose: function() {
goBack.destroy();
background.destroy();
},
toMainMenu: function() {
this.dispose();
game.state.start('MainMenu');
},
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment