[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] help with clock
- To: pygame-users@xxxxxxxx
- Subject: [pygame] help with clock
- From: Silver <rockachu2@xxxxxxxxx>
- Date: Tue, 08 May 2012 20:30:35 -0700
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Tue, 08 May 2012 23:30:47 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :x-enigmail-version:content-type; bh=3iaTSqy2hSVUzFxp3mw+8M+i5P85RMFstlqNfDWAaHw=; b=HD276CiMQBDjhwvHDSjudLUAp8GDKL/Yfsmc8taQkJWP/IvvqVvTtvDI1Dca1roGiX 4UUm2TUMvAiyY1PjCJKcl1zp+9hvQ86xlaGhvAwOrPXXBQKN7Glx8k6E1AzF7bYbK6ED FHwq/Td7K7ErG8w6Rv0KZzIAJ4DeUdXapkjHKxdhexe7a/Vc4xppwnD+EVrYXns48REy Yti5Ctjga5WkHcmFWuMsB5pyP1gUZ52YfMskq9jfSyCq7v294bNYX1IvPR0trHuTjmO6 J4MaqqzljzqcnQXHGAmR2pLRpS/p9SMNTgE8/nvEY28SyjNfpn+Mey7qPORRSMSXkIpt cWrQ==
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
- User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1
I wrote a small clock program that I might use if it turns out well, but
I am having a small issue where the top of the arcs that grow over time
shifts when I would like it to stay still. Does anyone know how to
achieve this?
from pygame import *
import time, math
import pygame, sys
def timeintoms():
t = time.time()
#print t
t %= 24*60*60
#print t, "Time since last day"
t *= 1000
#print t, "Milliseconds"
return t
def draw_arc(surface, color,pos, radius, width, angle1, angle2):
angle2 -= math.pi/2
angle1 += math.pi/2
pygame.draw.arc(surface, color, (pos[0], pos[1], radius, radius), -angle2, angle1, width)
pygame.init()
screen = pygame.display.set_mode((200,200))
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
raise SystemExit
screen.fill((0,0,0))
t = timeintoms()
s = t / 1000
m = s / (60)
h = m / (12)
s %= 60
m %= 60
h %= 12
#print(str(h)+":"+str(m)+":"+str(s))
angleg = math.radians((s / 60)*360)
angleb = math.radians((m / 60)*360)
angleo = math.radians((h / 12)*360)
angle1 = 0
#print(angleg-angle1)
draw_arc(screen, (21,176,26), (0,0), 200, 10, angle1, angleg)
draw_arc(screen, (3,67,223), (20,20), 160, 10, angle1, angleb)
draw_arc(screen, (249,115,6), (40,40), 120, 10, angle1, angleo)
pygame.display.update()