Marco90v / culebra

Juego Snake

Home Page:https://marco90v.github.io/culebra/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Culebra / Serpiente / Snake

Juego simple realizado en Javascript en el año 2015 aproximadamente, del lado del HTML solo cuenta con un canvas.
La lógica y el dibujado se realiza desde JavaScript.

Juego

Clásico juego donde una serpiente debe comer una manzana, a medida que va comiendo va creciendo, si colisiona con los bordes o consigo mismo, pierde.
Si pierde solo debe presionar la tecla R y volverá a iniciar.
Para mover la serpiente use las flechas del teclado.

Código

La lógica del código consiste en tres objetos, donde almacenará la posición de los elementos, la posición de la manzana, la posición de la cabeza de la serpiente y el objeto que tendrá el cuerpo de la serpiente.
El objeto cuerpo almacenara la posición en la que se encuentra actualmente que será usado para dibujar en el canvas y la posición anterior, información que será usada cada vez que se agrega un elemento y/o mueva el cuerpo
Tiene funciones de donde se redibuja el canvas, verifica la tecla presionada, agrega nuevo elemento, verifica la colisión, cambia posición de la manzana.

Vista Previa

juego

Autor: Marco




Snake / Serpent / Snake

Simple game made in Javascript in the year 2015 approximately, the HTML side only has a canvas.
Logic and drawing is done from JavaScript.

Game

Classic game where a snake must eat an apple, as it eats it grows, if it collides with the edges or with itself, it loses.
If you lose, just press the R key and it will start again.
To move the snake use the arrows on the keyboard.

Code

The logic of the code consists of three objects, where it will store the position of the elements, the position of the apple, the position of the snake's head and the object that the snake's body will have.
The body object will store the current position that will be used to draw on the canvas and the previous position, information that will be used every time an element is added and/or the body is moved. It has functions where it redraws the canvas, checks the keystroke, adds new element, checks the collision, changes position of the apple.

Preview

juego

Author: Marco

About

Juego Snake

https://marco90v.github.io/culebra/


Languages

Language:TypeScript 75.6%Language:HTML 10.6%Language:JavaScript 7.0%Language:CSS 6.9%