那些java沙子游戏如何跟踪这么多粒子? [英] How do those java sand games keep track of so many particles?

查看:97
本文介绍了那些java沙子游戏如何跟踪这么多粒子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以了解这样的程序是如何构建的吗?

Can anyone shed any light on how a program like that might be structured?

他们将使用哪些java类来跟踪这么多粒子然后检查它们用于碰撞检测等事情?粒子需要知道它们旁边是什么粒子,或者它们不是任何东西,所以它们可能会掉落等等。

What java classes would they employ to keep track of so many particles and then check against them for things like collision detection? Particles need to know what particles they are next to, or that they're not next to anything so they can fall etc.

这是一个例子,因为你不确定沙子游戏是什么。

Here's an example, incase you're not sure what a sand game is.

推荐答案

主要是阵列。


  • 一个主动移动的粒子的一维数组,用两个坐标表示(

  • 一个二维的bool(或颜色)数组,代表世界的固定部分。

最简单的物理模型是在谷物静止后移除谷物(例如,当世界位置在下方,左下方和右下方填充时):相反,填充相应的世界坐标。这使得计算可管理。如果世界坐标下方的左侧或右侧空闲,则允许谷物向下移动。移动谷物之间的谷物碰撞可以被忽略而不会失去太多的逼真度。

The simplest physics model is to remove a grain once it is at rest (e.g. when the world positions below, below to the left and below to the right are filled): instead, the corresponding world coordinate is filled in. This keeps the calculations manageable. Allow a grain to shift down if either the left or right below world coordinate is free. Grain collisions between moving grains can be ignored without loss of much verisimilitude.

(我不能完全了解这些天我们需要多少CPU功率! )

(I can't quite get over how much CPU power we've got to spare these days!)

这篇关于那些java沙子游戏如何跟踪这么多粒子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆