Пример #1
0
    def __init__(self):
        pygame.init()
        screen = pygame.display.set_mode(SCR_RECT.size)
        pygame.display.set_caption("zibanyan game")

        p1 = Object()
        x = p1.randx()

        y = p1.randy()

        sysfont = pygame.font.SysFont(None, 30)

        sysfont_b = pygame.font.SysFont(None, 80)
        sysfont_c = pygame.font.SysFont(None, 79)

        HP = sysfont.render("HP", True, (0, 0, 0))
        clear_b = sysfont_b.render("COURSE CLEAR!", True, (0, 0, 0))
        clear = sysfont_c.render("COURSE CLEAR!", True, (255, 183, 76))

        # 画像のロード
        Zibanyan.left_image = load_image(
            "C:\Users\sakamoto\Desktop\pythongame\zibanyan.png", -1)  # 左向き
        Zibanyan.right_image = pygame.transform.flip(Zibanyan.left_image, 1,
                                                     0)  # 右向き
        Tyokoboimage = load_image(
            "C:\Users\sakamoto\Desktop\pythongame\yokobo.png", -1)
        Medal = load_image("C:\Users\sakamoto\Desktop\pythongame\medal.png",
                           -1)
        Uisu = load_image("C:\Users\sakamoto\Desktop\pythongame\uisu.png", -1)

        global jump_sound
        jump_sound = pygame.mixer.Sound("jump01.wav")

        global get_sound
        get_sound = pygame.mixer.Sound("get.wav")

        global get_level
        get_level = pygame.mixer.Sound("get_level.wav")

        self.all = pygame.sprite.RenderUpdates()
        Zibanyan.containers = self.all
        Zibanyan()

        # メインループ
        clock = pygame.time.Clock()
        add = 1
        count = 0
        add_point = 0
        tyokobo_count = 0

        ran_mx = random.randint(300, 500)

        ran = random.randint(1, 100)

        tyoko_x_ran = random.randint(1, 300)

        ran_u = random.randint(1, 100)

        ran_x = random.randint(300, 500)
        level_sound = 0

        count_m = 0
        count_t = 0
        count_u = 0

        sound_m = 0
        sound_t = 0
        sound_u = 0

        while True:
            clock.tick(60)
            self.update()
            self.draw(screen)
            screen.blit(HP, (10, 5))

            pygame.draw.line(screen, (0, 0, 0), (50, 15), (200, 15), 8)

            pygame.draw.line(screen, (50, 204, 18), (50, 15),
                             (100 + add_point, 15), 8)

            medal_x = x + ran_mx
            medal_y = y + ran + add

            tyoko_x = x + tyoko_x_ran
            tyoko_y = y + add

            uisu_x = x + ran_x
            uisu_y = y + ran_u + add

            if math.fabs((medal_x / 6) - zibax) < 60 and math.fabs(medal_y -
                                                                   zibay) < 60:
                sound_m += 1
                count_m = 1
                if sound_m == 1:
                    get_sound.play()
                    add_point += 30

            if math.fabs((tyoko_x / 6) - zibax) < 80 and math.fabs(tyoko_y -
                                                                   zibay) < 70:
                sound_t += 1
                count_t = 1
                if sound_t == 1:
                    get_sound.play()
                    add_point += 50

    #uisu
            if math.fabs(uisu_x - zibax) < 20 and math.fabs(uisu_y -
                                                            zibay) < 60:
                sound_u += 1
                count_u = 1
                if sound_u == 1:
                    get_sound.play()
                    add_point += 20

            if count_m == 0 and count_t == 0 and count_u == 0:
                screen.blit(Tyokoboimage, (x, y + add))
                screen.blit(Medal, (x + ran, y + ran + add))
                screen.blit(Uisu, (x + ran_x, y + ran_u + add))

            if count_m == 0 and count_t == 1 and count_u == 0:
                screen.blit(Medal, (x + ran, y + ran + add))
                screen.blit(Uisu, (x + ran_x, y + ran_u + add))

            if count_t == 0 and count_m == 1 and count_u == 0:
                screen.blit(Tyokoboimage, (x, y + add))
                screen.blit(Uisu, (x + ran_x, y + ran_u + add))

            if count_u == 1 and count_m == 0 and count_t == 0:
                screen.blit(Medal, (x + ran, y + ran + add))
                screen.blit(Tyokoboimage, (x, y + add))

            if count_u == 1 and count_m == 0 and count_t == 1:
                screen.blit(Medal, (x + ran, y + ran + add))

            if count_u == 1 and count_t == 0 and count_m == 1:
                screen.blit(Tyokoboimage, (x, y + add))

            if count_u == 0 and count_t == 1 and count_m == 1:
                screen.blit(Uisu, (x + ran_x, y + ran_u + add))

            if count_m == 1 and count_t == 1 and count_u == 1:
                screen.blit(clear_b, (50, 240))
                screen.blit(clear, (50, 240))

                level_sound += 1
                if level_sound == 1:
                    get_level.play()

            pygame.display.update()
            self.key_handler()
            add += 0.5
Пример #2
0
    def __init__(self):
        pygame.init()
        screen = pygame.display.set_mode(SCR_RECT.size)
        pygame.display.set_caption("zibanyan game")
        
        p1 = Object()
    	x = p1.randx()
 
        y = p1.randy()
     
     
        sysfont = pygame.font.SysFont(None, 30)
        hello2 = sysfont.render("power", True, (0,0,0))
        hello3 = sysfont.render("clear", True, (0,0,0))
 
 
        # 画像のロード
    	Zibanyan.left_image = load_image("C:\Users\sakamoto\Desktop\pythongame\zibanyan.png", -1)                     # 左向き
    	Zibanyan.right_image = pygame.transform.flip(Zibanyan.left_image, 1, 0)  # 右向き
    	Tyokoboimage = load_image("C:\Users\sakamoto\Desktop\pythongame\yokobo.png", -1)  
    	Medal = load_image("C:\Users\sakamoto\Desktop\pythongame\medal.png", -1)
    	Uisu = load_image("C:\Users\sakamoto\Desktop\pythongame\uisu.png", -1)

	global jump_sound
	jump_sound = pygame.mixer.Sound("jump01.wav")
	
	global get_sound
	get_sound = pygame.mixer.Sound("get.wav")


	global get_level
	get_level = pygame.mixer.Sound("get_level.wav")
	
	self.all = pygame.sprite.RenderUpdates()
    	Zibanyan.containers = self.all
    	Zibanyan()
         
        # メインループ
    	clock = pygame.time.Clock()
    	add = 1
    	count = 0
    	add_point = 0;
    	tyokobo_count = 0;
    	ran = random.randint(1,100)
    	ran_u = random.randint(1,100)
 
	ran_x = random.randint(100,300)
	level_sound = 0
 
 
	count_m = 0
    	count_t = 0
    	count_u = 0

    	dele    = 64
 
        while True:
            clock.tick(60)
            self.update()
            self.draw(screen)
            screen.blit(Tyokoboimage, (0,5))
            screen.blit(hello2, (20,5))
            pygame.draw.line(screen, (0,0,0), (85,15), (300 + add_point,15), 8)
             
 
 
            if math.fabs(x+ran - zibax) < 20  and math.fabs(y +ran + add  - zibay) < 60:
	    	    get_sound.play()
	    	    count_m = 1
                    add_point = 5
 
            if math.fabs(x - zibax) < 20  and math.fabs(y + add  - zibay) < 60:
	    	    get_sound.play()
		    count_t = 1
                    add_point = 10
 
    #uisu
            if math.fabs(x+ran_x - zibax) < 20  and math.fabs(y +ran_u + add  - zibay) < 60:
	    	    get_sound.play()

		    count_u = 1
                    add_point = -50
         
            if count_m == 0 and  count_t == 0 and count_u ==0:      
                    screen.blit(Tyokoboimage, (x,y + add))
                    screen.blit(Medal, (x+ran,y+ran + add ))
                    screen.blit(Uisu, (x+ran_x,y+ran_u + add ))
         
            if count_m == 0 and count_t == 1 and count_u ==0:
                    screen.blit(Medal, (x+ran,y+ran + add ))
                    screen.blit(Uisu, (x+ran_x,y+ran_u + add ))
 
 
            if count_t == 0 and count_m == 1 and count_u ==0:
                    screen.blit(Tyokoboimage, (x,y + add))
                    screen.blit(Uisu, (x+ran_x,y+ran_u + add ))
         
            if  count_u ==1 and count_m == 0 and count_t == 0:
                    screen.blit(Medal, (x+ran,y+ran + add ))
                    screen.blit(Tyokoboimage, (x,y + add))
 
            if  count_u ==1 and count_m == 0 and count_t == 1:
                    screen.blit(Medal, (x+ran,y+ran + add ))
 
 
            if  count_u ==1 and count_t == 0 and count_m == 1:
                    screen.blit(Tyokoboimage, (x,y + add))
     
            if  count_u ==0 and count_t == 1 and count_m == 1:
                    screen.blit(Uisu, (x+ran_x,y+ran_u + add ))

 
            if count_m == 1 and  count_t == 1 and count_u ==1:  
                    screen.blit(hello3, (50,240))
                    level_sound += 1
		    if level_sound == 1:
                    	get_level.play()

                     
            pygame.display.update()
            self.key_handler()
            add += 0.5
Пример #3
0
    def __init__(self):
        pygame.init()
        screen = pygame.display.set_mode(SCR_RECT.size)
        pygame.display.set_caption("zibanyan game")

        p1 = Object()
        x = p1.randx()

        y = p1.randy()

        sysfont = pygame.font.SysFont(None, 30)
        hello2 = sysfont.render("power", True, (0, 0, 0))
        hello3 = sysfont.render("clear", True, (0, 0, 0))

        # 画像のロード
        Zibanyan.left_image = load_image(
            "C:\Users\sakamoto\Desktop\pythongame\zibanyan.png", -1)  # 左向き
        Zibanyan.right_image = pygame.transform.flip(Zibanyan.left_image, 1,
                                                     0)  # 右向き
        Tyokoboimage = load_image(
            "C:\Users\sakamoto\Desktop\pythongame\yokobo.png", -1)
        Medal = load_image("C:\Users\sakamoto\Desktop\pythongame\medal.png",
                           -1)
        Uisu = load_image("C:\Users\sakamoto\Desktop\pythongame\uisu.png", -1)

        global jump_sound
        jump_sound = pygame.mixer.Sound("jump01.wav")

        global get_sound
        get_sound = pygame.mixer.Sound("get.wav")

        global get_level
        get_level = pygame.mixer.Sound("get_level.wav")

        self.all = pygame.sprite.RenderUpdates()
        Zibanyan.containers = self.all
        Zibanyan()

        # メインループ
        clock = pygame.time.Clock()
        add = 1
        count = 0
        add_point = 0
        tyokobo_count = 0
        ran = random.randint(1, 100)
        ran_u = random.randint(1, 100)

        ran_x = random.randint(100, 300)
        level_sound = 0

        count_m = 0
        count_t = 0
        count_u = 0

        dele = 64

        while True:
            clock.tick(60)
            self.update()
            self.draw(screen)
            screen.blit(Tyokoboimage, (0, 5))
            screen.blit(hello2, (20, 5))
            pygame.draw.line(screen, (0, 0, 0), (85, 15),
                             (300 + add_point, 15), 8)

            if math.fabs(x + ran - zibax) < 20 and math.fabs(y + ran + add -
                                                             zibay) < 60:
                get_sound.play()
                count_m = 1
                add_point = 5

            if math.fabs(x - zibax) < 20 and math.fabs(y + add - zibay) < 60:
                get_sound.play()
                count_t = 1
                add_point = 10

    #uisu
            if math.fabs(x + ran_x - zibax) < 20 and math.fabs(
                    y + ran_u + add - zibay) < 60:
                get_sound.play()

                count_u = 1
                add_point = -50

            if count_m == 0 and count_t == 0 and count_u == 0:
                screen.blit(Tyokoboimage, (x, y + add))
                screen.blit(Medal, (x + ran, y + ran + add))
                screen.blit(Uisu, (x + ran_x, y + ran_u + add))

            if count_m == 0 and count_t == 1 and count_u == 0:
                screen.blit(Medal, (x + ran, y + ran + add))
                screen.blit(Uisu, (x + ran_x, y + ran_u + add))

            if count_t == 0 and count_m == 1 and count_u == 0:
                screen.blit(Tyokoboimage, (x, y + add))
                screen.blit(Uisu, (x + ran_x, y + ran_u + add))

            if count_u == 1 and count_m == 0 and count_t == 0:
                screen.blit(Medal, (x + ran, y + ran + add))
                screen.blit(Tyokoboimage, (x, y + add))

            if count_u == 1 and count_m == 0 and count_t == 1:
                screen.blit(Medal, (x + ran, y + ran + add))

            if count_u == 1 and count_t == 0 and count_m == 1:
                screen.blit(Tyokoboimage, (x, y + add))

            if count_u == 0 and count_t == 1 and count_m == 1:
                screen.blit(Uisu, (x + ran_x, y + ran_u + add))

            if count_m == 1 and count_t == 1 and count_u == 1:
                screen.blit(hello3, (50, 240))
                level_sound += 1
                if level_sound == 1:
                    get_level.play()

            pygame.display.update()
            self.key_handler()
            add += 0.5
Пример #4
0
    def __init__(self):
        pygame.init()
        screen = pygame.display.set_mode(SCR_RECT.size)
        pygame.display.set_caption("zibanyan and tyokobo")
       
        p1 = Object()
	x = p1.randx()

  	y = p1.randy()
	
	
	sysfont = pygame.font.SysFont(None, 30)
	hello2 = sysfont.render("power", True, (0,0,0))
	hello3 = sysfont.render("clear", True, (0,0,0))


        # 画像のロード
        Zibanyan.left_image = load_image("C:\Users\sakamoto\Desktop\pythongame\zibanyan.png", -1)                     # 左向き
        Zibanyan.right_image = pygame.transform.flip(Zibanyan.left_image, 1, 0)  # 右向き
	Tyokoboimage = load_image("C:\Users\sakamoto\Desktop\pythongame\yokobo.png", -1)  
        Medal = load_image("C:\Users\sakamoto\Desktop\pythongame\medal.png", -1)

	self.all = pygame.sprite.RenderUpdates()
        Zibanyan.containers = self.all
        Zibanyan()
        
        # メインループ
        clock = pygame.time.Clock()
 	add = 1
	count = 0
	add_point = 0;
	tyokobo_count = 0;
  	ran = random.randint(1,100)
  	count_m = 0
        count_t = 0
  	while True:
            clock.tick(60)
            self.update()
            self.draw(screen)
            screen.blit(Tyokoboimage, (0,5))
            screen.blit(hello2, (20,5))
            pygame.draw.line(screen, (0,0,0), (85,15), (300 + add_point,15), 8)


	
	    if math.fabs(x+ran - zibax) < 10  and math.fabs(y +ran + add  - zibay) < 30:
	    	    count_m = 1
	    	    add_point = 5

	    if math.fabs(x - zibax) < 10  and math.fabs(y + add  - zibay) < 30:
	    	    count_t = 1
	    	    add_point = 10
	    
	    if count_m == 0 and  count_t == 0:	    
	    	    screen.blit(Tyokoboimage, (x,y + add))
	    	    screen.blit(Medal, (x+ran,y+ran + add ))

	    
	    if count_m == 0 and count_t == 1:
	    	    pygame.draw.rect(screen, (255,255,255), Rect(x ,y + add,32,32))
	    	    screen.blit(Medal, (x+ran,y+ran + add ))

	    if count_t == 0 and count_m == 1:
	    	   pygame.draw.rect(screen, (255,255,255), Rect(x+ran,y +ran+ add,32,32))
	    	   screen.blit(Tyokoboimage, (x,y + add))

	    
	    if count_m == 1 and  count_t == 1:	
		    screen.blit(hello3, (50,240))
	   

            pygame.display.update()
            self.key_handler()
	    add += 0.5