Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Jogo - Caça Goblin</title>
</head>
<body>
<script>
// Criando o canvas
var canvas = document.createElement("canvas");
var context = canvas.getContext("2d");
canvas.width = 512;
canvas.height = 480;
document.body.appendChild(canvas);
// Imagem de Fundo
var backgroundPronto = false;
var backgroundImagem = new Image();
backgroundImagem.onload = function () {
backgroundPronto = true;
};
backgroundImagem.src = "http://bit.do/e8H6m";
// Heroi Imagem
var heroiPronto = false;
var heroiImage = new Image();
heroiImage.onload = function () {
heroiPronto = true;
};
heroiImage.src = "http://bit.do/e8H59";
// goblins Imagem
var goblinsProntos = false;
var goblinsImage = new Image();
goblinsImage.onload = function () {
goblinsProntos = true;
};
goblinsImage.src = "http://bit.do/e8H6g";
// Objetos do Jogo
var heroi = {
velocidade: 256 // movimentos em pixels por segundo
};
var goblins = {};
var goblinsCapturados = 0;
// Handle keyboard controls
var keysDown = {};
addEventListener("keydown", function (e) {
keysDown[e.keyCode] = true;
}, false);
addEventListener("keyup", function (e) {
delete keysDown[e.keyCode];
}, false);
// Reset o jogo quando o jogador pegar um goblins
var reset = function () {
heroi.x = canvas.width / 2;
heroi.y = canvas.height / 2;
// fazer os globins aparecerem aleatoriamente
goblins.x = 32 + (Math.random() * (canvas.width - 64));
goblins.y = 32 + (Math.random() * (canvas.height - 64));
};
// Atualiza os Objetos do Jogo
var update = function (modifier) {
if (38 in keysDown) { // Move para cima
heroi.y -= heroi.velocidade * modifier;
}
if (40 in keysDown) { //Move para baixo
heroi.y += heroi.velocidade * modifier;
}
if (37 in keysDown) { // Move para esquerda
heroi.x -= heroi.velocidade * modifier;
}
if (39 in keysDown) { // Move para direita
heroi.x += heroi.velocidade * modifier;
}
// Checkar colisao
if (
heroi.x <= (goblins.x + 32)
&& goblins.x <= (heroi.x + 32)
&& heroi.y <= (goblins.y + 32)
&& goblins.y <= (heroi.y + 32)
) {
++goblinsCapturados;
reset();
}
};
// Desenhando tudo
var render = function () {
if (backgroundPronto) {
context.drawImage(backgroundImagem, 0, 0);
}
if (heroiPronto) {
context.drawImage(heroiImage, heroi.x, heroi.y);
}
if (goblinsProntos) {
context.drawImage(goblinsImage, goblins.x, goblins.y);
}
// Score
context.fillStyle = "rgb(250, 250, 250)";
context.font = "24px Helvetica";
context.textAlign = "left";
context.textBaseline = "top";
context.fillText("Goblins capturados: " + goblinsCapturados, 32, 32);
};
// The principal game loop
var principal = function () {
var now = Date.now();
var delta = now - then;
update(delta / 1000);
render();
then = now;
};
// Rodar o Jogo
reset();
var then = Date.now();
setInterval(principal, 1); // Execute as fast as possible
</script>
</body>
</html>
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team