重现 Time Pilot 的自由卷轴动作 | Wireframe #41
穿越云层,体验我们对Konami经典1980s射击游戏的复刻之作。Mark Vanstone提供了代码。
-

由 Yoshiki Okamoto 设计的科乐美游戏 Time Pilot 于 1982 年在街机平台发行。
Time Pilot 堪称科乐美最成功的作品之一,于 1982 年登陆街机厅。Yoshiki Okamoto 曾秘密参与开发,其惊人的成功促使续作迅速跟进。在原版中,玩家需穿越五个时代:1910 年、1940 年、1970 年、1982 年,最后是遥远的未来:2001 年。飞机从双翼机开始,随着关卡推进,到最后一关自然就变成了 UFO。
玩家还可以在其他飞行员从飞机上跳伞时接住他们来拯救这些飞行员。玩家的飞机始终保持在屏幕中央,而其他游戏对象则在其周围移动。营造运动感的云层采用视差滚动效果,部分移动速度较快,从而营造出深度错觉。
要使用 Pygame Zero 制作我们自己的版本,我们需要八张玩家飞机的图像帧——对应它可飞行的每个方向。创建玩家 Actor 对象后,我们可以接收光标键的输入,并使用一个变量(范围设为 0 到 7,其中 0 代表向上方向)来改变飞机的朝向。在向屏幕绘制玩家之前,我们将 Actor 的图像设置为基础图像文件名再加上该变量...direction variable is at the time. That will give us a rotating aircraft.
为了提供运动感,我们添加了云层。我们可以在屏幕上生成一组随机云朵,并让它们朝与玩家飞机相反的方向移动。由于我们只有八个方向,可以使用查找表来更改 x 和 y 坐标,而不是计算移动值。当它们移出屏幕时,可以让它们从另一侧重新出现,从而形成一个“无限”的游戏区域。添加一个...level variable to the clouds, and we can move them at different speeds on each update() call, producing the parallax effect. Then we need enemies. They will need the same eight frames to move in all directions. For this sample, we will just make one biplane, but more could be made and added.

我们对科乐美街机经典致敬的 Python 作品。
要让敌机飞向玩家,我们需要一点数学知识。我们使用...math.atan2() function to work out the angle between the enemy and the player. We convert that to a direction which we set in the enemy Actor object, and set its image and movement according to that direction variable. We should now have the enemy swooping around the player, but we will also need some bullets. When we create bullets, we need to put them in a list so that we can update each one individually in our update(). When the player hits the fire button, we just need to make a new bullet Actor and append it to the bullets list. We give it a direction (the same as the player Actor) and send it on its way, updating its position in the same way as we have done with the other game objects.
最后一步是检测子弹命中。我们进行简单的点碰撞检测,如果匹配成功,就创建一个爆炸 Actor 并在其他地方重生敌人。在此示例中,我们没有编写任何用于清除旧子弹 Actor 的清理代码(如果不希望列表变得过长,应当添加此代码),但基本上你已经掌握了所有必要内容:你自己制作出了一个 Time Pilot 克隆版!

以下是 Mark 编写的 Time Pilot 风格自由卷轴射击游戏的代码。要在你的系统上运行它,你需要...安装Pygame Zero。要下载全部代码与资源文件,请点击此处。
获取你的 Wireframe 第 41 期副本
你可以在本期杂志中阅读更多类似内容Wireframe 第 41 期,可直接从树莓派出版社购买——我们提供全球配送。
如果你想要一份方便的电子版杂志,也可以免费下载第 41 期的PDF格式版本。

2条评论
哈里·哈吉诺
下载链接指向的是第 40 期,而不是第 41 期。
chupo_cro
我们在 80 年代初经常玩这款游戏。因为摇杆在右侧,我们必须交叉双手来操作;而且当时戴着手套,因为摇杆上有尖锐的毛刺(塑料球帽当然早就遗失了)。
评论已关闭