Juego de la Serpiente
body { font-family: Arial, sans-serif; text-align: center; } #canvas { border: 1px solid black; }
Juego de la Serpiente
const canvas = document.getElementById('canvas'); const ctx = canvas.getContext('2d'); const gridSize = 20; const gridSizeX = canvas.width / gridSize; const gridSizeY = canvas.height / gridSize; let snake = [{ x: 5, y: 5 }]; let food = { x: 10, y: 10 }; let direction = 'right'; let isGameOver = false;
function drawSnake() { ctx.fillStyle = 'green'; snake.forEach(segment = { ctx.fillRect(segment.x * gridSize, segment.y * gridSize, gridSize, gridSize); }); }
function drawFood() { ctx.fillStyle = 'red'; ctx.fillRect(food.x * gridSize, food.y * gridSize, gridSize, gridSize); }
function checkCollision(x, y) { return snake.some(segment = segment.x === x && segment.y === y); }
function generateFood() { let newFoodX, newFoodY; do { newFoodX = Math.floor(Math.random() * gridSizeX); newFoodY = Math.floor(Math.random() * gridSizeY); } while (checkCollision(newFoodX, newFoodY)); food = { x: newFoodX, y: newFoodY }; }
function update() { if (isGameOver) return;
const head = { ...snake[0] };
switch (direction) { case 'up': head.y -= 1; break; case 'down': head.y += 1; break; case 'left': head.x -= 1; break; case 'right': head.x += 1; break; }
if (head.x === food.x && head.y === food.y) { snake.push(food); generateFood(); } else { snake.pop(); }
if ( head.x = gridSizeX || head.y = gridSizeY || checkCollision(head.x, head.y) ) { isGameOver = true; }
snake.unshift(head); }
function draw() { ctx.clearRect(0, 0, canvas.width, canvas.height);
drawSnake(); drawFood();
if (isGameOver) { ctx.fillStyle = 'black'; ctx.font = '30px Arial'; ctx.fillText('Game Over', canvas.width / 2 - 80, canvas.height / 2); return; }
update();
requestAnimationFrame(draw); }
document.addEventListener('keydown', event = { switch (event.key) { case 'ArrowUp': direction = 'up'; break; case 'ArrowDown': direction = 'down'; break; case 'ArrowLeft': direction = 'left'; break; case 'ArrowRight': direction =...
Read moreWe have been hearing about this place from friends for a while, and so we finally decided to check it out. I have to say we were pleasantly surprised with the quality and taste of the food. My husband, who is very picky about his chicken soup was raving about their chicken soup. I like that they have different menu soup options for every day of the week, I got the chupa which was the soup of the day, and it was very tasty. The bread that comes with each meal is wonderful, and it definitely wasn’t enough. It is a small portion that comes, so we ended up ordering another basket of it. Also, the Cachangas were very tasty as an appetizer! Great lunch spot!
I am docking a star for poor service because we asked for a table when we arrived and she told us that all the tables were full and we’d have to wait 45 minutes for a table so we accepted to sit at the bar. After being seated for only five minutes a table opened up and she made no offer to see us there even though I looked at her several times. Also, our requests were ignored several times and it took extra long for our other portion of bread to come, and my husband never got the extra onions he requested for his soup…typical lackadaisical latitude from staff around offering good service to clientele. Otherwise, the...
Read moreHi, I went there with the whole family. 5 adults and 3 children( the kids of 2.5 , 5 and 8 years old.) and our 70 year old mother, between 18.00 and 21.00 hours aprox of the 26.06.22. We had to wait until 1 hour and 30 min to get some food, first 1 hour waiting in the line and then another 30 min waiting for the waiters to find us a table and then to get it clean after repetitive complains from us to the waiter for letting others to jump over us in line because they didnt have an available table for 8 but for 2 persons. Seems like waiters are working under stress conditions and have no posibility to check availability of tables for number of customers per group prior check inn, there was not respect for the arrival order and priority. We became upset for not getting proper help by the crew members even when our 2 small kids fall asleep while waiting and our mother got phisically tired and there was not consideration for it from anyone working for the restaurant at all. Me and my brother had to tell the waiters what to do so we could finally get some food. We didn't get any apology for this after all. Despite this negative experience food was ok but not that good considering Lima is well known for the good quality of food in restaurants. We do not recomend this...
Read more