• 「网易官方」极客战记(codecombat)攻略-游戏开发2-硬币游戏第 1 步:布局-game-of-coins-step-1-layout


                                                                                (点击图片进入关卡)

    让我们开始制作一个游戏。

    简介

    在接下来的几个关卡,我们将建立一个 PAC-MAN 风格的街机游戏。

    玩家的目标是收集所有的硬币。

    食人魔搜寻玩家,可以一击击败他们。

    会有一些能让玩家在短时间内击败食人魔(通过进入他们)的强力提升。

    分数是时间的基础,随着时间的推移,每一秒都会减少,所以这是一场与时间赛跑! 玩家还可以通过击败怪物,收集硬币和电源 UPS 来提高得分。

    在这个关卡,我们将从建造迷宫、英雄和收藏品开始。

    我们将使用 “森林” 的瓷砖在迷宫的网格,和'蘑菇'用于通电。

    使用键盘或鼠标进行播放器控制:

    1. W -> 上
    2. S -> 下
    3. A -> 左
    4. D -> 右
    5. 鼠标点击 -> 移动到点击处

    默认代码

    # 让我们开始建立一个新的PAC风格的街机游戏。
    # 我们将继续在下一个关卡进行制作游戏的工作。
    # 首先我们需要森林
    # 让我们在网格模式中产生一些“森林”瓦片。
    game.spawnXY("forest", 16, 16)
    game.spawnXY("forest", 32, 16)
    game.spawnXY("forest", 48, 16)
    game.spawnXY("forest", 64, 16)
    game.spawnXY("forest", 16, 32)
    game.spawnXY("forest", 32, 32)
    game.spawnXY("forest", 48, 32)
    game.spawnXY("forest", 64, 32)
    game.spawnXY("forest", 16, 48)
    # 正如你所看到的,它们之间的距离是16米。
    # 在三个地点产生更多的森林瓷砖
    # 他们消失的地方
    # 接下来,我们在森林中产生硬币。
    # 为蘑菇的动力发动留出空间!
    # 向下滚动,有很多硬币。
    game.spawnXY("bronze-coin", 16, 8)
    game.spawnXY("bronze-coin", 24, 8)
    game.spawnXY("bronze-coin", 32, 8)
    game.spawnXY("bronze-coin", 48, 8)
    game.spawnXY("bronze-coin", 56, 8)
    game.spawnXY("bronze-coin", 64, 8)
    game.spawnXY("bronze-coin", 72, 8)
    game.spawnXY("bronze-coin", 8, 16)
    game.spawnXY("bronze-coin", 24, 16)
    game.spawnXY("bronze-coin", 40, 16)
    game.spawnXY("bronze-coin", 56, 16)
    game.spawnXY("bronze-coin", 72, 16)
    game.spawnXY("bronze-coin", 8, 24)
    game.spawnXY("bronze-coin", 16, 24)
    game.spawnXY("bronze-coin", 24, 24)
    game.spawnXY("bronze-coin", 32, 24)
    game.spawnXY("bronze-coin", 40, 24)
    game.spawnXY("bronze-coin", 48, 24)
    game.spawnXY("bronze-coin", 56, 24)
    game.spawnXY("bronze-coin", 64, 24)
    game.spawnXY("bronze-coin", 72, 24)
    game.spawnXY("bronze-coin", 24, 32)
    game.spawnXY("bronze-coin", 56, 32)
    game.spawnXY("bronze-coin", 8, 40)
    game.spawnXY("bronze-coin", 16, 40)
    game.spawnXY("bronze-coin", 24, 40)
    game.spawnXY("bronze-coin", 32, 40)
    game.spawnXY("bronze-coin", 40, 40)
    game.spawnXY("bronze-coin", 48, 40)
    game.spawnXY("bronze-coin", 56, 40)
    game.spawnXY("bronze-coin", 64, 40)
    game.spawnXY("bronze-coin", 72, 40)
    game.spawnXY("bronze-coin", 8, 48)
    game.spawnXY("bronze-coin", 24, 48)
    game.spawnXY("bronze-coin", 40, 48)
    game.spawnXY("bronze-coin", 56, 48)
    game.spawnXY("bronze-coin", 72, 48)
    game.spawnXY("bronze-coin", 8, 56)
    game.spawnXY("bronze-coin", 16, 56)
    game.spawnXY("bronze-coin", 24, 56)
    game.spawnXY("bronze-coin", 32, 56)
    # 在空旷的地方长生更多的硬币。(相距8米)
    # 蘑菇将是我们的动力。
    game.spawnXY("mushroom", 40, 8)
    game.spawnXY("mushroom", 8, 32)
    # 产生更多蘑菇。
    # 玩家和目标设置
    player = game.spawnPlayerXY('knight', 8, 8)
    player.maxSpeed = 30
    game.addCollectGoal()
    # 现在测试你所做的以确保它运行。

    概览

    放置这么多物体可能很无聊。但是,它是游戏 DEV 程序的一部分。 别担心,你会在下一门课上学会如何自动化。 对于游戏,我们选择使用网格系统的硬币和森林瓷砖,因为对称是简单和美丽的。

    对于您未来的项目,您可以随心所欲地放置瓦片并获得有趣的布局。 关卡设计是关于创造力的。

    硬币游戏第 1 步:布局 解法

    # 让我们开始建立一个新的PAC风格的街机游戏。
    # 我们将继续在下一个关卡进行制作游戏的工作。
    # 首先我们需要森林
    # 让我们在网格模式中产生一些“森林”瓦片。
    game.spawnXY("forest", 16, 16)
    game.spawnXY("forest", 32, 16)
    game.spawnXY("forest", 48, 16)
    game.spawnXY("forest", 64, 16)
    game.spawnXY("forest", 16, 32)
    game.spawnXY("forest", 32, 32)
    game.spawnXY("forest", 48, 32)
    game.spawnXY("forest", 64, 32)
    game.spawnXY("forest", 16, 48)
    # 正如你所看到的,它们之间的距离是16米。
    # 在三个地点产生更多的森林瓷砖
    # 他们消失的地方
    game.spawnXY("forest", 32, 48)
    game.spawnXY("forest", 48, 48)
    game.spawnXY("forest", 64, 48)
    # 接下来,我们在森林中产生硬币。
    # 为蘑菇的动力发动留出空间!
    # 向下滚动,有很多硬币。
    game.spawnXY("bronze-coin", 16, 8)
    game.spawnXY("bronze-coin", 24, 8)
    game.spawnXY("bronze-coin", 32, 8)
    game.spawnXY("bronze-coin", 48, 8)
    game.spawnXY("bronze-coin", 56, 8)
    game.spawnXY("bronze-coin", 64, 8)
    game.spawnXY("bronze-coin", 72, 8)
    game.spawnXY("bronze-coin", 8, 16)
    game.spawnXY("bronze-coin", 24, 16)
    game.spawnXY("bronze-coin", 40, 16)
    game.spawnXY("bronze-coin", 56, 16)
    game.spawnXY("bronze-coin", 72, 16)
    game.spawnXY("bronze-coin", 8, 24)
    game.spawnXY("bronze-coin", 16, 24)
    game.spawnXY("bronze-coin", 24, 24)
    game.spawnXY("bronze-coin", 32, 24)
    game.spawnXY("bronze-coin", 40, 24)
    game.spawnXY("bronze-coin", 48, 24)
    game.spawnXY("bronze-coin", 56, 24)
    game.spawnXY("bronze-coin", 64, 24)
    game.spawnXY("bronze-coin", 72, 24)
    game.spawnXY("bronze-coin", 24, 32)
    game.spawnXY("bronze-coin", 56, 32)
    game.spawnXY("bronze-coin", 8, 40)
    game.spawnXY("bronze-coin", 16, 40)
    game.spawnXY("bronze-coin", 24, 40)
    game.spawnXY("bronze-coin", 32, 40)
    game.spawnXY("bronze-coin", 40, 40)
    game.spawnXY("bronze-coin", 48, 40)
    game.spawnXY("bronze-coin", 56, 40)
    game.spawnXY("bronze-coin", 64, 40)
    game.spawnXY("bronze-coin", 72, 40)
    game.spawnXY("bronze-coin", 8, 48)
    game.spawnXY("bronze-coin", 24, 48)
    game.spawnXY("bronze-coin", 40, 48)
    game.spawnXY("bronze-coin", 56, 48)
    game.spawnXY("bronze-coin", 72, 48)
    game.spawnXY("bronze-coin", 8, 56)
    game.spawnXY("bronze-coin", 16, 56)
    game.spawnXY("bronze-coin", 24, 56)
    game.spawnXY("bronze-coin", 32, 56)
    # 在空旷的地方长生更多的硬币。(相距8米)
    game.spawnXY("bronze-coin", 48, 56)
    game.spawnXY("bronze-coin", 56, 56)
    game.spawnXY("bronze-coin", 64, 56)
    game.spawnXY("bronze-coin", 72, 56)
    # 蘑菇将是我们的动力。
    game.spawnXY("mushroom", 40, 8)
    game.spawnXY("mushroom", 8, 32)
    # 产生更多蘑菇。
    game.spawnXY("mushroom", 72, 32)
    game.spawnXY("mushroom", 40, 56)
    # 玩家和目标设置
    player = game.spawnPlayerXY('knight', 8, 8)
    player.maxSpeed = 30
    game.addCollectGoal()
    # 现在测试你所做的以确保它运行。

    本攻略发于极客战记官方教学栏目,原文地址为:

    https://codecombat.163.com/news/jikezhanji-yingbiyouxibuju

    极客战记——学编程,用玩的!

  • 相关阅读:
    LINUX基础学习之基础命令(3)--2019-11-22
    LINUX基础学习之基础命令(2)--2019-11-18
    Linux基础学习之基础命令(1)--2019-11-14
    Linux系统的安装-2019-11-11
    Linux学习之路-基础入门 20191104
    linux下安装redis
    Hadoop(1):Centos 7 安装 Hadoop 3.2.1
    rsync 分发脚本
    Linux环境(Centos 7)安装MySQL数据库
    在已经安装好的Nginx上增加新模块
  • 原文地址:https://www.cnblogs.com/codecombat/p/12840935.html
Copyright © 2020-2023  润新知