Hi to all
I'm newbie in the python and this is my first program in it.
I have created a board that it LEDs can on/off like the checkbox. and a Timeline that has 20 Frames for controlling the animation (Frames are like the RadioButton).
Can you help me :
- Frames would can save their Frames (on/off). (now they are saving all status to theirselve)
- this timeline would works as well for playing animation.
- Thank you for your replying!
-----
import pygame
pygame.init()
size = (800, 600)
screen = pygame.display.set_mode(size)
pygame.display.set_caption("Tablo")
black = ( 0, 0, 0)
white = ( 255, 255, 255)
green = ( 0, 255, 0)
red = ( 255, 0, 0)
blue = ( 0, 0, 255)
done = False
first_nps = True
first_kh = True
ni = 0
nj = 0
nps = 0
R = {}
F = 0
FC = {}
clock = pygame.time.Clock()
while done == False:
#Event processing:
for event in pygame.event.get():
if event.type == pygame.QUIT:
done = True
p = pygame.mouse.get_pos()
x = p[0]
y = p[1]
ms = pygame.mouse.get_pressed()
#Event processing
#Draw Table
for x_offest in range(0, 850, 50):
pygame.draw.line(screen, blue, (x_offest, 0), (x_offest, 400), 5)
for y_offest in range(0, 650, 50):
pygame.draw.line(screen, blue, (0 , y_offest), (800 , y_offest), 5)
pygame.draw.line(screen, black, (0 , 0 + 500), (800 , 500), 5)
#Draw Table
#on/off LEDs
if ms == (1,0,0):
for i in range(0, 800, 50):
for j in range(0, 400,50):
if x > i and x < i + 50 and y > j and y < j + 50:
ni = i / 50
nis = str(ni)
nj = j / 50
njs = str(nj)
nps = nis + njs
if R.has_key(nps) == 0:
pygame.draw.circle(screen, red, (i + 25, j+ 25), 20, 20)
R[nps] = 1
pygame.time.delay(200)
else:
pygame.draw.circle(screen, black, (i + 25, j + 25), 20, 20)
del R[nps]
pygame.time.delay(200)
pygame.display.flip()
#on/off LEDs
#Draw Timeline
for x_offest in range(0, 800, 40):
pygame.draw.line(screen, white, (x_offest, 450), (x_offest, 550), 4)
#Draw Timeline
if ms == (1,0,0) and x > x_offest and x < x_offest + 40 and y > 450 and y < 550:
fi = x_offest / 40
F = fi + 1
FC[F] = R
print FC
#Frames radio button
for gclearer in range(0, 800, 40):
pygame.draw.circle(screen, black, (gclearer + 20, 500), 15 , 4)
pygame.draw.circle(screen, green, (x_offest + 20, 500), 15 , 4)
#Frames radio button
pygame.time.delay(50)
pygame.display.flip()
pygame.display.flip()
clock.tick(25)