#!/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(font_height)
        print(y)
    def bougyo(self,screen,background,text,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(font_height)
    
list1=[]
text = []
j = render()

while True:

    
    for event in pygame.event.get():
        if event.type == MOUSEBUTTONDOWN:
            exit()
        if event.type == KEYDOWN:
            j.hit(screen,background,y) 
            print(list1)
        if event.type == QUIT:
            j.bougyo(screen,background,text,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()
