"""执剑女角色版本1之造型切换,动作游戏基础,本版本只是实现动作切换.,按a或d键实现方向的改变,按空格键实现重击造型变换,按鼠标键实现普通攻击。
完整的角色为,按鼠标键发普通攻击,会向前位移,按空格键为跃起,然后显示重击效果,并且落地时会有火花等。
"""
import time
import pygame
from pygame.locals import *
class Actor:
def __init__(self,right_frames,left_frames):
self.right_frames = right_frames
self.left_frames = left_frames
self.frames = [right_frames,left_frames]
self.heading = 0 # 为0表示朝向为右,使用初始是面向右系列造型
self.index = 0 # 初始状态系列造型中的索引为0的造型
def update(self):
if time.time() - self.start_time > self.interval: # 超时则换造型
if self.status == "attack":
if self.index < 4 :
self.index += 1
else:
self.status = "stand"
self.index = 0
if __name__ == "__main__":
width,height = 960,720
screen = pygame.display.set_mode((width,height))
pygame.display.set_caption("执剑女角色版本1之造型切换,动作游戏基础 www.lixingqiu.com")
girl = Actor(right_frames,left_frames)
clock = pygame.time.Clock()
running = True
while running:
for event in pygame.event.get():
if event.type == QUIT:running = False
screen.fill((0,0,0))
screen.blit(girl.image,girl.rect)
pygame.display.update()
clock.tick(60)
pygame.quit()
下载完整源代码与素材,请
需要浏览更多吗?
成为会员后,登陆才能继续浏览!联系微信scratch8即可办理会员。
(会员专属:能浏览所有文章,下载所有带链接的Python资源。)

