-
Notifications
You must be signed in to change notification settings - Fork 0
/
Reloj.py
68 lines (55 loc) · 1.74 KB
/
Reloj.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Fri Oct 6 10:04:49 2017
@author: terevaldivia
"""
import os
from CC3501Utils_personal import *
pi = 3.1415
fps = 60
clock = pygame.time.Clock()
class Reloj(Figura):
#variables de instancia del palito
tamano = 24.
segundo = 0.
x_palito = 0
y_palito = tamano #posiciones iniciales
seg_final = 30
def __init__(self, pos=Vector(0, 0), rgb=(1.0, 1.0, 1.0)):
super(Reloj, self).__init__(pos, rgb)
def figura(self):
#Base circular
glBegin(GL_TRIANGLE_FAN)
glColor3f(47 / 255.0, 79 / 255.0, 79 / 255.0)
glVertex2f(0.0, 0.0)
radio1 = 30
ang = 2 * pi / 20
for i in range(20):
ang_i = ang * i
glVertex2f(cos(ang_i) * radio1, sin(ang_i) * radio1)
glVertex2f(1.0 * radio1, 0.0)
glEnd()
#Circulo interior
glBegin(GL_TRIANGLE_FAN)
glColor3f(97 / 255.0, 218 / 255.0, 137 / 255.0)
glVertex2f(0.0, 0.0)
radio2 = 24
ang = 2 * pi / 20
for i in range(20):
ang_i = ang * i
glVertex2f(cos(ang_i) * radio2, sin(ang_i) * radio2)
glVertex2f(1.0 * radio2, 0.0)
glEnd()
#palillo: que sea actualizable con variables de instancia afuera
glBegin(GL_LINES)
glColor3f(0 / 255.0, 0 / 255.0, 0 / 255.0) #negro?
glVertex2f(0.0, 0.0)
glVertex2f(self.x_palito, self.y_palito)
glEnd()
def update(self, fps):
self.segundo += 1./fps
if self.segundo >= self.seg_final:
return
self.x_palito = self.tamano * sin(pi * self.segundo / 30.)
self.y_palito = self.tamano * cos(pi * self.segundo / 30.)