我们使用一些必要的Cookie来确保网站正常运行。

我们使用可选的 Cookie,具体详情请参阅我们的Cookie政策,用于记住您的设置并了解您如何使用我们的网站。

编写向 Bubble Bobble 致敬之作 | Wireframe #56

在我们的这款街机经典致敬作品中吹泡泡并戳破它们。在最新一期《线框图》杂志Wireframe 中,Mark Vanstone 分享了代码.

Bubble Bobble 于 1986 年发布,看起来与当时街机厅里的任何游戏都大不相同。这款游戏由 Taito 的 Fukio Mitsuji 设计,是一款合作游戏,两名玩家控制一对龙 Bub 和 Bob,吹出泡泡困住敌人,然后再将泡泡戳破。这样能制服里面的敌人并释放加分道具,收集后可以获得额外分数。与当时众多的射击、驾驶和格斗游戏不同,Bubble Bobble 是一款卡通风格、吸引力广泛的游戏;Mitsuji 在后来的采访中表示,他希望这款游戏能被情侣们一起享受。也许这正是 Bubble Bobble 成为 Taito 大热之作的部分原因,并且至今仍是其移植范围最广、最令人怀念的 1980 年代游戏之一。

Bubble Bobble arcade
Bubble Bobble 为我们带来了整整 100 个关卡去探索。

在本月的 Pygame Zero 示例中,我们将专注于游戏中的泡泡机制,看看如何发射、推动和戳破在关卡中漂浮的泡泡。首先,我们需要一组平台供我们的小龙在上面跑动。在这个示例中我们保持简单:一圈围墙和三排平台,可以用一个简单的嵌套循环来定义。每个平台方块都是 Actors,我们在启动 main program 之前把它们放进一个 list。Ourdraw() function is quite simple, drawing our background, then the platforms, our bubbles, and finally Bub, our little dragon.

为了让 Bub 移动,我们可以在 the 中检测 arrow keys。update() function. We cycle through three frames to make him walk along the platforms and then apply some gravity to him so that if he walks off the end, he’ll fall down to the next level. To get Bub jumping, we use the on_key_down() function and test to see if he’s on the ground, and if so, set the Bub Actor property ‘jump’ to 60, which will set off upward motion for 60 frames – at which point Bub will start falling back down as our gravity check takes over again.

现在来说泡泡

现在来说泡泡。我们检测 theSPACE bar being pressed, create a new bubble, and add it to a list. To start with, it will fly out horizontally in the direction Bub is facing. We can check how far it has travelled with the status property of the new bubble. After the status property reaches zero, we stop the bubble moving horizontally and let it rise upwards using the driftx and drifty properties. We can change these properties at random to give the bubble a bit more of an uncertain direction. We can also reverse the properties to make the bubble bounce off the side and top walls. We check all the bubbles each frame to make sure they aren’t colliding with any other bubbles, too.

我们对经典 Bubble Bobble 的致敬。没有怪物,但泡泡漂浮与破裂的机制非常到位

我们还需要检测 Bub 与任意泡泡之间的碰撞。如果他撞到泡泡,就会推着泡泡走;但如果他跳起来用背刺碰到泡泡,泡泡就会破裂。泡泡还有一个 timer 属性,意味着过一段时间泡泡会自行爆裂。这就是泡泡的基本原理——你可能还想添加一些怪物和供 Bub 收集的好东西,或者让平台更复杂。像往常一样,我们留给你来实现。

下面是 Mark 的代码,它用 Python 重现了 Bubble Bobble 吹泡泡与戳破泡泡的机制。你可以在以下网址找到完整说明:wfmag.cc/pgzero。完整的代码清单请见点击这里

获取你的 Wireframe issue 56

你可以在本期杂志中阅读更多类似内容Wireframe第5期6,可直接通过Raspberry Pi Press官网订购——我们支持全球配送。

若你还希望获得一份便捷的数字版杂志,也可同时订阅。免费下载 issue 56PDF格式。

3条评论

Ina avatar

哈!我还记得那款游戏——没错,我那么老了。我弟弟以前常玩这个。那时我对游戏没那么感兴趣,但我对能在显示器上控制东西感到很着迷。这是我现在的孩子无法理解的。我见过幼儿试图滑动电视节目,他们就是如此原生的数字一代。很好奇这对他们的学习、信息消费等方面会产生什么影响。
Greetings!

Thetechonly avatar

这款游戏真的很酷,我以前玩过。

JioSaavn Mod Apk avatar

这是一款非常酷的游戏

评论已关闭