#<F11><F11:wq
import pygame 
from pygame.locals import *
from sys import exit
import random
import datetime
import time
filename="ojizousan2.png"
filename2="tesita2.png"
filename3="kougeki.png"
filename4="bougyo.png"
filename5="nigeru.png"
filename6="kougeki2.png"
filename7="bougyo2.png"
filename8="nigeru2.png"
filename9="waku2.png"
background_image_filename = 'j.png'
def sentou():
    pygame.init()
    background_image_filename = "sentou.png"
    screen = pygame.display.set_mode((640,480),0,32)
    background = pygame.image.load(background_image_filename).convert()
    jizou = pygame.image.load(filename).convert_alpha()
    tesita = pygame.image.load(filename2).convert_alpha()
    kou = pygame.image.load(filename3).convert_alpha()

    bou = pygame.image.load(filename4).convert_alpha()
    nige = pygame.image.load(filename5).convert_alpha()
    k2 = pygame.image.load(filename6).convert_alpha()

    b2 = pygame.image.load(filename7).convert_alpha()
    n2 = pygame.image.load(filename8).convert_alpha()
    waku = pygame.image.load(filename9).convert_alpha()
    x,y = 100, 200
    tesita_x,tesita_y = 400, 200
    move_x,move_y = 0, 0
    c = 1
    x2 =1
    y2 =1
    e =0
    playerpos=0
    j = 1
   
    while True:
        hp =16
        mp =10
        tuyosa = 5
        gp = 0
        keikenchi=0
        tesita_hp=10
        flag0=0
        flag1=0
        screen.blit(background,(0,0))
   
        screen.blit(jizou,(x,y))
        screen.blit(tesita,(tesita_x,tesita_y))
        font = pygame.font.Font(None,32)
        pygame.draw.rect(screen,(0,0,0),(20,20,150,150))
        pygame.draw.rect(screen,(0,0,0),(20,300,150,150))
        text = font.render(str(hp),False,(255,255,255))
        screen.blit(text,(30,120))
        text = font.render(str(mp),False,(255,255,255))
        screen.blit(text,(60,120))
        font = pygame.font.Font(None,32)
        text = font.render("HP",False,(255,255,255))
        screen.blit(text,(20,100))
        text = font.render("MP",False,(255,255,255))
        screen.blit(text,(60,100))
        screen.blit(kou,(60,300))
        screen.blit(bou,(60,350))
        screen.blit(nige,(60,400))
        background2 = [kou,bou,nige]
        pt = 300
        pd = 400
        bg=0
    
        #for i in range(3):
            #screen.blit(background2[i],(i*40,300,350,150))
        #playerpos = 2
        #pygame.draw.rect(screen,(0,0,0),(20,300,150,150),2)
        for event in pygame.event.get():
            #pygame.event.set_blocked([KEYDOWN,KEYUP])
            if event.type == QUIT:
                exit()
        if event.type == KEYDOWN:
            if event.key == K_ESCAPE:
                exit()
            elif event.key == K_UP :
                #if pt <= 300 and flag0==0:
                    playerpos = playerpos- 1
            elif event.key == K_DOWN: 
                    playerpos = playerpos+ 1

                    print("play2")
                    print(playerpos)
                    
        #screen.blit(background2[playerpos],(20,i*10))
        #screen[playerpos]=background2[playerpos]
        #playerpos = 2
        #screen.blit(waku,(20,playerpos*40))
        print("ddhhd")
        print(playerpos)
        print(event.type)
        #screen.blit(background2[playerpos],(20,playerpos*40))
        #playerpos = playerpos - 1
        screen.blit(waku,(60,400 + playerpos))
        """
        screen.blit(k2,(60,300))
        screen.blit(b2,(60,350))
        screen.blit(n2,(60,400))
        """
        """
        text = font.render("kougeki",False,(255,255,255))
        screen.blit(text,(60,300))
        text = font.render("bougyo",False,(255,255,255))
        screen.blit(text,(60,320))
        """
        def kougeki():
            r2 = int(r)
            if r2 >= 7:
                damege = tuyosa + 1
            elif r2 >= 3:
                damege = tuyosa + 3
            elif r2 >= 0:
                damege = tuyosa + 5
        pygame.display.update()
        
        

def up():
    pygame.draw.rect(screen,(255,255,255),(60,300,100,20),5)
def down():
    pygame.draw.rect(screen,(255,255,255),(60,300,100,20),5)
def bougyo():
        screen = pygame.display.set_mode((640,480),0,32)
        font = pygame.font.Font(None,32)
        text = font.render("bougyo",False,(255,255,255))
        screen.blit(text,(120,280))
        pygame.display.update()
sentou()
