2019-03-26 14:06:41 +01:00
|
|
|
// title: Doom Fire
|
|
|
|
// author: Fabien Freling
|
|
|
|
// desc: inspired by https://fabiensanglard.net/doom_fire_psx/
|
|
|
|
// script: wren
|
|
|
|
|
2019-03-27 14:08:48 +01:00
|
|
|
import "random" for Random
|
|
|
|
|
2019-03-26 14:06:41 +01:00
|
|
|
class Game is TIC{
|
|
|
|
|
|
|
|
construct new(){
|
|
|
|
_t=0
|
2019-03-28 13:16:31 +01:00
|
|
|
_width = 240
|
|
|
|
_height = 136
|
2019-03-27 14:08:48 +01:00
|
|
|
// Init to black
|
2019-03-28 13:16:31 +01:00
|
|
|
_base = List.filled(_width * _height, 0)
|
|
|
|
for (last_line in (_width * (_height-1))...(_width * _height)) {
|
2019-03-27 14:08:48 +01:00
|
|
|
_base[last_line] = 15
|
|
|
|
}
|
|
|
|
_random = Random.new(12345)
|
|
|
|
TIC.cls(0)
|
2019-03-26 14:06:41 +01:00
|
|
|
}
|
|
|
|
|
2019-03-27 14:08:48 +01:00
|
|
|
dofire() {
|
2019-03-28 13:16:31 +01:00
|
|
|
for (x in 0..._width) {
|
|
|
|
for (y in 0...(_height-1)) {
|
2019-03-27 14:08:48 +01:00
|
|
|
spreadfire(x, y)
|
|
|
|
}
|
2019-03-26 14:06:41 +01:00
|
|
|
}
|
2019-03-27 14:08:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
spreadfire(x, y) {
|
2019-03-28 13:16:31 +01:00
|
|
|
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
|
2019-03-26 14:06:41 +01:00
|
|
|
}
|
2019-03-27 14:08:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TIC(){
|
2019-03-28 13:16:31 +01:00
|
|
|
for (y in 0..._height) {
|
|
|
|
for (x in 0..._width) {
|
2019-03-27 14:08:48 +01:00
|
|
|
TIC.pix(x, y, _base[x + y * 240])
|
|
|
|
}
|
2019-03-26 14:06:41 +01:00
|
|
|
}
|
2019-03-27 14:08:48 +01:00
|
|
|
dofire()
|
2019-03-26 14:06:41 +01:00
|
|
|
_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>
|
2019-03-27 14:08:48 +01:00
|
|
|
// 000:0000002424245d343471614ea54c30b66534ff4648da8930b27d55d27d2cc69548caaa2cd2aa4cc2c25ddad45effffff
|
2019-03-26 14:06:41 +01:00
|
|
|
// </PALETTE>
|
|
|
|
|