愤怒的南瓜!使用ChatGPT-4 打造的万圣节游戏(附全部prompt和源码)

最近推特上一位开发者分享了自己使用ChatGPT创作的一款游戏,所有的代码都是用 GPT-4 写的,游戏中的图像则借助 Midjourney 和 DALL•E 3 制作而成。成功创建了一个名为“愤怒的南瓜?”的小游戏,而且整个开发过程下来,基本上动手写的代码为零。

我们知道,通过提供自然语言描述,GPT-4可以自动生成出功能完整的游戏逻辑代码。在图像方面,给出文本提示后,GPT-4就可以调用Dalle3输出适合游戏场景的高质量图像。

为了获得最佳效果,这位开发者采取了渐进的方式与GPT对话。他先让GPT-4实现游戏的核心机制,然后不断添加新功能并在出现问题时明确要求GPT-4改进自身。在图像生成上,通过细致的描述来指导GPT输出理想的视觉效果。

最终,这位开发者成功创建了一个集趣味和艺术于一体的万圣节小游戏。从开发过程来看,这也标志着AI在游戏制作领域的广泛应用新时代已经来临。未来,我们可能只需要通过语言描描述想法,就可以打造出高水准的游戏作品。

我们正在经历一个仅仅在科幻电影中才能看到的历史性时刻。现在,我们能够仅凭借自然语言创造出任何东西,这种全新的工作方式将彻底改变我们的世界。

下面是作者在创建这个游戏时使用到的prompt和源码,可以看一看,另外,你想先试试这个游戏吗?

点这里就能玩!(不过要注意,手机上可能玩不了):
https://bestaiprompts.art/angry-pumpkins/index.html

? 开场画面(由 GPT-4 提供的 DALL•E 3 制作)

  • “Photo of a horizontal vibrant home screen for a video game titled 'Angry Pumpkins'. The design is inspired by the 'Angry Birds' game aesthetic but different. Halloween elements like haunted houses, gravestones, and bats dominate the background. The game logo is prominently displayed at the center-top, with stylized pumpkin characters looking angry and ready for action on either side. A 'Play' button is located at the bottom center, surrounded by eerie mist”


背景设计(Midjourney 制作)

  • Angry birds skyline in iPhone screenshot, Halloween Edition, graveyard, in the style of light aquamarine and orange, neo-traditionalist, kerem beyit, earthworks, wood, Xbox 360 graphics, light pink and navy --ar 8:5。”

  • 另一张图片则用来做地面:“2d platform, stone bricks, Halloween, 2d video game terrain, 2d platformer, Halloween scenario, similar to angry birds, metal slug Halloween, screenshot, in-game asset --ar 8:5”

角色设计(Midjourney 制作)

  • "Halloween pumpkin, in-game sprite but Halloween edition, simple sprite, 2d, white background"

物品涉及(Midjourney 制作)

作者设计了多种“精灵样式”,然后利用 Photoshop/Photopea 对其进行裁剪和去背景处理。对于那些细小的部分,还使用了 Midjourney 的修复工具。

  • "Wooden box. Item assets sprites. White background. In-game sprites"
  • "Skeleton bone. Large skeleton bone. Item assets sprites. White background. In-game sprites"
  • "Rectangular stone. Item assets sprites. White background. In-game sprites"
  • "Wooden box. Large skeleton bone. Item assets sprites. White background. In-game sprites"
  • "Item assets sprites. Wooden planks. White background. In-game sprites. Similar to Angry Birds style"

GPT-4编码

查看完整源代码:https://bestaiprompts.art/angry-pumpkins/sketch.js

虽然这个游戏的代码只有 600 行,而且作一个字都没写,另外作者加入了很多细节,比如各种各样的粒子效果,不同种类的物体等等。到目前为止,GPT-4 还不能仅凭一个提示就生成整个游戏。但我相信,将来我们一定能够仅通过发出请求,就能制作出三A级别的视频游戏。

言归正传,现在的窍门在于,要循序渐进地向 GPT-4 提出请求。这其实和人类编程的方式相当类似:先从一个简单的可行的基础开始,然后不断迭代、拓展、优化代码。

下面是一些使用过的小技巧和示例提示:

? 先从简单的事情开始做起

  • "Can we now create a simple game using matter.js and p5.js in the style of "Angry Birds"? Just launch a ball with angle and force using the mouse and hit some stacked boxes with 2D physics

? 然后,不断地添加更多的元素和功能。每当遇到问题时,就详细说明错误所在,并让程序自我修正。记住,耐心是关键!例如:

  • "Now, I ask you: do you know how the birds are launched in Angry Birds? What the finger does on the screen? Exactly. Add this to the game, using the mouse."
  • "I have this error, please, fix it: Uncaught ReferenceError: Constraint is not defined"
  • "I would like to make a torch with particle effects. Can it be done with p5.js? Make one, please."
  • "Now, make the monsters circular, and be very careful: apply the same technique that already exists for the rectangular ones regarding scaling and collision area, and don't mess it up like before. ?"

? 我们(包括我和 GTP-4)为了这部分内容反复试验,付出了极大的耐心。

  • "There's something off with the logic that calculates when there's a strong impact on a bug. If the impact is direct, it works well, but not if it's indirect. For example, if I place a rectangle over two bugs and drop a box on the rectangle, even though the bugs should be affected by the impact, they don't notice it. What can we do to ensure they also get affected when things fall on top of a body they are under?"

讲到这里,祝你万圣节快乐!??


请使用浏览器的分享功能分享到微信等