epic射击角色_动作游戏核心代码 pygame Shooting Character-Action Game Core Code

你好,请进入Q群:225792826,免费下载本站最新提供的视频教程原创源码资料,从2020年2月20号到3月底,成为本站会员只要原价的3折,即2980元*0.3 = 894元 ,向微信scratch8付款即可成为本站会员。即可拥有本站所有原创资源,并提供技术支持。如本消息修改,以最后时间的为准。

pygame游戏关卡制作器演示

下面是部分代码预览:

"""epic射击角色, 动作射击游戏基础核心源代码哦. 按鼠标射击,按a,d左右行走,按w拿枪攻击,按s倒地."""

__author__= "李兴球"
__date__ = "2019/6/8"
__blog__ = "www.lixingqiu.com"

import time
import pygame
from pygame.locals import *

class Actor:
    
    def __init__(self,right_frames,left_frames,screen):
        self.screen = screen
        self.sw = screen.get_width()
        self.sh = screen.get_height()
        self.right_frames = right_frames
        self.left_frames = left_frames
        self.frames = [right_frames,left_frames]
         
    def update(self):
        if time.time() - self.start_time > self.interval: # 超时则换造型
          

def main():

    width,height = 480,360
    screen = pygame.display.set_mode((width,height))
    pygame.display.set_caption("epic射击角色_动作游戏核心代码 www.lixingqiu.com")

    fighter = Actor(costumes_right,costumes_left,screen)
       
    clock = pygame.time.Clock()
    running = True
    while running:
        for event in pygame.event.get():
            if event.type == QUIT:running = False
            if event.type == KEYDOWN:
                if event.key == K_a:
                    fighter.heading = 1  # 向左
                    fighter.status = "run"
                    fighter.index = 48
                    fighter.speed = (-5,0)
                    
                if event.key == K_d:
                    fighter.heading = 0 # 向右
                    fighter.status = "run"
                    fighter.index = 48
                    fighter.speed = (5,0)
                    
                if event.key == K_w:
                    fighter.status = "up_attack"
                    fighter.index = 32
                    fighter.start_time = time.time()
                    
                    
                if event.key == K_s:
                    fighter.status = "hurt"
                    fighter.index = 16
                    fighter.start_time = time.time()
            if event.type == KEYUP:
                if event.key == K_a or event.key == K_d:
                   fighter.status = 'stand'
                   fighter.index = 0
                   fighter.speed = (0,0)
                    
            if event.type == MOUSEBUTTONDOWN:
                    fighter.status = "shoot"
                    fighter.index = 0
                    fighter.start_time = time.time()

        fighter.update()
        
        screen.blit(background,(0,0))
        screen.blit(fighter.image,fighter.rect)
        pygame.display.update()
        clock.tick(60)

    pygame.quit()

if __name__ == "__main__":

    main()               
                

 
如需要查看完整源代码,请扫码付款:

VIP免费查看

已有0人支付

本站所有作品,教程等皆为原创,盗版必究。一旦付款,表示同意本站知识付费原则:数字商品,不支持退款。亦可直接向微信号scratch8付款购买。QQ群免费教学群:225792826 (提供真实姓名可入群)
李兴球的博客_Python创意编程技术前沿 » epic射击角色_动作游戏核心代码 pygame Shooting Character-Action Game Core Code

学本领,探索更大的世界!

李兴球博客 风火轮编程主页