ADM-201 dump PMP dumps pdf SSCP exam materials CBAP exam sample questions

【用代数讲计算机科学】游戏里更新玩家状态 – 译学馆
未登录,请登录后再发表信息
最新评论 (0)
播放视频

【用代数讲计算机科学】游戏里更新玩家状态

CS in Algebra: Big Game Update Player

现在 你对于使用条件式已经很熟悉了让我们尝试一下在你的游戏中使用它们
Now that you’re more comfortable using conditionals, let’s try using them in your big game.
为了使角色小精灵响应你的键盘操作 我们需要使用一个条件式
In order to get the player sprite to respond to the keyboard, we’ll need to use a conditional
去核查哪个键被按下 然后向上或向下移动
to check which key was pressed and then move either up or down.
键盘上的每个键发送一个独一无二的叫做键控代码的数字到你的电脑上
Each key on your keyboard sends a unique number called a key code to your computer.
update-player(更新玩家状态)函数将接受键控代码和玩家目前的y坐标
The update-player function will take in that key code as well as the player’s current y
并且返回一个新坐标 这个坐标比原坐标大还是小
coordinate and return a new y coordinate that is either greater or less than the previous,
取决于按下的键
depending on key pressed.
如果你想要使用箭头键来移动你的角色 你需要勾选
If you want to use the arrow keys to move your player, you’ll need to check for key
键控代码38(上键)和键控代码40(下键)
code 38 for the up arrow and key code 40 for the down arrow.
如果你想要在你的游戏中使用不同的键 从你的学生用书上
If you want to use different keys for your game, check the key code reference sheet from
查看键控代码参考表
your student workbook.

发表评论

译制信息
视频概述
听录译者

收集自网络

翻译译者

谨之的猫

审核员

【MR】拾月

视频来源

https://www.youtube.com/watch?v=Ll_uL6Lj2QI

相关推荐