马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本帖最后由 被诅咒的章鱼 于 2024-11-1 14:04 编辑
现在只做了一个效果,没有优化,以后会更新这个帖子。
视频:
【renpy制作实时按键控制人物移动功能】
script.rpy:
[RenPy] 纯文本查看 复制代码 label start:
init python:
#0不动 1向右 -1向左
#0不动 1向下 -1向上
status = [0,0
px = 0
py = 0
def changeStatus(d,s):
status[d] = s
def prt(m):
print(m)
def moveright():
global px
px += 3
def moveleft():
global px
px -= 3
def moveup():
global py
py -= 3
def movedown():
global py
py += 3
def update():
global status
if status[0 == 0:
pass
elif status[0 == 1:
moveright()
elif status[0 == -1:
moveleft()
if status[1 == 0:
pass
elif status[1 == 1:
movedown()
elif status[1 == -1:
moveup()
jump walk
return
customScreen.rpy:
[RenPy] 纯文本查看 复制代码 label walk:
call screen walk
return
screen walk:
timer 0.01 action Show("room")
timer 0.02 action Show("player")
timer 0.01 action Show("update")
screen player:
frame:
xysize(100,100)
xpos px
ypos py
background Solid("#ff0000")
screen room:
frame:
xysize(1920,1080)
background Solid("#ffffff")
screen update:
timer 0.02 action [Hide("update"),Function(update),Show("update")]
key "K_RIGHT" action Function(changeStatus,s=1,d=0)
key "keyup_K_RIGHT" action Function(changeStatus,s=0,d=0)
key "K_LEFT" action Function(changeStatus,s=2,d=0)
key "keyup_K_LEFT" action Function(changeStatus,s=0,d=0)
key "K_DOWN" action Function(changeStatus,s=1,d=1)
key "keyup_K_DOWN" action Function(changeStatus,s=0,d=1)
key "K_UP" action Function(changeStatus,s=2,d=1)
key "keyup_K_UP" action Function(changeStatus,s=0,d=1)
|