1.6
This commit is contained in:
parent
ee22e1a929
commit
88f618cadf
55 changed files with 1299 additions and 447 deletions
|
|
@ -37,9 +37,29 @@
|
|||
);
|
||||
}
|
||||
|
||||
function createRainWaterItem(worldRef) {
|
||||
const drop = new Item("water", rand(58, worldRef.w - 58), rand(58, worldRef.h - 58));
|
||||
drop.amount = rand(24, 58);
|
||||
function createRainWaterItem(worldRef, opts = {}) {
|
||||
const px = Number(opts?.x);
|
||||
const py = Number(opts?.y);
|
||||
const hasX = Number.isFinite(px);
|
||||
const hasY = Number.isFinite(py);
|
||||
const x = hasX ? px : rand(58, worldRef.w - 58);
|
||||
const y = hasY ? py : rand(58, worldRef.h - 58);
|
||||
const drop = new Item("water", x, y);
|
||||
const amount = Number(opts?.amount);
|
||||
drop.amount = Number.isFinite(amount) ? amount : rand(24, 58);
|
||||
// Rain drops, placed water drops, and water-balloon splashes all use the
|
||||
// same Item("water") object. Optional velocity only gives that same water
|
||||
// item a short ballistic motion; it is not a separate splash item type.
|
||||
const vx = Number(opts?.vx);
|
||||
const vy = Number(opts?.vy);
|
||||
if (Number.isFinite(vx) || Number.isFinite(vy)) {
|
||||
drop.prevX = drop.x;
|
||||
drop.prevY = drop.y;
|
||||
drop.vx = Number.isFinite(vx) ? vx : 0;
|
||||
drop.vy = Number.isFinite(vy) ? vy : 0;
|
||||
}
|
||||
const flight = Number(opts?.splashFlightTimer ?? opts?.flightTimer);
|
||||
if (Number.isFinite(flight) && flight > 0) drop.splashFlightTimer = flight;
|
||||
return drop;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue