Skip to content
Browse files

More work on CleanSweep.

  • Loading branch information...
1 parent d383ba3 commit 0240195e90dd1225f79bd082becb0edba6c4a585 @JohnEarnest committed Jul 1, 2012
View
125 games/CleanSweep/CleanEngine.fs
@@ -232,7 +232,7 @@
;
: c-npc? ( a b -- flag )
- over py over py 6 - >= >r
+ over py over py 14 - >= >r
over py over py 6 + < r> and >r
over px over px 14 - >= r> and >r
over px over px 14 + < r> and >r
@@ -459,6 +459,60 @@
rdrop
;
+: evaporate ( id -- )
+ >r
+ i timer @ if
+ i timer dec@
+ 55 i tile!
+ i timer @ 10 > if 54 i tile! then
+ i timer @ 20 > if 53 i tile! then
+ else
+ i free
+ then
+ rdrop
+;
+
+: puddle ( id -- )
+ # puddles have no logic of their own.
+ # this stub is here so we can identify
+ # them by type name.
+ drop
+;
+
+: spawn-puddle ( tile-x tile-y -- )
+ 53 ' puddle 0 spawn-npc drop
+;
+
+:var item-carried
+:const item-powder 1
+:const item-mat 2
+
+:vector resupply ( -- ) ;
+
+: powder drop ; ( id -- )
+: mat drop ; ( id -- )
+
+: spawn-powder ( tile-x tile-y -- )
+ 44 ' powder {
+ "Picked up dessicant powder!" alert
+ item-powder item-carried ! free
+ resupply
+ } spawn-npc drop
+;
+
+: spawn-mat ( tile-x tile-y -- )
+ 45 ' mat {
+ "Picked up absorbent mat!" alert
+ item-mat item-carried ! free resupply
+ } spawn-npc drop
+;
+
+######################################################
+##
+## Doors
+##
+######################################################
+
# an outer routine driving
# these actions (think) leaves
# a value on the stack- we
@@ -687,17 +741,80 @@
rdrop
;
+: mat? ( tile -- flag )
+ 144 over 146 within >r
+ 160 swap 162 within r> or
+;
+
+: on-mat? ( npc-id -- flag )
+ >r
+ i px 1 + i py 22 + mat?
+ i px 8 + i py 22 + mat? or
+ i px 14 + i py 22 + mat? or
+ i px 1 + i py 31 + mat? or
+ i px 8 + i py 31 + mat? or
+ i px 14 + i py 31 + mat? or
+ rdrop
+;
+
+: >mat? ( tile -- flag )
+ dup grid-z and if
+ drop false
+ else
+ 16 mod 7 <
+ then
+;
+
+: lay-mat ( mat-tile ox oy -- )
+ player @ py + swap
+ player @ px + swap pixel-grid@
+ dup @ >mat? if ! else 2drop then
+;
+
+: base-action ( id -- )
+ item-carried @ item-powder = if
+ "USED powder" typeln
+ activated on item-carried off drop exit
+ then
+ item-carried @ item-mat = if
+ 0 player @ tile!
+ # would've been possible to do
+ # with loops and such, but this
+ # approach is *so much* easier:
+
+ player @ sprite@ @ sprite-mirror-horiz and if
+ # facing right
+ 144 16 16 160 16 24
+ 145 24 16 161 24 24
+ 146 32 16 162 32 24
+ else
+ # facing left
+ 146 -8 16 162 -8 24
+ 145 -16 16 161 -16 24
+ 144 -24 16 160 -24 24
+ then
+ 2 for lay-mat lay-mat 5 for tick next next
+ activated on item-carried off drop exit
+ then
+ do-transform
+;
+
: scrubby ( id -- )
>r
- 0 i tile!
+
+ 0
+ item-carried @ item-powder = if drop 48 then
+ item-carried @ item-mat = if drop 50 then
+ i tile!
keys 15 and if
keys 15 and keys-dir + @
dup 7 > if drop p-dir @ then p-dir !
p-bounce dec@
p-bounce @ -10 < if 10 p-bounce ! then
- p-bounce @ 0 > if 1 else 0 then i tile!
+ i tile 1 not and p-bounce @ 0 > 1 and or i tile!
+
keys key-rt and if i face-right then
keys key-lf and if i face-left then
@@ -736,7 +853,7 @@
found-trigger @ exec
activated on
else
- i do-transform
+ i base-action
then
then
then
View
BIN games/CleanSweep/LabTiles.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN games/CleanSweep/Scrubby.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
86 games/CleanSweep/TestLevels.fs
@@ -198,6 +198,7 @@
: init-down-hallway
0 GS ! grid-down-hallway GP !
+ 21 16 spawn-puddle
;
: main-down-hallway
@@ -224,14 +225,14 @@
-1 -1 -1 -1 -1 -1 -1 40 40 40 40 40 40 40 40 1073741864 1073741864 1073741864 1073741864 1073741864 1073741864 1073741864 1073741864 1073741864 1073741864 40 40 40 40 40 40 40 40 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 40 40 10 10 10 10 10 134 1073741952 1073741953 1073741959 1073741958 1073741952 1073741953 1073741959 1073741958 1073741952 1073741953 135 10 10 10 10 10 40 40 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 40 40 10 10 10 10 10 10 10 134 1073741952 1073741953 135 134 1073741952 1073741953 135 10 10 10 10 10 10 10 40 40 -1 -1 -1 -1 -1 -1 -1 -1
- -1 -1 -1 -1 -1 -1 -1 40 40 10 10 10 10 10 10 10 10 60 60 60 60 60 60 10 10 10 10 10 10 10 10 40 40 -1 -1 -1 -1 -1 -1 -1 -1
- -1 -1 -1 -1 -1 -1 -1 40 40 60 60 60 60 60 60 60 76 149 150 150 150 150 151 59 60 60 60 60 60 60 60 40 40 -1 -1 -1 -1 -1 -1 -1 -1
- -1 -1 -1 -1 -1 -1 -1 40 40 149 150 150 151 149 150 150 151 149 88 89 89 90 151 149 150 150 151 149 150 150 151 40 40 -1 -1 -1 -1 -1 -1 -1 -1
- -1 -1 -1 -1 -1 -1 -1 40 40 88 89 89 90 88 89 89 90 88 89 90 88 89 90 88 89 89 90 88 89 89 90 40 40 -1 -1 -1 -1 -1 -1 -1 -1
- -1 -1 -1 -1 -1 -1 -1 40 40 88 73 89 90 88 89 73 90 18 18 18 18 18 18 88 73 89 90 88 73 89 90 40 40 -1 -1 -1 -1 -1 -1 -1 -1
- -1 -1 -1 -1 -1 -1 -1 40 40 88 89 73 90 88 89 73 90 18 2 2 2 2 2 88 73 73 90 88 29 73 90 40 40 -1 -1 -1 -1 -1 -1 -1 -1
- -1 -1 -1 -1 -1 -1 -1 40 40 72 73 73 74 72 73 73 74 18 2 2 2 2 0 72 73 73 74 72 73 73 74 40 40 -1 -1 -1 -1 -1 -1 -1 -1
- -1 -1 -1 -1 -1 -1 -1 40 40 18 18 18 18 18 18 18 18 18 2 2 0 0 0 36 18 18 18 18 18 18 18 40 40 -1 -1 -1 -1 -1 -1 -1 -1
+ -1 -1 -1 -1 -1 -1 -1 40 40 60 60 60 60 60 127 10 10 127 60 60 60 60 127 10 10 127 60 60 60 60 60 40 40 -1 -1 -1 -1 -1 -1 -1 -1
+ -1 -1 -1 -1 -1 -1 -1 40 40 149 150 150 150 151 75 60 60 76 149 150 150 150 75 60 60 76 149 150 150 150 151 40 40 -1 -1 -1 -1 -1 -1 -1 -1
+ -1 -1 -1 -1 -1 -1 -1 40 40 88 89 89 89 90 18 18 18 18 88 89 89 90 18 18 18 18 88 89 89 89 90 40 40 -1 -1 -1 -1 -1 -1 -1 -1
+ -1 -1 -1 -1 -1 -1 -1 40 40 88 73 89 89 90 18 8 8 18 88 90 88 90 18 8 8 18 88 73 73 89 90 40 40 -1 -1 -1 -1 -1 -1 -1 -1
+ -1 -1 -1 -1 -1 -1 -1 40 40 88 89 73 73 90 18 8 8 0 36 18 18 18 18 8 8 0 88 29 29 73 90 40 40 -1 -1 -1 -1 -1 -1 -1 -1
+ -1 -1 -1 -1 -1 -1 -1 40 40 72 73 73 73 74 18 0 0 0 2 2 2 2 2 0 0 0 72 73 73 73 74 40 40 -1 -1 -1 -1 -1 -1 -1 -1
+ -1 -1 -1 -1 -1 -1 -1 40 40 18 18 18 18 18 18 0 0 0 2 2 2 2 0 0 0 0 36 18 18 18 18 40 40 -1 -1 -1 -1 -1 -1 -1 -1
+ -1 -1 -1 -1 -1 -1 -1 40 40 18 18 0 0 0 0 0 0 0 2 2 0 0 0 0 0 0 0 0 0 0 0 40 40 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 40 40 1073741973 1073741974 1073741974 1073741975 1073741973 1073741974 1073741974 1073741975 2 2 2 0 0 0 1073741973 1073741974 1073741974 1073741975 1073741973 1073741974 1073741974 1073741975 40 40 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 40 40 88 89 89 90 88 89 89 90 2 2 2 0 0 0 88 89 89 90 88 89 89 90 40 40 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 40 40 88 89 73 90 88 29 89 90 2 2 2 2 2 2 88 73 89 90 88 89 89 90 40 40 -1 -1 -1 -1 -1 -1 -1 -1
@@ -259,7 +260,7 @@
i timer inc@
i timer @ 8 mod -if
i prev @ bob-delta + @
- dup 0 < if 61 else 60 then i tile!
+ dup 0 < if 60 else 59 then i tile!
i +py
i prev @ 1 + 14 mod i prev !
then
@@ -269,9 +270,9 @@
: follow ( id -- )
>r
i px 16 - player @ px over 32 + within if
- 62 i tile!
+ 61 i tile!
else
- 63 i tile!
+ 62 i tile!
player @ px i px < if
i face-left
else
@@ -281,16 +282,69 @@
rdrop
;
+#XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+
+:var follower
+: access ( id -- )
+ >r
+ ' follow instance follower !
+ 63 follower @ tile!
+ dialog-open
+ dialog[
+ "<Greetings, Comrade."
+ "Would you like me to brief you on"
+ "available cleaning equipment?>"
+ ]-ask
+ if
+ 62 follower @ tile!
+ player @ face-left
+ follower @ face-left
+ dialog[
+ "<To the left are dessicant powder"
+ "canisters. They can be used to soak"
+ "up spills, but leaves a residue.>"
+ ]-text
+ player @ face-right
+ follower @ face-right
+ dialog[
+ "<To the right are absorbent mats."
+ "Place them in areas of high foot-"
+ "traffic to stop the spread of dirt.>"
+ ]-text
+ else
+ 61 follower @ tile!
+ dialog[ "<Very well, then, Comrade.>" ]-text
+ then
+
+ 63 follower @ tile!
+ dialog[ "<Good cleaning to you!>" ]-text
+ dialog-close
+ rdrop
+;
+
+: spawn-items ( -- )
+ ' powder any? -if
+ 15 7 spawn-powder
+ then
+ ' mat any? -if
+ 23 7 spawn-mat
+ then
+;
+
: init-closet
+ ' spawn-items ' resupply revector
+ spawn-items
+
0 GS ! grid-closet GP !
19 16 spawn-scrubby
48x16 19 20 spawn-exit-door
- 15 3 61 ' bob 0 spawn-npc 10 swap timer !
- 23 3 61 ' bob 0 spawn-npc 2 swap prev !
- 17 3 60 ' bob 0 spawn-npc 3 swap prev !
- 21 3 60 ' bob 0 spawn-npc 7 swap prev !
- 19 4 62 ' follow 0 spawn-npc drop
+ 15 3 60 ' bob 0 spawn-npc 10 swap timer !
+ 23 3 60 ' bob 0 spawn-npc 2 swap prev !
+ 17 3 59 ' bob 0 spawn-npc 3 swap prev !
+ 21 3 59 ' bob 0 spawn-npc 7 swap prev !
+ 19 4 61 ' follow 0 spawn-npc drop
+ 19 6 0 { drop } ' access spawn-npc hide
;
: main-closet
View
20 lib/Game/Entities.fs
@@ -115,7 +115,7 @@
;
: count+ drop swap 1 + swap ;
-: count 0 swap ' count+ whoever ; ( 'filter -- )
+: count 0 swap ' count+ whoever ; ( 'filter -- n )
: always drop true ;
: think ' always ' apply-kind whoever ; ( -- )
: clear-entities ' always ' free whoever ; ( -- )
@@ -127,6 +127,24 @@
drop false
;
+: any? ( 'kind -- flag )
+ ent-max 1 - for
+ i kind @ over xor -if
+ drop rdrop true exit
+ then
+ next
+ drop false
+;
+
+: instance ( 'kind -- id )
+ ent-max 1 - for
+ i kind @ over xor -if
+ drop r> exit
+ then
+ next
+ drop bogus-ent
+;
+
# positive if a>b, negative if a<b.
:vector -sprites ( a b -- )
py swap py swap -

0 comments on commit 0240195

Please sign in to comment.
Something went wrong with that request. Please try again.