Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Diagrama de Flujo .jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Diagrama de Flujo.pdf
Binary file not shown.
6 changes: 6 additions & 0 deletions your-project/.ipynb_checkpoints/Snake Game -checkpoint.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 5
}
185 changes: 185 additions & 0 deletions your-project/Proyecto_Snake.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
#------------Importar modulos---------------

import turtle
import time
import random

#--------------Variables--------------------
retraso = 0.1
score = 0
high_score = 0

#--------------Interfaz grafica --------------------

s = turtle.Screen()
s.setup(600,600)
s.bgcolor("black")
s.tracer(0)
s.title("Mini Project Snake")


#--------------Creacion de la cabeza--------------------

serpiente = turtle.Turtle()
serpiente.speed(1)
serpiente.shape("square")
serpiente.penup()
serpiente.goto(0,0)
serpiente.direction = "stop"
serpiente.color("SpringGreen4")


#--------------Creacion de comida --------------------

comida = turtle.Turtle()
comida.shape("circle")
comida.color("red2")
comida.penup()
comida.goto(0,100)
comida.speed(0)

#--------------Cuerpo de la serpiente --------------------
cuerpo = []

#--------------Marcador---------------------------------------------------------------------------

texto = turtle.Turtle()
texto.speed(0)
texto.color("white")
texto.penup()
texto.hideturtle()
texto.goto(-130, 250)
texto.write("Score: 0\tHigh Score : 0",align="center",font=("verdana", 10, "normal"))

#--------------Funciones--------------------------------------------------------------------------

def arriba():
serpiente.direction = "up"

def abajo():
serpiente.direction = "down"

def derecha():
serpiente.direction = "right"

def izquierda():
serpiente.direction = "left"


def movimiento():
if serpiente.direction == "up":
y = serpiente.ycor()
serpiente.sety(y+20)
if serpiente.direction == "down":
y = serpiente.ycor()
serpiente.sety(y-20)
if serpiente.direction == "right":
x = serpiente.xcor()
serpiente.setx(x+20)
if serpiente.direction == "left":
x = serpiente.xcor()
serpiente.setx(x-20)


#--------------Acciones del teclado------------------------------------------------------

s.listen()
s.onkeypress(arriba, "Up")
s.onkeypress(abajo, "Down")
s.onkeypress(izquierda, "Left")
s.onkeypress(derecha, "Right")

#--------------Acciones condicionadas del juego------------------------------------------------------------------

while True:
s.update()

#---------------------Colisiones con los bordes------------------------------------------------------------------------------

if serpiente.xcor() > 300 or serpiente.xcor() < -300 or serpiente.ycor() > 300 or serpiente.ycor() < -300:
time.sleep(2)
serpiente.goto(0,0)
serpiente.direction = "stop"

for i in cuerpo:
i.clear()
i.hideturtle()
serpiente.home()
serpiente.direction = "stop"
cuerpo.clear()

#-------------- Resetear Marcador ------------------------------------------------------------------

score = 0
texto.clear()
texto.write("Score:{} \tHigh Score:{}".format(score,high_score),align="center", font=("verdana", 10, "normal" ))


#---------------------Colisiones con la comida------------------------------------------------------------------------------

if serpiente.distance(comida) < 20:
x = random.randint(-250,250)
y = random.randint(-250,250)
comida.goto(x,y)

nuevo_cuerpo = turtle.Turtle()
nuevo_cuerpo.shape("square")
nuevo_cuerpo.color("SpringGreen2")
nuevo_cuerpo.penup()
nuevo_cuerpo.goto(0,0)
nuevo_cuerpo.speed(0)
cuerpo.append(nuevo_cuerpo)

#---------------------Aumentar marcador ------------------------------------------------------------------------------
score += 10
if score > high_score:
high_score = score
texto.clear()
texto.write("Score:{}\tHigh_score:{}".format(score,high_score),align="center", font=("verdana", 10, "normal" ))
else:
texto.clear()
texto.write("Score:{}\tHigh_score:{}".format(score,high_score),align="center", font=("verdana", 10, "normal" ))

#--------------Movimiento del cuerpo de la serpiente------------------------------------------------------------------

total = len(cuerpo)
for i in range(total -1,0,-1):
x = cuerpo[i-1].xcor()
y = cuerpo[i-1].ycor()
cuerpo[i].goto(x,y)

if total > 0:
x = serpiente.xcor()
y = serpiente.ycor()
cuerpo[0].goto(x,y)



movimiento()

#--------------------- Colisiones con el cuerpo ------------------------------------------------------------------------------

for i in cuerpo:
if i.distance(serpiente) < 20:
time.sleep(retraso)
for i in cuerpo:
i.clear()
i.hideturtle()
serpiente.home()
cuerpo.clear()
serpiente.direction = "stop"

#-------------- Resetear Marcador ------------------------------------------------------------------

score = 0
texto.clear()
texto.write("Score:{}\tHigh Score:{}".format(score,high_score),align="center", font=("verdana", 10, "normal" ))




time.sleep(retraso)

#-----------------Mantener la ventana abierta--------------------------------------

turtle.done()
64 changes: 43 additions & 21 deletions your-project/README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,56 @@
<img src="https://bit.ly/2VnXWr2" alt="Ironhack Logo" width="100"/>

# Title of Your Project
*[Your Name]*

*[Your Cohort, Campus & Date]*

## Content
- [Project Description](#project-description)
- [Rules](#rules)
- [Workflow](#workflow)
- [Organization](#organization)
- [Links](#links)
# Snake Game :snake:

Mini Proyecto de elaboración de un video juego.
Seleccionamos el juego de la culebra donde hemos puesto a prueba los conocimientos que hemos adquirido utilizando Python


# **Content** :scroll:

* [Project Description](#project-description)
* [Rules](#rules)
* [Workflow](#workflow)


## Project Description
Write a short description of your project. Write 1-2 sentences about what what you chose to build and why.

Recreación del famoso juego de la culebrita, utilizando el lenguaje de programación Python.Este es primer mini proyecto realizado para el Bootcamp de Data Analytics de Ironhack.


## Rules
Describe briefly the rules of the game you chose.

Las reglas son las siguientes:

Para moverte dentro del juego utiliza las teclas de dirección de tu teclado ← , ↑ , → , ↓

Aparecerán las manzanas dentro del tablero, tu objetivo es comerlas.

Por cada manzana que comas tu puntuación aumentara 10 puntos y también crecerá el cuerpo de la serpiente.

Recuerda, si chocas con las paredes o con una parte del cuerpo habras perdido.



## Workflow
Outline the workflow you used in your project. What are the steps you went through?

## Organization
How did you organize your work? Did you use any tools like a trello or kanban board?
Durante la ejecución de este proyecto se descompuso las acciones y eventos del juego en funciones para programarse utilizando el lenguaje de programación Python.

Se utilizaron modulos como:
* Turtle
* Time
* Random

![Diagrama de Flujo](Diagramadeflujo.jpg)

## Trello

Puedes revisar nuestra programación en https://trello.com/invite/b/Vc6eoOTX/8bb1e032d37c06a455b17e4d5ec201c0/programacion-del-videojuego


What does your repository look like? Explain your folder and file structure.
## Authors :pencil:

## Links
Include links to your repository, slides and trello/kanban board. Feel free to include any other links associated with your project.
- Odra Mathison
- Benjamin Kenyery

[Repository](https://github.com/)
[Slides](https://slides.com/)
[Trello](https://trello.com/en)
6 changes: 6 additions & 0 deletions your-project/Snake Game .ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 5
}