2019-02-18 01:14:56 +00:00
|
|
|
( J O B )
|
2019-02-17 00:21:02 +00:00
|
|
|
var MODE-MOVE
|
|
|
|
var MODE-WAIT
|
2019-02-12 04:23:00 +00:00
|
|
|
|
2019-02-17 00:21:02 +00:00
|
|
|
: listen-for-jobs activate blah
|
|
|
|
begin receive
|
|
|
|
MODE-WAIT @ ' tick redefine
|
|
|
|
execute
|
|
|
|
hide-footer
|
|
|
|
MODE-MOVE @ ' tick redefine
|
|
|
|
again ;
|
2019-02-12 04:23:00 +00:00
|
|
|
|
2019-02-17 00:21:02 +00:00
|
|
|
task const JOB
|
|
|
|
JOB listen-for-jobs
|
2019-02-12 04:23:00 +00:00
|
|
|
|
2019-02-18 01:14:56 +00:00
|
|
|
( T I C K )
|
2019-05-01 01:15:25 +00:00
|
|
|
defer party
|
2019-03-01 02:46:04 +00:00
|
|
|
defer entities
|
|
|
|
|
|
|
|
: entity-at ( x y -- entity|0 )
|
|
|
|
0 >rot
|
2019-05-17 01:05:40 +00:00
|
|
|
entities each >r 2dup ( 0 x y x y r:e )
|
2019-03-01 02:46:04 +00:00
|
|
|
r@ entity.x @ r@ entity.y @ world>tile 2= ( 0 x y eq r:e )
|
2019-05-17 01:05:40 +00:00
|
|
|
if <rot drop <r >rot break ( e x y )
|
2019-03-01 02:46:04 +00:00
|
|
|
else rdrop then ( 0 x y )
|
|
|
|
more drop drop ;
|
|
|
|
|
|
|
|
( P L A Y E R )
|
|
|
|
var player.state
|
2019-05-01 01:15:25 +00:00
|
|
|
var player.prevdir
|
2019-03-01 02:46:04 +00:00
|
|
|
|
|
|
|
1 const MOVING
|
|
|
|
2 const DRIVING
|
2019-03-26 02:05:23 +00:00
|
|
|
4 const NOCLIP
|
2019-06-02 03:35:37 +00:00
|
|
|
8 const ISMARY
|
2019-07-20 02:29:32 +00:00
|
|
|
16 const ISJEANNE
|
2019-03-26 02:05:23 +00:00
|
|
|
|
|
|
|
: player.driving? player.state DRIVING f@ ;
|
2019-03-01 02:46:04 +00:00
|
|
|
|
2019-07-01 16:31:00 +00:00
|
|
|
: :playerwalk create , , does>
|
|
|
|
player.state MOVING f@ not if cell + then @ execute ;
|
|
|
|
|
|
|
|
' {mary} ' {mary-walk} :playerwalk {pmary}
|
|
|
|
' {pete-stand} ' {pete-walk} :playerwalk {ppete}
|
|
|
|
' {jeanne} ' {jeanne-walk} :playerwalk {pjeanne}
|
|
|
|
|
2019-03-01 02:46:04 +00:00
|
|
|
: {player}
|
2019-06-26 01:58:52 +00:00
|
|
|
player.driving? if {car-drive}
|
2019-07-20 02:29:32 +00:00
|
|
|
else
|
|
|
|
player.state ISMARY f@ if {pmary}
|
|
|
|
else player.state ISJEANNE f@ if {pjeanne}
|
|
|
|
else {ppete} then then
|
2019-07-01 16:31:00 +00:00
|
|
|
then ;
|
2019-03-01 02:46:04 +00:00
|
|
|
|
2019-02-27 02:44:22 +00:00
|
|
|
: player.canmove? ( x y -- )
|
2019-03-26 02:05:23 +00:00
|
|
|
player.state NOCLIP f@ not if
|
|
|
|
player.driving? if DRIVABLE else WALKABLE then mapflag?
|
|
|
|
else drop drop 1 then ;
|
2019-02-18 01:14:56 +00:00
|
|
|
|
2019-03-03 01:03:34 +00:00
|
|
|
12 9 N ' {player} defentity player
|
|
|
|
|
2019-02-18 01:14:56 +00:00
|
|
|
: move-player
|
2019-03-03 01:03:34 +00:00
|
|
|
1 player.state MOVING f!
|
|
|
|
player move-entity
|
2019-05-01 01:15:25 +00:00
|
|
|
player.prevdir @ party each
|
|
|
|
dup player != if
|
2019-05-17 01:05:40 +00:00
|
|
|
dup entity.dir @ >r
|
2019-05-01 01:15:25 +00:00
|
|
|
dup >rot entity.dir !
|
2019-05-17 01:05:40 +00:00
|
|
|
move-entity <r
|
2019-05-01 01:15:25 +00:00
|
|
|
else entity.dir @ player.prevdir ! then more drop
|
2019-03-03 01:03:34 +00:00
|
|
|
0 player.state MOVING f! ;
|
|
|
|
|
|
|
|
: out-of-bounds ( x y -- b )
|
|
|
|
2dup 0 < swap 0 < or >rot mapsize ( b x y w h )
|
|
|
|
<rot <= >rot ( b b x w )
|
|
|
|
>= or or ;
|
|
|
|
|
2019-03-10 00:59:52 +00:00
|
|
|
: leaving? ( x y dir -- b )
|
|
|
|
dup N = if drop swap drop 0 < else
|
|
|
|
dup W = if drop drop 0 < else
|
|
|
|
S = if swap drop mapsize swap drop >= else
|
|
|
|
drop mapsize drop >= then then then ;
|
|
|
|
|
2019-03-03 01:03:34 +00:00
|
|
|
defer player-touch ( x y -- b )
|
|
|
|
|
2019-04-30 23:32:20 +00:00
|
|
|
: touch-begin each 2dup more >rot drop drop ;
|
|
|
|
: touch-next dup if rdrop done then drop rswap ;
|
|
|
|
: touch-last ' done , ; immediate
|
2019-03-12 01:57:22 +00:00
|
|
|
: ;touch [ ' touch-last , ' [ , ] ; immediate
|
|
|
|
|
2019-03-03 01:03:34 +00:00
|
|
|
: check-player-touch ( x y -- b )
|
2019-03-12 01:57:22 +00:00
|
|
|
touch-begin entity-at dup if EVTOUCH entity>do 1 then
|
|
|
|
touch-next player-touch
|
|
|
|
touch-next out-of-bounds
|
|
|
|
touch-next player.canmove? not ;touch
|
2019-03-03 01:03:34 +00:00
|
|
|
|
|
|
|
: try-move-player
|
2019-03-05 22:35:50 +00:00
|
|
|
player entity-dst check-player-touch not if move-player then ;
|
|
|
|
|
2019-05-19 17:34:27 +00:00
|
|
|
: follow ( e -- )
|
|
|
|
player entity>pos <rot entity.pos! NODIR player.prevdir ! ;
|
|
|
|
|
2019-03-12 01:57:22 +00:00
|
|
|
: check-entity-touch
|
|
|
|
touch-begin entity-at
|
|
|
|
touch-next out-of-bounds
|
|
|
|
touch-next WALKABLE mapflag? ;touch
|
2019-03-05 22:35:50 +00:00
|
|
|
|
|
|
|
: try-move-entity ( e -- )
|
|
|
|
dup entity-dst check-entity-touch not if move-entity then ;
|
2019-03-03 01:03:34 +00:00
|
|
|
|
2019-03-14 00:43:38 +00:00
|
|
|
var q-level
|
|
|
|
var q-player.x
|
|
|
|
var q-player.y
|
|
|
|
: queue-level q-level ! q-player.y ! q-player.x ! ;
|
2019-03-10 23:51:24 +00:00
|
|
|
|
2019-03-03 01:03:34 +00:00
|
|
|
player :tick
|
2019-02-18 01:14:56 +00:00
|
|
|
0 ^LEFT key-down if drop 1 W player entity.dir ! then
|
|
|
|
^RIGHT key-down if drop 1 E player entity.dir ! then
|
|
|
|
^UP key-down if drop 1 N player entity.dir ! then
|
|
|
|
^DOWN key-down if drop 1 S player entity.dir ! then
|
2019-03-03 01:03:34 +00:00
|
|
|
if ' try-move-player JOB send then
|
|
|
|
;entity
|
2019-03-01 02:46:04 +00:00
|
|
|
|
|
|
|
( S T U F F )
|
2019-03-26 02:05:23 +00:00
|
|
|
: reset-level
|
2019-05-01 01:15:25 +00:00
|
|
|
:| done |; ' entities redefine
|
2019-03-26 02:05:23 +00:00
|
|
|
:| drop drop 0 |; ' player-touch redefine ;
|
|
|
|
|
2019-02-17 00:21:02 +00:00
|
|
|
: mode-move
|
2019-03-01 02:46:04 +00:00
|
|
|
entities each EVTICK entity>do more
|
2019-05-01 01:15:25 +00:00
|
|
|
party each EVTICK entity>do more
|
2019-02-18 01:14:56 +00:00
|
|
|
tick-mapedit
|
2019-03-10 23:51:24 +00:00
|
|
|
tick-debounce
|
2019-03-14 00:43:38 +00:00
|
|
|
q-level @ dup if
|
|
|
|
0 q-level !
|
2019-03-26 02:05:23 +00:00
|
|
|
reset-level
|
2019-03-10 23:51:24 +00:00
|
|
|
loadlevel
|
2019-03-14 00:43:38 +00:00
|
|
|
q-player.x @ q-player.y @ tile>world player entity.pos!
|
2019-05-19 17:34:27 +00:00
|
|
|
party each follow more
|
2019-03-10 23:51:24 +00:00
|
|
|
else drop then ;
|
2019-02-18 01:14:56 +00:00
|
|
|
|
2019-02-17 00:21:02 +00:00
|
|
|
' mode-move MODE-MOVE !
|
2019-02-18 01:14:56 +00:00
|
|
|
' tick-debounce MODE-WAIT !
|
2019-02-12 04:23:00 +00:00
|
|
|
|
2019-02-27 02:44:22 +00:00
|
|
|
: draw-entity
|
2019-05-17 01:05:40 +00:00
|
|
|
>r r@ entity.x @ r@ entity.y @
|
|
|
|
r@ entity.dir @ <r entity>sprite
|
2019-02-11 00:17:58 +00:00
|
|
|
draw-sprite ;
|
|
|
|
|
2019-04-26 01:55:23 +00:00
|
|
|
var showmouse
|
|
|
|
1 showmouse !
|
2019-06-26 01:58:52 +00:00
|
|
|
var glitchlevel
|
|
|
|
|
2019-02-11 00:17:58 +00:00
|
|
|
: full-draw
|
|
|
|
player entity.x @ 152 -
|
|
|
|
player entity.y @ 92 -
|
|
|
|
scroll
|
|
|
|
|
2019-03-01 02:46:04 +00:00
|
|
|
entities each draw-entity more
|
2019-05-01 01:15:25 +00:00
|
|
|
party each draw-entity more
|
|
|
|
|
2019-04-26 01:55:23 +00:00
|
|
|
showmouse @ if
|
|
|
|
mouseworldpos 4 draw-sprite
|
|
|
|
then
|
2019-06-26 01:58:52 +00:00
|
|
|
glitchlevel @ glitch
|
2019-02-17 00:21:02 +00:00
|
|
|
draw-screen
|
|
|
|
draw-footer ;
|
2019-02-11 00:17:58 +00:00
|
|
|
|
2019-06-26 01:58:52 +00:00
|
|
|
16 18 W ' {horse} defentity p_chuck
|
2019-07-01 16:31:00 +00:00
|
|
|
16 18 W ' {pjeanne} defentity p_jeanne
|
|
|
|
|
2019-03-10 00:59:52 +00:00
|
|
|
:noname
|
2019-03-10 23:51:24 +00:00
|
|
|
reset-level
|
|
|
|
MODE-MOVE @ ' tick redefine
|
|
|
|
' full-draw ' draw redefine
|
2019-06-26 01:58:52 +00:00
|
|
|
:| player yield
|
2019-07-20 02:29:32 +00:00
|
|
|
player.state ISMARY f@ if p_jeanne yield then
|
2019-06-26 01:58:52 +00:00
|
|
|
CHUCK-FOLLOW flag@ if p_chuck yield then
|
|
|
|
done |; ' party redefine
|
|
|
|
|
2019-03-10 00:59:52 +00:00
|
|
|
; ' onload redefine
|