mirror of
https://github.com/klmp200/sarl-fireworks.git
synced 2024-12-28 02:31:12 +00:00
Add gravity and reduce fire size
This commit is contained in:
parent
8cece71f8f
commit
66e070e163
@ -31,10 +31,14 @@ agent Fire {
|
|||||||
var grid : Positions
|
var grid : Positions
|
||||||
var xf : Double
|
var xf : Double
|
||||||
var yf : Double
|
var yf : Double
|
||||||
|
var vx : Double
|
||||||
|
var vy : Double
|
||||||
var id = UUID.randomUUID
|
var id = UUID.randomUUID
|
||||||
var parentID : UUID
|
var parentID : UUID
|
||||||
var move : AgentTask
|
var move : AgentTask
|
||||||
var parentAgent : UUID
|
var parentAgent : UUID
|
||||||
|
var gravity: Double
|
||||||
|
var mass : Double
|
||||||
|
|
||||||
on Freeze {
|
on Freeze {
|
||||||
this.frozen = occurrence.value
|
this.frozen = occurrence.value
|
||||||
@ -47,11 +51,12 @@ agent Fire {
|
|||||||
on Initialize {
|
on Initialize {
|
||||||
x = new ArrayList()
|
x = new ArrayList()
|
||||||
y = new ArrayList()
|
y = new ArrayList()
|
||||||
if (occurrence.parameters.size.equals(4)) {
|
if (occurrence.parameters.size.equals(5)) {
|
||||||
x.add(occurrence.parameters.get(0) as Double)
|
x.add(occurrence.parameters.get(0) as Double)
|
||||||
y.add(occurrence.parameters.get(1) as Double)
|
y.add(occurrence.parameters.get(1) as Double)
|
||||||
grid = occurrence.parameters.get(2) as Positions
|
grid = occurrence.parameters.get(2) as Positions
|
||||||
parentID = occurrence.parameters.get(3) as UUID
|
parentID = occurrence.parameters.get(3) as UUID
|
||||||
|
gravity = occurrence.parameters.get(4) as Double
|
||||||
} else {
|
} else {
|
||||||
info("Error in fire Initialize : bad parameter number")
|
info("Error in fire Initialize : bad parameter number")
|
||||||
}
|
}
|
||||||
@ -60,6 +65,10 @@ agent Fire {
|
|||||||
xf = Math.random() * 10.0 - Math.random() * 5
|
xf = Math.random() * 10.0 - Math.random() * 5
|
||||||
yf = Math.random() * 10.0 + 1.0
|
yf = Math.random() * 10.0 + 1.0
|
||||||
|
|
||||||
|
vx = xf * 20.0
|
||||||
|
vy = yf * 30.0
|
||||||
|
|
||||||
|
mass = 10.0
|
||||||
}
|
}
|
||||||
|
|
||||||
on FireReady {
|
on FireReady {
|
||||||
@ -73,8 +82,14 @@ agent Fire {
|
|||||||
}
|
}
|
||||||
|
|
||||||
on UpdateFirePosition [isFromMe(occurrence) && !frozen && !destroyed] {
|
on UpdateFirePosition [isFromMe(occurrence) && !frozen && !destroyed] {
|
||||||
var newx = x.last + xf
|
var newx : Double
|
||||||
var newy = y.last + yf
|
var newy : Double
|
||||||
|
|
||||||
|
vy = vy - gravity * mass * Configuration.FireLifeCycleSchedulingRate / 100.0
|
||||||
|
|
||||||
|
newx = x.last + vx * Configuration.FireLifeCycleSchedulingRate / 1000.0
|
||||||
|
newy = y.last + vy * Configuration.FireLifeCycleSchedulingRate / 1000.0
|
||||||
|
|
||||||
x.add(newx)
|
x.add(newx)
|
||||||
y.add(newy)
|
y.add(newy)
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ agent Rocket {
|
|||||||
|
|
||||||
on Explode {
|
on Explode {
|
||||||
for (var i = 0; i < fireQuantity; i++) {
|
for (var i = 0; i < fireQuantity; i++) {
|
||||||
spawnInContext(Fire, innerContext, x, y, grid, id)
|
spawnInContext(Fire, innerContext, x, y, grid, id, gravity)
|
||||||
}
|
}
|
||||||
// emit(new Launch)
|
// emit(new Launch)
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ class FXMLViewerController implements EventListener {
|
|||||||
gc.setFill(fire.getColor());
|
gc.setFill(fire.getColor());
|
||||||
fire.getPositions().forEach(pos |
|
fire.getPositions().forEach(pos |
|
||||||
{
|
{
|
||||||
gc.fillOval(pos.get(0), pos.get(1), 5, 5);
|
gc.fillOval(pos.get(0), pos.get(1), 3, 3);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} catch (exception : Exception) {
|
} catch (exception : Exception) {
|
||||||
|
Loading…
Reference in New Issue
Block a user