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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
venv/
__pycache__/
88 changes: 19 additions & 69 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,82 +1,32 @@
import pygame
from pygame.locals import *

import numpy as np

import parametros as pr
from parametros import *

from robotin import Robotin

pygame.init()
screen = pygame.display.set_mode((0,0),pygame.FULLSCREEN)


pestañeo = 0
cont = 0


run = 1
while run:
for event in pygame.event.get():
if event.type == KEYDOWN:
if event.key == K_ESCAPE:
run = 0

elif event.type == QUIT:
run = 0
screen.fill(COLOR_CARA)


cont += 1
if __name__ == '__main__':
pygame.init()
screen = pygame.display.set_mode((0,0),pygame.FULLSCREEN)

if cont > 1000:
if cont < 1000 + 60:
if cont%5 == 0:
pestañeo += OJO_STEP
elif cont < 1000 + 60 + 60:
if cont%5 == 0:
pestañeo -= OJO_STEP
if cont > 1000 + 60 + 60:
pestañeo = 0
cont = 0

robotin = Robotin()

clock = pygame.time.Clock()

run = 1
while run:
clock.tick(FRAMERATE)
for event in pygame.event.get():
if event.type == KEYDOWN:
if event.key == K_ESCAPE:
run = 0

punto = pygame.mouse.get_pos()
x = (SCREEN_WIDTH - punto[0])/80
y = (SCREEN_HEIGHT - punto[1])/80



pygame.draw.ellipse(screen, (0, 0, 0),
Rect(SCREEN_WIDTH/2 - PASO_W*3 - x*3, SCREEN_HEIGHT/2 - PASO_H*2 + pestañeo - y*3,
OJO_ANCHO, OJO_ALTO - pestañeo*2))

pygame.draw.ellipse(screen, (0, 0, 0),
Rect(SCREEN_WIDTH/2 + PASO_W*3 - OJO_ANCHO - x*3, SCREEN_HEIGHT/2 - PASO_H*2 + pestañeo - y*3,
OJO_ANCHO, OJO_ALTO - pestañeo*2))

pygame.draw.ellipse(screen, (0, 0, 0),
Rect(SCREEN_WIDTH/2-90 - x, SCREEN_HEIGHT/2 - y,
180, 100))

pygame.draw.ellipse(screen, COLOR_CARA,
Rect(SCREEN_WIDTH/2-70 - x, SCREEN_HEIGHT/2 - y,
140, 80))

pygame.draw.rect(screen, COLOR_CARA,
Rect(SCREEN_WIDTH/2-90 - x, SCREEN_HEIGHT/2 - y,
180, 50))

pygame.draw.ellipse(screen, (0, 0, 0),
Rect(SCREEN_WIDTH/2-90 - x, SCREEN_HEIGHT/2+40 - y,
22, 20))

pygame.draw.ellipse(screen, (0, 0, 0),
Rect(SCREEN_WIDTH/2+90-22 - x, SCREEN_HEIGHT/2+40 - y,
22, 20))
elif event.type == QUIT:
run = 0

screen.fill(COLOR_CARA)

robotin.update()
robotin.draw(screen)

pygame.display.flip()
pygame.display.flip()
1 change: 1 addition & 0 deletions parametros.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

pygame.init()

FRAMERATE = 60

SCREEN_WIDTH = pygame.display.Info().current_w
SCREEN_HEIGHT = pygame.display.Info().current_h
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
numpy==1.23.3
pygame==2.1.2
63 changes: 63 additions & 0 deletions robotin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
from parametros import *
from pygame.locals import Rect

class Robotin:
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

self.pestaneo = 0
self.contador = 0

def update(self):
self.contador += 1
self.pestanear()

def draw(self, screen):
# Get mouse position
punto = pygame.mouse.get_pos()
x = (SCREEN_WIDTH - punto[0])/80
y = (SCREEN_HEIGHT - punto[1])/80


pygame.draw.ellipse(screen, (0, 0, 0),
Rect(SCREEN_WIDTH/2 - PASO_W*3 - x*3, SCREEN_HEIGHT/2 - PASO_H*2 + self.pestaneo - y*3,
OJO_ANCHO, OJO_ALTO - self.pestaneo*2))

pygame.draw.ellipse(screen, (0, 0, 0),
Rect(SCREEN_WIDTH/2 + PASO_W*3 - OJO_ANCHO - x*3, SCREEN_HEIGHT/2 - PASO_H*2 + self.pestaneo - y*3,
OJO_ANCHO, OJO_ALTO - self.pestaneo*2))

pygame.draw.ellipse(screen, (0, 0, 0),
Rect(SCREEN_WIDTH/2-90 - x, SCREEN_HEIGHT/2 - y,
180, 100))

pygame.draw.ellipse(screen, COLOR_CARA,
Rect(SCREEN_WIDTH/2-70 - x, SCREEN_HEIGHT/2 - y,
140, 80))

pygame.draw.rect(screen, COLOR_CARA,
Rect(SCREEN_WIDTH/2-90 - x, SCREEN_HEIGHT/2 - y,
180, 50))

pygame.draw.ellipse(screen, (0, 0, 0),
Rect(SCREEN_WIDTH/2-90 - x, SCREEN_HEIGHT/2+40 - y,
22, 20))

pygame.draw.ellipse(screen, (0, 0, 0),
Rect(SCREEN_WIDTH/2+90-22 - x, SCREEN_HEIGHT/2+40 - y,
22, 20))



def pestanear(self):
if self.contador > 1000:
if self.contador < 1000 + 60:
if self.contador % 5 == 0:
self.pestaneo += OJO_STEP
elif self.contador < 1000 + 120:
if self.contador % 5 == 0:
self.pestaneo -= OJO_STEP
if self.contador > 1000 + 120:
self.pestaneo = 0
self.contador = 0