#!/usr/bin/env python

background_image_filename = 'f.jpg'
mouse_image_filename = 'fugu.png'

import pygame
from pygame.locals import *
from sys import exit

pygame.init()

screen = pygame.display.set_mode((640, 480), 0, 32)
pygame.display.set_caption("Hello, World!")

background = pygame.image.load(background_image_filename).convert()
mouse_cursor = pygame.image.load(mouse_image_filename).convert_alpha()
class render():
    y=0
    def hit(self,screen,background,y):
        font = pygame.font.Font(None,32)
        font_height = font.get_linesize()
        screen.blit(background, (0,0))
        list1.append("jizou no kougeki")
        for text in reversed(list1):
            screen.blit(font.render(text,True,(255,55,55)),(200,400-y))
            y += font_height
            print(text)
            print(list1)
    def bougyo(self,screen,background,y):
        font = pygame.font.Font(None,32)
        font_height = font.get_linesize()
        screen.blit(background, (0,0))
        list1.append("jizou no bougyo")
        for text in reversed(list1):
            screen.blit(font.render(text,True,(255,55,55)),(200,400-y))
            y += font_height
            print(text)
            print(list1)
        print(font_height)
    def nigeru(self,screen,background,y):
        font = pygame.font.Font(None,32)
        font_height = font.get_linesize()
        screen.blit(background, (0,0))
        list1.append("jizou no nigeru")
        for text in reversed(list1):
            screen.blit(font.render(text,True,(255,55,55)),(200,400-y))
            y += font_height
            print(text)
            print(list1)
    
list1=[]
text = []
j = render()

while True:

    
    for event in pygame.event.get(KEYDOWN):
        if event.key == K_0:
            exit()
        if event.key == K_1:
            j.hit(screen,background,y) 
            print(list1)
        if event.key == K_2:
            j.bougyo(screen,background,y)
        if event.key == K_3:
            j.nigeru(screen,background,y)

    x, y = pygame.mouse.get_pos()
    x-= mouse_cursor.get_width() / 2
    y-= mouse_cursor.get_height() / 2
    screen.blit(mouse_cursor, (x, y))
        
    pygame.display.update()
