🏝️ 阳炎竞技场大冒险:太阳能争夺战!
欢迎来到太阳岛!在这里,红色闪电队与蓝色浪潮队的机器海龟将为了争夺宝贵的太阳能展开对决。
🏆 获胜条件
- 直接胜利:让对手机器海龟的能量降到0(关机)。
- 积分胜利:比赛结束时,拥有太阳能总积分更多的一方获胜。
🗺️ 地图与移动
- 网格世界:每个格子边长2米。
- 移动:海龟可向上下左右移动。
moveRight(1) 移动4米(2格)。
- 💀 危险边界:如果海龟移动到地图四个边角,会直接断电输掉比赛!
☀️ 核心玩法:太阳能板
- 建造:走过的地方会自动放下太阳能板。
- 升级:走在自己的板子上可以升级它(产出更多能量)。
- 占领:走在对手的板子上会将其占领(重置为1级)。
- 圈地:用太阳能板围成一个圈,圈内空地会自动填满你的板子!
☁️ 环境与道具
- 宝藏:每2秒刷新电池。医疗电池(加血)、加速电池(加速)、太阳能电池(根据现有能量按比例奖励)。
- 乌云:进入阴影会持续掉血。
- 传送门:走进一个门,会从另一个门出来,方向不变。
👇 向下滚动查看所有 API 方法详解与代码示例
🚀 基础行动 (Movement)
hero.moveForward(times)
沿着上次的方向移动 4 * times 米。
移动
参数: times (正整数)
# 向当前朝向移动 12米 (3个单位)
hero.moveForward(3)
// 向当前朝向移动 12米 (3个单位)
hero.moveForward(3);
hero.moveUp(times)
将你的机器人乌龟移动到北方(上方向)4 * times 米。
移动
参数: times (正整数)
# 向北移动 4米
hero.moveUp(1)
// 向北移动 4米
hero.moveUp(1);
hero.moveDown(times)
将你的角色移动到 4 * times 米向南 (下方向)。
移动
参数: times (正整数)
# 向南移动,深入地球核心
hero.moveDown(2)
// 向南移动
hero.moveDown(2);
hero.turn(direction)
改变方向:"up", "down", "right" 或 "left"。这个指令不会暂停,不花费时间。
转向
参数: direction (字符串)
# 转向右边,准备发射水枪
hero.turn("right")
// 转向右边
hero.turn("right");
⚡ 战斗技能 (Combat Abilities)
注意:所有技能使用前建议检查 isReady。
hero.isReady(ability)
检查特殊能力 ability 是否准备好使用(冷却结束且能量足够)。
返回值: boolean
if hero.isReady("waterGun"):
hero.ability("waterGun")
if (hero.isReady("waterGun")) {
hero.ability("waterGun");
}
hero.ability(abilityName)
如果机器乌龟的特殊能力冷却结束,施放该特殊能力。通用施法函数。
技能来源: Robot Turtle
# 施放一个通用的技能,例如 shockTrap
hero.ability("shockTrap")
// 施放技能
hero.ability("shockTrap");
hero.ability("shockTrap")
电击陷阱:留下一个电击陷阱,若对手接近将启动电击,令对手不能动弹并且受损。消耗当前太阳能量的一部分。
Zap!
# 在关键路口放置陷阱
if hero.isReady("shockTrap"):
hero.ability("shockTrap")
// 放置陷阱
if (hero.isReady("shockTrap")) {
hero.ability("shockTrap");
}
hero.ability("waterGun")
高压水枪:朝当前方向发射水弹,击中敌人会造成伤害并减速。距离越远,伤害和减速越强。消耗当前太阳能量百分比。
嗖嗖!
# 先转向敌人,再射击
hero.turn("right")
hero.ability("waterGun")
// 射击
hero.turn("right");
hero.ability("waterGun");
hero.ability("shockThrow", x, y)
电击飞球:向目标位置(x, y)投掷电击球。落地爆炸,对范围目标造成伤害并眩晕。消耗当前太阳能量。
滋啦!
# 向地图中心 (40, 30) 投掷炸弹
hero.ability("shockThrow", 40, 30)
// 向指定坐标投掷
hero.ability("shockThrow", 40, 30);
hero.ability("robotCrab")
机器蟹工兵:制造一个机器蟹,沿直线行走并铺设太阳能板。撞到任何东西会爆炸。与其他技能(如shockThrow)接触时会触发连锁爆炸。
咔嗒咔嗒嘭!
# 释放机器蟹去开疆拓土
if hero.isReady("robotCrab"):
hero.ability("robotCrab")
// 释放机器蟹
if (hero.isReady("robotCrab")) {
hero.ability("robotCrab");
}
📡 属性与感知 (Properties & Sensing)
hero properties (只读)
你和对手机器龟的可用属性。
color: 队伍颜色
x, y: 坐标位置
direction: "up", "down", "left", "right"
angle: 弧度 (0右, PI/2上, PI左)
speed: 当前速度
health / maxHealth: 生命值
solar: 当前太阳能
# 获取当前坐标和能量
my_x = hero.x
my_y = hero.y
energy = hero.solar
// 获取当前坐标和能量
float myX = hero.x;
float myY = hero.y;
int energy = hero.solar;
hero.opponent
你的对手引用。你可以读取他们的属性(如 health, x, y 等)。
类型: Object
enemy = hero.opponent
if enemy:
hero.say("我看到你了,坐标 " + enemy.x)
auto enemy = hero.opponent;
if (enemy) {
// 在C++中访问属性
float ex = enemy.x;
}
hero.time
当前游戏时间。
# 前10秒采取防御策略
if hero.time < 10:
pass
// 检查时间
if (hero.time < 10) {
// ...
}
hero.distanceTo(target)
返回到目标的距离(米)。
返回值: number
enemy = hero.opponent
if enemy and hero.distanceTo(enemy) < 10:
hero.ability("waterGun")
auto enemy = hero.opponent;
if (enemy && hero.distanceTo(enemy) < 10) {
hero.ability("waterGun");
}
hero.getSolarMap()
返回岛上太阳能板的二维数组地图。0=无板, 1=红队, -1=蓝队。行是Y,列是X。
返回值: array (2D)
map = hero.getSolarMap()
# 访问坐标 (5, 5) 的情况
cell = map[5][5]
auto map = hero.getSolarMap();
// C++中通常通过hero.solarAtXY直接查询更方便
hero.solarAtXY(x, y)
返回 {x, y} 点的太阳能板状态。0=无,正数=我方等级,负数=敌方等级(绝对值表示等级)。
注:原文描述为"岩浆状态"可能是笔误,实际对应太阳能板归属与等级。
返回值: number
val = hero.solarAtXY(hero.x, hero.y)
if val == 0:
hero.say("这里是空地")
float val = hero.solarAtXY(hero.x, hero.y);
if (val < 0) {
hero.say("这是敌人的领地!");
}
🎁 物品与环境 (Items & Environment)
hero.findNearestItem()
找到并返回最近的物品(电池)。如果没有物品则返回 null。
返回值: object (Item)
item = hero.findNearestItem()
if item:
hero.moveXY(item.x, item.y)
auto item = hero.findNearestItem();
if (item) {
// 假设有moveXY或移动逻辑
hero.moveUp(1);
}
hero.findItems()
找到和返回当前场上所有物品的数组。
返回值: array
items = hero.findItems()
for item in items:
hero.say("发现电池!")
auto items = hero.findItems();
// C++ 遍历示例
if (items.size() > 0) {
// ...
}
hero.findShadows()
返回场上当前所有乌云阴影的数组。每个阴影对象包含属性:
x, y: 阴影坐标
lifespan: 阴影剩余持续时间
返回值: array
shadows = hero.findShadows()
for shadow in shadows:
if hero.distanceTo(shadow) < 5:
hero.say("小心乌云!")
auto shadows = hero.findShadows();
if (shadows.size() > 0) {
// 避开阴影逻辑
}
hero.findPortals()
返回场上当前所有传送门的数组。每个传送门对象包含属性:
x, y: 传送门坐标
target: 该门通向的目标传送门对象
返回值: array
portals = hero.findPortals()
if len(portals) > 0:
p = portals[0]
hero.say("传送门通往: " + p.target.x)
auto portals = hero.findPortals();
// 访问传送门属性逻辑
hero.findCrabs()
返回场上当前所有机器蟹工兵的数组。每个机器蟹包含属性:
x, y: 坐标
direction: 行走方向
speed: 行走速度
color: 队伍颜色
返回值: array
crabs = hero.findCrabs()
for crab in crabs:
if crab.color != hero.color:
hero.ability("waterGun")
auto crabs = hero.findCrabs();
// 寻找敌方机器蟹并攻击