diff --git a/entity.jor b/entity.jor index c1e4c22..c8a65cb 100755 --- a/entity.jor +++ b/entity.jor @@ -67,6 +67,7 @@ array frames ( 2: pete walk ) 12 10 8 6 frame ( 3: mary stand ) 17 20 22 24 frame ( 4: mary walk ) 19 21 23 25 frame +( 5: car lights ) 29 27 26 28 frame : sprindex ( dir frame ) 2 << frames + + b@ ; : defstatic ( frame -- ) create b, does> b@ sprindex ; @@ -79,6 +80,7 @@ array frames 2 + + b@ sprindex ; 0 defstatic {car} +5 defstatic {car-lit} 1 defstatic {pete-stand} 1 2 2 5 defanim {pete-walk} 13 defsingle {pete-table} diff --git a/game.exe b/game.exe index 9fd6918..2aeb0e0 100755 Binary files a/game.exe and b/game.exe differ diff --git a/game.jor b/game.jor index e93d869..f2c97c3 100755 --- a/game.jor +++ b/game.jor @@ -37,7 +37,7 @@ var player.prevdir : player.driving? player.state DRIVING f@ ; : {player} - player.driving? if {car} + player.driving? if {car-drive} else player.state MOVING f@ if player.state ISMARY f@ if {mary-walk} else {pete-walk} then else @@ -141,6 +141,8 @@ player :tick var showmouse 1 showmouse ! +var glitchlevel + : full-draw player entity.x @ 152 - player entity.y @ 92 - @@ -152,11 +154,17 @@ var showmouse showmouse @ if mouseworldpos 4 draw-sprite then + glitchlevel @ glitch draw-screen draw-footer ; +16 18 W ' {horse} defentity p_chuck :noname reset-level MODE-MOVE @ ' tick redefine ' full-draw ' draw redefine + :| player yield + CHUCK-FOLLOW flag@ if p_chuck yield then + done |; ' party redefine + ; ' onload redefine \ No newline at end of file diff --git a/game.prj b/game.prj index 56192f4..c1eb8a6 100755 Binary files a/game.prj and b/game.prj differ diff --git a/gameboot.jor b/gameboot.jor index cf3aa81..475b430 100755 --- a/gameboot.jor +++ b/gameboot.jor @@ -21,8 +21,8 @@ s" timer.jor" loadfile s" entity.jor" loadfile s" footer.jor" loadfile s" map.jor" loadfile -s" game.jor" loadfile s" state.jor" loadfile +s" game.jor" loadfile ; execute intern pete.jor diff --git a/map.jor b/map.jor index 013fca9..75bc722 100755 --- a/map.jor +++ b/map.jor @@ -4,8 +4,6 @@ var tileselect : mouseworldpos mousepos scrollpos +pos ; : mousetile mouseworldpos world>tile ; : tile ( x y -- ptr ) mapsize drop * + map + ; -: day s" TILES.TIF" loadtiles invalidate-map ; -: night s" NTILES.TIF" loadtiles invalidate-map ; 1 const WALKABLE 2 const DRIVABLE diff --git a/ntiles.tif b/ntiles.tif index 23207d9..e81a7a2 100755 Binary files a/ntiles.tif and b/ntiles.tif differ diff --git a/sprite.tif b/sprite.tif index 3096c5c..8e06464 100755 Binary files a/sprite.tif and b/sprite.tif differ diff --git a/state.jor b/state.jor index 767c829..06795af 100755 --- a/state.jor +++ b/state.jor @@ -4,8 +4,9 @@ 3 const CHUCK-HOME 4 const CHUCK-STOLEN 5 const CHUCK-EXPLAINED +6 const NIGHT -6 const FLAG-COUNT +7 const FLAG-COUNT array flags FLAG-COUNT 8 / 1 + allot @@ -15,9 +16,8 @@ array flags FLAG-COUNT 8 / 1 + allot : setflag 1 swap flagsf! ; : clearflag 0 swap flagsf! ; -16 18 W ' {horse} defentity p_chuck -:noname - :| player yield - CHUCK-FOLLOW flag@ if p_chuck yield then - done |; ' party redefine -; ' onload redefine \ No newline at end of file +: day s" TILES.TIF" loadtiles invalidate-map NIGHT clearflag ; +: night s" NTILES.TIF" loadtiles invalidate-map NIGHT setflag ; + +: {car-drive} NIGHT flag@ if {car-lit} else {car} then ; + diff --git a/testbed.c b/testbed.c index 973e233..d22d12a 100755 --- a/testbed.c +++ b/testbed.c @@ -59,10 +59,18 @@ unsigned int far *tiles; unsigned int far *sprites; unsigned char map[10000]; + +void deallocate_gfx() { + if (tiles) farfree(tiles); + if (sprites) farfree(sprites); +} + void allocate_gfx() { unsigned long memleft = farcoreleft(); - tiles = farmalloc(NUM_TILES * TILE_STRIDE); - sprites = farmalloc(NUM_SPRITES * SPRITE_STRIDE); + tiles = farmalloc(NUM_TILES * TILE_STRIDE * 2); + sprites = farmalloc(NUM_SPRITES * SPRITE_STRIDE * 2); + atexit(deallocate_gfx); + if (!tiles || !sprites) { printf("%lu bytes free - need %lu\n", memleft, (unsigned long) @@ -237,6 +245,24 @@ void f_cleanup() { f_execcp(f_atexit); } +void f_glitch() { + int count = TOP().u; + int i, x, y; + DROP(1); + for (i = 0; i < count; i ++) { + x = screen.scrollX + (rand() % 352) - 16; + y = screen.scrollY + (rand() % 232) - 16; + switch(rand()%2) { + case 0: + drawSprite(sprites + (rand() % (NUM_SPRITES * SPRITE_STRIDE)), x, y); + break; + case 1: + drawSprite(mem + (rand() % MEM_SIZE), x, y); + break; + } + } +} + void game_f_init(char *exe) { f_init(exe); CDEF("seremit", f_seremit); @@ -259,6 +285,7 @@ void game_f_init(char *exe) { CDEF("mousepos", f_mousepos); CDEF("mousebuttons", f_mousebuttons); CDEF("loadtiles", f_loadtiles); + CDEF("glitch", f_glitch); CDEF("unfuck", tile_init); f_loadjor("gameboot.jor"); diff --git a/trail1.map b/trail1.map index 483e366..429d959 100755 Binary files a/trail1.map and b/trail1.map differ