Created
July 25, 2011 09:57
-
-
Save esehara/1103851 to your computer and use it in GitHub Desktop.
VJ ROBOT KUN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:utf-8 -*- | |
import pygame | |
from pygame.locals import * | |
import random | |
import time | |
def main(): | |
pygame.init() | |
screen = pygame.display.set_mode((640,480),pygame.FULLSCREEN) | |
pygame.display.set_caption("Denki") | |
clock = pygame.time.Clock() | |
click = 1; | |
animation = False | |
mono = False | |
effect_kind = 0 | |
effect_time = 0 | |
while 1: | |
clock.tick(60) | |
if not animation: | |
if not mono: | |
font = pygame.font.Font(None,random.randint(1,256)) | |
text = font.render(str(click), False, (random.randint(1,255),random.randint(1,255),random.randint(1,255))) | |
else: | |
font = pygame.font.Font(None,24) | |
text = font.render(str(click), False, (255,255,255)) | |
screen.blit(text, (random.randint(-256,640),random.randint(-256,480))) | |
click += 1 | |
else: | |
if effect_kind == 1: | |
pygame.draw.rect(screen,(random.randint(1,255),random.randint(1,255),random.randint(1,255)),Rect(0,0,640,240 - effect_time)) | |
pygame.draw.rect(screen,(random.randint(1,255),random.randint(1,255),random.randint(1,255)),Rect(0,240 + effect_time,640,480 - effect_time)) | |
effect_time -= 10 | |
if effect_kind == 2: | |
pygame.draw.circle(screen,(random.randint(1,255),random.randint(1,255),random.randint(1,255)),(320,240),640 - effect_time) | |
effect_time -= 20 | |
if effect_kind == 3: | |
pygame.draw.rect(screen,(random.randint(1,255),random.randint(1,255),random.randint(1,255)),Rect(320 - effect_time,320 - effect_time,320 - effect_time,320 - effect_time)) | |
time.sleep(0.15) | |
effect_time -= 30 | |
if effect_time < 0: | |
animation = False | |
if not mono: | |
pygame.draw.rect(screen,(random.randint(1,255),random.randint(1,255),random.randint(1,255)),Rect(random.randint(1,640),random.randint(1,480),random.randint(1,640),random.randint(1,480))) | |
pygame.display.flip() | |
if random.randint(1,500) == 2: | |
pygame.draw.rect(screen,(0,0,0),Rect(0,0,640,480)) | |
if not mono: | |
mono = True | |
else: | |
mono = False | |
if random.randint(1,100) == 2: | |
animation = True | |
effect_time = 240 | |
effect_kind = 1 | |
if random.randint(1,50) == 2: | |
effect_time = 320 | |
effect_kind = 3 | |
if random.randint(1,100) == 3: | |
animation = True | |
effect_time = 640 | |
effect_kind = 2 | |
for event in pygame.event.get(): | |
if event.type == QUIT: | |
return | |
if (event.type == KEYDOWN and | |
event.key == K_ESCAPE): | |
return | |
if event.type == KEYDOWN: | |
if event.key == K_UP: | |
click += 1 | |
if event.key == K_DOWN: | |
click -= 1 | |
if event.key == K_SPACE: | |
animation = True | |
effect_time = 240 | |
effect_kind = 1 | |
if event.key == K_RETURN: | |
animation = True | |
effect_time = 640 | |
effect_kind = 2 | |
if __name__ == '__main__':main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment