car headlights

This commit is contained in:
Jeremy Penner 2019-06-25 21:58:52 -04:00
parent 5e98b5f095
commit 761ef1751a
11 changed files with 48 additions and 13 deletions

View file

@ -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}

BIN
game.exe

Binary file not shown.

View file

@ -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

BIN
game.prj

Binary file not shown.

View file

@ -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

View file

@ -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

Binary file not shown.

Binary file not shown.

View file

@ -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
: 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 ;

View file

@ -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");

Binary file not shown.