- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以我是一个新程序员,正在修改/添加一些东西到已经制作的太空入侵者游戏中,以更熟悉游戏的编程方式。我正在尝试向游戏中添加作弊,但快速作弊给我带来了一些麻烦。当你选择快速射击并通过关卡时,游戏有时会在还剩下一些外星人的情况下提前触发notifyWin。这是因为有时两枪同时击中同一个敌人,使计算机认为有两个不同的敌人被杀死,因此有时会在“你赢了!”的同时留下一些外星人。屏幕弹出。当外星人计数达到 0 时触发胜利,对同一个敌人射击两次会减少外星人计数 2 而不是 1。我似乎无法弄清楚这一点。
// reduce the alient count, if there are none left, the player has won
alienCount--;
if (alienCount == 0)
{
notifyWin ();
}
这是射击与敌人碰撞的代码
/**
* Notification that this shot has collided with another
* entity
*
* @parma other The other entity with which we've collided
*/
public void collidedWith(Entity other) {
// prevents double kills, if we've already hit something,
// don't collide
if (used) {
return;
}
// if we've hit an alien, kill it!
if (other instanceof AlienEntity) {
// remove the affected entities
game.removeEntity(this);
game.removeEntity(other);
// notify the game that the alien has been killed
game.notifyAlienKilled();
used = true;
}
}
最佳答案
一种可能的解决方案是将敌人作为对象添加到列表中。当他们被 Gunicorn 后,将他们从名单中删除,并事先检查他们是否仍然在那里。当列表为空时执行notifyWin。这样,如果对敌人进行碰撞检测的逻辑产生太多命中,它仍然可以正常工作。
这个列表很可能已经存在,以便在屏幕上渲染敌人。
编辑:现在我看到了该方法,您可能只需在 collidedWith 顶部执行以下操作:
if (used || !game.containsEntity(other)) {
return;
}
其中方法 containsEntity 检查保存游戏参与者(实体)的内部列表或结构中实体是否存在。
关于Java Space Invaders Game Rapid Fire 作弊触发游戏获胜过早,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34348384/
我正在使用 rapids.ai 的 python 库我开始怀疑的关键事情之一是:如何以编程方式检查内存分配?我知道我可以使用 nvidia-smi 查看一些总体高级统计数据,但我特别想知道: 1) 是
Intel Rapid Start 是 Intel 公司研发的一种帮助笔记本电脑节省电源和快速恢复的技术,与传统的睡眠(Sleep)和休眠(Hibernate)有一定的区别,相较而言,与混合睡眠(H
我正在 Google Colab 上使用 CUML 0.10.0 库中的随机森林回归模型,但在获取模型预测时遇到问题。模型训练成功结束后,我使用 (.predict) 方法对一个非常大的数组 (416
我们有一个功能,可以让用户通过UI界面拖拽一个模块,形成一个数据处理流水线,比如读取数据,做预处理,做分类训练等等,拖拽之后,这些模块会是顺序执行。 每个模块都会启动一个容器(通过k8s)运行,上一个
我正在尝试在 Windows 计算机上运行 Nvidia rapids,但没有任何运气。我已经为 windows 安装了 docker 桌面并下载了 rapids 图像。已安装 Cuda 10.0,但
我是 Python 和 Rapids.AI 的新手,我正在尝试使用 Dask 和 RAPID 在多节点 GPU(我有 2 个 GPU)中重新创建 SKLearn KMeans(我正在使用 Rapids
我正在使用rapidminer,我有一个带有数值字段(属性)的数据集,我想简单地向该功能的所有值添加一个常量(例如1), 我该怎么做?到目前为止我还没有发现任何简单的事情。 最佳答案 使用数据转换 >
我正在开发一个实现后退/前进箭头导航的 Javascript slider 。我的问题是快速单击“前进”箭头会选择文本。 (尽管出于某种原因,当快速单击我的任何其他按钮时不会发生这种情况。)我基本上遇
如何为快速 SQL 备份/导出数据源? (可以输入rapidsql) 每个开发人员都需要设置自己的数据源或需要移动到不同的机器上,这很麻烦。 最佳答案 如果您运行的是更高版本之一,请选择“数据源”菜单
我没有注意到我的 GKE 集群位于快速 channel 中。直到今天我想添加节点池。 它显示节点版本“1.17.5-gke.6”不受支持。 https://cloud.google.com/kuber
所以我是一个新程序员,正在修改/添加一些东西到已经制作的太空入侵者游戏中,以更熟悉游戏的编程方式。我正在尝试向游戏中添加作弊,但快速作弊给我带来了一些麻烦。当你选择快速射击并通过关卡时,游戏有时会在还
我正在使用 CUDF它是 Nvidia 的 Rapids ML 套件的一部分。 使用这个套件我将如何做点积? df = cudf.DataFrame([('a', list(range(20))),
这很难解释,所以我举个例子: @Override public void start(Stage primaryStage) throws Exception { final VBox vbo
我正在使用 cocos2d 制作一个基于加速度计的应用程序,我注意到可以设置加速度计更新间隔。 [[UIAccelerometer sharedAccelerometer] setUpdateInte
我在 Windows 21H2 (19044.1348) 下安装了 WSL 2 (5.10.60.1-microsoft-standard-WSL2),并使用带有 pascal GPU (1070)
我正在尝试通过 Rapid Sql 在 Sybase15 数据库上运行查询。我收到错误消息,例如 -- Number (103) Severity (15) State (207) Server (s
谁能给我解释一下 Rapid Miner 中 k-means 的质心图到底意味着什么?我知道该图表可视化了每个特征相对于集群的质心值,但我需要专家提供一些更专业的解释。 例如,我有这样的问题:为什么簇
我刚开始使用 RAD for Websphere。在对 Java 代码进行一些更改后,我注意到服务器和部署在其上的 EAR 会显示类似“已启动,发布”的内容。今天我启动了我的服务器,它显示“Start
我想知道我是否可以安装 RAPIDS Google Colaboratory notebook 中的库(完全在 GPU 上执行机器学习任务)? 我已经做了一些研究,但我一直无法找到这样做的方法....
QuickFIX 登录问题:(使用 QuickFIX,在 Python 2.7 中使用 FIX 4.4) 一旦我执行initiator.start(),就会建立连接,并发送登录消息。但是,我没有看到代
我是一名优秀的程序员,十分优秀!