Browse Source

Merge pull request #32 from npisanti/master

replaces zig with lerp
master
Nicola Pisanti 6 years ago
committed by GitHub
parent
commit
e29a3d1b28
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 35
      sim.c

35
sim.c

@ -245,7 +245,7 @@ static void oper_poke_and_stun(Glyph* restrict gbuffer, Mark* restrict mbuffer,
_('W', movement) \ _('W', movement) \
_('X', teleport) \ _('X', teleport) \
_('Y', yump) \ _('Y', yump) \
_('Z', zig) _('Z', lerp)
#define MOVEMENT_CASES \ #define MOVEMENT_CASES \
'N' : case 'n' : case 'E' : case 'e' : case 'S' : case 's' : case 'W' \ 'N' : case 'n' : case 'E' : case 'e' : case 'S' : case 's' : case 'W' \
@ -747,26 +747,21 @@ BEGIN_OPERATOR(yump)
POKE(0, 1, PEEK(0, -1)); POKE(0, 1, PEEK(0, -1));
END_OPERATOR END_OPERATOR
BEGIN_OPERATOR(zig) BEGIN_OPERATOR(lerp)
LOWERCASE_REQUIRES_BANG; LOWERCASE_REQUIRES_BANG;
Glyph* gline = gbuffer + width * y; PORT(0, -1, IN);
gline[x] = '.'; PORT(0, 1, IN);
if (x + 1 == width) PORT(1, 0, IN | OUT);
return; Glyph g = PEEK(0, -1);
if (gline[x + 1] == '.') { Isz rate = 1;
gline[x + 1] = This_oper_char; if (g != '.' && g != '*')
mbuffer[width * y + x + 1] |= (U8)Mark_flag_sleep; rate = (Isz)index_of(g);
} else { Isz target = (Isz)index_of(PEEK(0, 1));
Usz n = 256; Isz val = (Isz)index_of(PEEK(1, 0));
if (x < n) Isz mod = (val <= target - rate)
n = x; ? rate
for (Usz i = 0; i < n; ++i) { : ((val >= target + rate) ? -rate : target - val);
if (gline[x - i - 1] != '.') { POKE(1, 0, glyph_of((Usz)(val + mod)));
gline[x - i] = This_oper_char;
break;
}
}
}
END_OPERATOR END_OPERATOR
//////// Run simulation //////// Run simulation

Loading…
Cancel
Save