83 lines
2 KiB
Plaintext
83 lines
2 KiB
Plaintext
// title: Doom Fire
|
|
// author: Fabien Freling
|
|
// desc: inspired by https://fabiensanglard.net/doom_fire_psx/
|
|
// script: wren
|
|
|
|
import "random" for Random
|
|
|
|
class Game is TIC{
|
|
|
|
construct new(){
|
|
_t=0
|
|
_width = 240
|
|
_height = 136
|
|
// Init to black
|
|
_base = List.filled(_width * _height, 0)
|
|
for (last_line in (_width * (_height-1))...(_width * _height)) {
|
|
_base[last_line] = 15
|
|
}
|
|
_random = Random.new(12345)
|
|
TIC.cls(0)
|
|
}
|
|
|
|
dofire() {
|
|
for (x in 0..._width) {
|
|
for (y in 0...(_height-1)) {
|
|
spreadfire(x, y)
|
|
}
|
|
}
|
|
}
|
|
|
|
spreadfire(x, y) {
|
|
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..._height) {
|
|
for (x in 0..._width) {
|
|
TIC.pix(x, y, _base[x + y * 240])
|
|
}
|
|
}
|
|
dofire()
|
|
_t=_t+1
|
|
}
|
|
}
|
|
// <TILES>
|
|
// 001:efffffffff222222f8888888f8222222f8fffffff8ff0ffff8ff0ffff8ff0fff
|
|
// 002:fffffeee2222ffee88880fee22280feefff80fff0ff80f0f0ff80f0f0ff80f0f
|
|
// 003:efffffffff222222f8888888f8222222f8fffffff8fffffff8ff0ffff8ff0fff
|
|
// 004:fffffeee2222ffee88880fee22280feefff80ffffff80f0f0ff80f0f0ff80f0f
|
|
// 017:f8fffffff8888888f888f888f8888ffff8888888f2222222ff000fffefffffef
|
|
// 018:fff800ff88880ffef8880fee88880fee88880fee2222ffee000ffeeeffffeeee
|
|
// 019:f8fffffff8888888f888f888f8888ffff8888888f2222222ff000fffefffffef
|
|
// 020:fff800ff88880ffef8880fee88880fee88880fee2222ffee000ffeeeffffeeee
|
|
// </TILES>
|
|
|
|
// <WAVES>
|
|
// 000:00000000ffffffff00000000ffffffff
|
|
// 001:0123456789abcdeffedcba9876543210
|
|
// 002:0123456789abcdef0123456789abcdef
|
|
// </WAVES>
|
|
|
|
// <SFX>
|
|
// 000:000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000304000000000
|
|
// </SFX>
|
|
|
|
// <PALETTE>
|
|
// 000:0000002424245d343471614ea54c30b66534ff4648da8930b27d55d27d2cc69548caaa2cd2aa4cc2c25ddad45effffff
|
|
// </PALETTE>
|
|
|