Fix fire effect in wren
This commit is contained in:
parent
4b09e54b64
commit
45efb366f3
|
@ -9,9 +9,11 @@ class Game is TIC{
|
|||
|
||||
construct new(){
|
||||
_t=0
|
||||
_width = 240
|
||||
_height = 136
|
||||
// Init to black
|
||||
_base = List.filled(240 * 136, 0)
|
||||
for (last_line in (240 * 135)...(240 * 136)) {
|
||||
_base = List.filled(_width * _height, 0)
|
||||
for (last_line in (_width * (_height-1))...(_width * _height)) {
|
||||
_base[last_line] = 15
|
||||
}
|
||||
_random = Random.new(12345)
|
||||
|
@ -19,26 +21,33 @@ class Game is TIC{
|
|||
}
|
||||
|
||||
dofire() {
|
||||
for (x in 0...240) {
|
||||
for (y in 135..1) {
|
||||
for (x in 0..._width) {
|
||||
for (y in 0...(_height-1)) {
|
||||
spreadfire(x, y)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
spreadfire(x, y) {
|
||||
var rand = _random.int(2)
|
||||
var delta = rand
|
||||
var index = x + y * 240
|
||||
_base[index - 240] = _base[index] - delta
|
||||
if (_base[index - 240] < 0) {
|
||||
_base[index - 240] = 0
|
||||
var rand = _random.int(4) // [0, 3]
|
||||
var delta = rand & 1
|
||||
var side = -rand+1 // [-2, 1]
|
||||
if (x+side < 0) {
|
||||
side=0
|
||||
}
|
||||
if (x+side >= _width) {
|
||||
side = 0
|
||||
}
|
||||
var index = x + (y*240)
|
||||
_base[index+side] = _base[index + _width] - delta
|
||||
if (_base[index+side] < 0) {
|
||||
_base[index+side] = 0
|
||||
}
|
||||
}
|
||||
|
||||
TIC(){
|
||||
for (y in 0...136) {
|
||||
for (x in 0...240) {
|
||||
for (y in 0..._height) {
|
||||
for (x in 0..._width) {
|
||||
TIC.pix(x, y, _base[x + y * 240])
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue