bitsy.nv
· 8.8 KiB · Text
原始文件
Playground
|:: get color for .|
:color: 51 68 85
|:: get color for #|
:color: 255 187 51
|:: get sprite 1 for .|
:sprite data: (
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
)
|:: get sprite 1 for p|
:sprite data: (
. # . # # # # .
. # # # # # . .
. . . . . . . .
. . # # # # . .
. # . # # . # .
. . # . . # . .
. . # . . # . .
. . # . . # . .
)
|| :set player actor: p
|:: is p actor| :actor: p yes
|:: get sprite 2 for p|
:sprite data: (
# . # # # # . .
# # # # # . . .
. . . . . . . .
. . # # # # . .
. # . # # . # .
. . # . . # . .
. . # . . # . .
. . # . . # . .
)
|:: is c actor| :actor: c yes
|:: get sprite 1 for c|
:sprite data: (
. . . . . . . .
. . . . . . . .
. . . . . # . #
. . . . . # # #
. # . . . # # #
. # . # # # # .
. . # # # # # .
. . . # # . # .
)
|:: get sprite 2 for c|
:sprite data: (
. . . . . . . .
. . . . . . . .
. . . . . # . #
. . . . . # # #
. . . . . # # #
# . . # # # # .
. # # # # # # .
. . . # # . # .
)
|:: is w solid| :solid: w yes
|:: get sprite 1 for w|
:sprite data: (
# # # # # # # #
# # . . . . # #
# . # # # # . #
# . # . . # . #
# . # . . # . #
# . # # # # . #
# # . . . . # #
# # # # # # # #
)
|:: get sprite 1 for g|
:sprite data: (
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . # . . . . .
. . # . . # . .
. . # . . # . .
)
|:: get sprite 2 for g|
:sprite data: (
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. # . . . . . .
. # . . # . . .
. . # . . # . .
)
|| :current room: test
|:: get tiles for test|
:room data: (
w w w w w w w w
w . . . . g . w
w . . w w . . w
w c . . . . p w
w . . g . . . w
w g . w w . . w
w . . . . g . w
w w w w w w w w
)
|| :screen resolution: 64 64
:frame for sprites: 1
|:: start? :set player actor: $actor|
:: get actor locations
:: set player actor $actor
|:: get actor locations :current room: $room?|
:: get tiles for $room :: find each actor :tile location: 0 0
:: get tiles for $room :: find each solid :tile location: 0 0
|:: find each $type :room data: ($1 $2 $3 $4 $5 $6 $7 $8)|
:: is $1 $type :: add to $type list :: next tile column
:: is $2 $type :: add to $type list :: next tile column
:: is $3 $type :: add to $type list :: next tile column
:: is $4 $type :: add to $type list :: next tile column
:: is $5 $type :: add to $type list :: next tile column
:: is $6 $type :: add to $type list :: next tile column
:: is $7 $type :: add to $type list :: next tile column
:: is $8 $type :: add to $type list :: next tile row
:: find each $type
|:: find each $type :tile location: $x $y|
|:: add to actor list :actor: $who yes :tile location: $x $y?|
:actors: $who $x $y
|:: add to actor list :actor: $who no|
|:: add to solid list :solid: $what yes :tile location: $x $y?|
:solids: $what $x $y
|:: add to solid list :solid: $what no|
|:: set player actor $actor :actors: $actor $x $y|
:: rollback actors :player actor: $actor $x $y
|:: set player actor $actor :no more actors:|
|:: set player actor $actor?|
:: next actor
|::start :screen resolution: $x $y?|
:@graphics: set-resolution fullscreen $x $y
::main loop
|::draw|
:: clear the screen
:: move player actor
:: draw current room
:: draw npcs
:: draw player
:: tick frame
:: draw FPS
|:: is $x actor| :actor: $x no
|:: is $x solid| :solid: $x no
|:: get sprite $frame for $id|
:: get sprite 1 for $id
|:: next actor :actors: $actor $x $y :actors: $more $_x $_y?|
:discarded actors: $actor $x $y
|:: next actor :actors: $actor $x $y|
:discarded actors: $actor $x $y
:no more actors:
|:: next actor|
:no more actors:
|:: rollback actors :discarded actors: $actor $x $y|
:actors: $actor $x $y
|:: rollback actors|
|:: next solid :solids: $actor $x $y :solids: $more $_x $_y?|
:discarded solids: $actor $x $y
|:: next solid :solids: $actor $x $y|
:discarded solids: $actor $x $y
:no more solids:
|:: next solid|
:no more solids:
|:: rollback solids? :discarded solids: $solid $x $y|
:solids: $solid $x $y
|:: rollback solids|
|:: draw current room :current room: $room?|
:tile location: 0 0
:: get tiles for $room
:: draw room
|:: draw room :room data: ($1 $2 $3 $4 $5 $6 $7 $8)|
:: render tile $1 to screen
:: render tile $2 to screen
:: render tile $3 to screen
:: render tile $4 to screen
:: render tile $5 to screen
:: render tile $6 to screen
:: render tile $7 to screen
:: render tile $8 to screen :: last column
:: draw room
|:: draw room :tile location: $x $y|
|:: render tile $id to screen :: last column|
:: is $id actor :: draw sprite $id :: next tile row
|:: render tile $id to screen|
:: is $id actor :: draw sprite $id :: next tile column
|:: draw npcs? :tile location: $x $y|
|:: draw npcs :no more actors:|
:: rollback actors
|:: draw npcs? :actors: $actor $x $y?|
:: draw sprite $actor :tile location: $x $y
:: next actor
|:: draw player :player actor: $actor $x $y?|
:: draw sprite $actor :tile location: $x $y
|:: draw sprite $actor :actor: $actor yes|
:: draw sprite .
|:: draw sprite $actor? :actor: $actor no|
|:: draw sprite $sprite :frame for sprites: $frame? :tile location: $x $y?|
:pixel location: $x $y
:: get sprite $frame for $sprite
:: draw sprite
|:: draw sprite :sprite data: ($1 $2 $3 $4 $5 $6 $7 $8)|
:: plot $1 :: next pixel column
:: plot $2 :: next pixel column
:: plot $3 :: next pixel column
:: plot $4 :: next pixel column
:: plot $5 :: next pixel column
:: plot $6 :: next pixel column
:: plot $7 :: next pixel column
:: plot $8 :: next pixel row
:: draw sprite
|:: draw sprite :pixel location: $x $y|
|:: plot . :pixel location: $x $y? :color: $r $g $b|
:@graphics: set-pixel $x $y $r $g $b
|:: plot # :pixel location: $x $y? :color: $r $g $b|
:@graphics: set-pixel $x $y $r $g $b
|:: plot $char?|
:: get color for $char
|:: next pixel column :@math: $x :pixel location: $_ $y|
:pixel location: $x $y
|:: next pixel column? :pixel location: $x $y?|
:@math: add $x 1
|:: next pixel row :@math: $y :pixel location: $_x $_y :tile location: $x $_?|
:pixel location: $x $y
|:: next pixel row? :pixel location: $x $y?|
:@math: add $y 1
|:: next tile column :@math: $x :tile location: $_ $y|
:tile location: $x $y
|:: next tile column? :tile location: $x $y?|
:@math: add $x 8
|:: next tile row :@math: $y :tile location: $x $_|
:tile location: 0 $y
|:: next tile row? :tile location: $x $y?|
:@math: add $y 8
|:: tick frame :frame for sprites: 1|
:frame for sprites: 2
|:: tick frame :frame for sprites: 2|
:frame for sprites: 1
|:: move player actor|
:: check if up is pressed :: move player
:: check if right is pressed :: move player
:: check if down is pressed :: move player
:: check if left is pressed :: move player
|:: move player :key pressed: up :player actor: $actor $x 0?|
|:: move player? :key pressed: up :player actor: $actor $x $y?|
:: move y :@math: subtract $y 8
|:: move player :key pressed: right :player actor: $actor 56 $y?|
|:: move player? :key pressed: right :player actor: $actor $x $y?|
:: move x :@math: add $x 8
|:: move player :key pressed: down :player actor: $actor $x 56?|
|:: move player? :key pressed: down :player actor: $actor $x $y?|
:: move y :@math: add $y 8
|:: move player :key pressed: left :player actor: $actor 0 $y?|
|:: move player? :key pressed: left :player actor: $actor $x $y?|
:: move x :@math: subtract $x 8
|:: move player|
|:: move x? :@math: $x :player actor: $actor $_ $y?|
:: check for solid $x $y
|:: move x :a solid at: $x $y|
|:: move x :a nonsolid at: $x $y :player actor: $actor $_x $_y|
:player actor: $actor $x $y
|:: move y? :@math: $y :player actor: $actor $x $_?|
:: check for solid $x $y
|:: move y :a solid at: $x $y|
|:: move y :a nonsolid at: $x $y :player actor: $actor $_x $_y|
:player actor: $actor $x $y
|:: check for solid $x $y :solids: $what $x $y?|
:: rollback solids :a solid at: $x $y
|:: check for solid $x $y :no more solids:|
:: rollback solids :a nonsolid at: $x $y
|:: check for solid $x $y?|
:: next solid
| 1 | |:: get color for .| |
| 2 | :color: 51 68 85 |
| 3 | |:: get color for #| |
| 4 | :color: 255 187 51 |
| 5 | |
| 6 | |:: get sprite 1 for .| |
| 7 | :sprite data: ( |
| 8 | . . . . . . . . |
| 9 | . . . . . . . . |
| 10 | . . . . . . . . |
| 11 | . . . . . . . . |
| 12 | . . . . . . . . |
| 13 | . . . . . . . . |
| 14 | . . . . . . . . |
| 15 | . . . . . . . . |
| 16 | ) |
| 17 | |
| 18 | |:: get sprite 1 for p| |
| 19 | :sprite data: ( |
| 20 | . # . # # # # . |
| 21 | . # # # # # . . |
| 22 | . . . . . . . . |
| 23 | . . # # # # . . |
| 24 | . # . # # . # . |
| 25 | . . # . . # . . |
| 26 | . . # . . # . . |
| 27 | . . # . . # . . |
| 28 | ) |
| 29 | |
| 30 | || :set player actor: p |
| 31 | |:: is p actor| :actor: p yes |
| 32 | |:: get sprite 2 for p| |
| 33 | :sprite data: ( |
| 34 | # . # # # # . . |
| 35 | # # # # # . . . |
| 36 | . . . . . . . . |
| 37 | . . # # # # . . |
| 38 | . # . # # . # . |
| 39 | . . # . . # . . |
| 40 | . . # . . # . . |
| 41 | . . # . . # . . |
| 42 | ) |
| 43 | |
| 44 | |:: is c actor| :actor: c yes |
| 45 | |:: get sprite 1 for c| |
| 46 | :sprite data: ( |
| 47 | . . . . . . . . |
| 48 | . . . . . . . . |
| 49 | . . . . . # . # |
| 50 | . . . . . # # # |
| 51 | . # . . . # # # |
| 52 | . # . # # # # . |
| 53 | . . # # # # # . |
| 54 | . . . # # . # . |
| 55 | ) |
| 56 | |:: get sprite 2 for c| |
| 57 | :sprite data: ( |
| 58 | . . . . . . . . |
| 59 | . . . . . . . . |
| 60 | . . . . . # . # |
| 61 | . . . . . # # # |
| 62 | . . . . . # # # |
| 63 | # . . # # # # . |
| 64 | . # # # # # # . |
| 65 | . . . # # . # . |
| 66 | ) |
| 67 | |
| 68 | |:: is w solid| :solid: w yes |
| 69 | |:: get sprite 1 for w| |
| 70 | :sprite data: ( |
| 71 | # # # # # # # # |
| 72 | # # . . . . # # |
| 73 | # . # # # # . # |
| 74 | # . # . . # . # |
| 75 | # . # . . # . # |
| 76 | # . # # # # . # |
| 77 | # # . . . . # # |
| 78 | # # # # # # # # |
| 79 | ) |
| 80 | |
| 81 | |:: get sprite 1 for g| |
| 82 | :sprite data: ( |
| 83 | . . . . . . . . |
| 84 | . . . . . . . . |
| 85 | . . . . . . . . |
| 86 | . . . . . . . . |
| 87 | . . . . . . . . |
| 88 | . . # . . . . . |
| 89 | . . # . . # . . |
| 90 | . . # . . # . . |
| 91 | ) |
| 92 | |
| 93 | |:: get sprite 2 for g| |
| 94 | :sprite data: ( |
| 95 | . . . . . . . . |
| 96 | . . . . . . . . |
| 97 | . . . . . . . . |
| 98 | . . . . . . . . |
| 99 | . . . . . . . . |
| 100 | . # . . . . . . |
| 101 | . # . . # . . . |
| 102 | . . # . . # . . |
| 103 | ) |
| 104 | |
| 105 | || :current room: test |
| 106 | |:: get tiles for test| |
| 107 | :room data: ( |
| 108 | w w w w w w w w |
| 109 | w . . . . g . w |
| 110 | w . . w w . . w |
| 111 | w c . . . . p w |
| 112 | w . . g . . . w |
| 113 | w g . w w . . w |
| 114 | w . . . . g . w |
| 115 | w w w w w w w w |
| 116 | ) |
| 117 | |
| 118 | || :screen resolution: 64 64 |
| 119 | :frame for sprites: 1 |
| 120 | |
| 121 | |
| 122 | |:: start? :set player actor: $actor| |
| 123 | :: get actor locations |
| 124 | :: set player actor $actor |
| 125 | |
| 126 | |
| 127 | |
| 128 | |:: get actor locations :current room: $room?| |
| 129 | :: get tiles for $room :: find each actor :tile location: 0 0 |
| 130 | :: get tiles for $room :: find each solid :tile location: 0 0 |
| 131 | |
| 132 | |:: find each $type :room data: ($1 $2 $3 $4 $5 $6 $7 $8)| |
| 133 | :: is $1 $type :: add to $type list :: next tile column |
| 134 | :: is $2 $type :: add to $type list :: next tile column |
| 135 | :: is $3 $type :: add to $type list :: next tile column |
| 136 | :: is $4 $type :: add to $type list :: next tile column |
| 137 | :: is $5 $type :: add to $type list :: next tile column |
| 138 | :: is $6 $type :: add to $type list :: next tile column |
| 139 | :: is $7 $type :: add to $type list :: next tile column |
| 140 | :: is $8 $type :: add to $type list :: next tile row |
| 141 | :: find each $type |
| 142 | |:: find each $type :tile location: $x $y| |
| 143 | |
| 144 | |:: add to actor list :actor: $who yes :tile location: $x $y?| |
| 145 | :actors: $who $x $y |
| 146 | |:: add to actor list :actor: $who no| |
| 147 | |
| 148 | |:: add to solid list :solid: $what yes :tile location: $x $y?| |
| 149 | :solids: $what $x $y |
| 150 | |:: add to solid list :solid: $what no| |
| 151 | |
| 152 | |
| 153 | |:: set player actor $actor :actors: $actor $x $y| |
| 154 | :: rollback actors :player actor: $actor $x $y |
| 155 | |:: set player actor $actor :no more actors:| |
| 156 | |:: set player actor $actor?| |
| 157 | :: next actor |
| 158 | |
| 159 | |::start :screen resolution: $x $y?| |
| 160 | :@graphics: set-resolution fullscreen $x $y |
| 161 | ::main loop |
| 162 | |
| 163 | |
| 164 | |
| 165 | |::draw| |
| 166 | :: clear the screen |
| 167 | :: move player actor |
| 168 | :: draw current room |
| 169 | :: draw npcs |
| 170 | :: draw player |
| 171 | :: tick frame |
| 172 | :: draw FPS |
| 173 | |
| 174 | |:: is $x actor| :actor: $x no |
| 175 | |:: is $x solid| :solid: $x no |
| 176 | |:: get sprite $frame for $id| |
| 177 | :: get sprite 1 for $id |
| 178 | |
| 179 | |
| 180 | |:: next actor :actors: $actor $x $y :actors: $more $_x $_y?| |
| 181 | :discarded actors: $actor $x $y |
| 182 | |:: next actor :actors: $actor $x $y| |
| 183 | :discarded actors: $actor $x $y |
| 184 | :no more actors: |
| 185 | |:: next actor| |
| 186 | :no more actors: |
| 187 | |:: rollback actors :discarded actors: $actor $x $y| |
| 188 | :actors: $actor $x $y |
| 189 | |:: rollback actors| |
| 190 | |
| 191 | |:: next solid :solids: $actor $x $y :solids: $more $_x $_y?| |
| 192 | :discarded solids: $actor $x $y |
| 193 | |:: next solid :solids: $actor $x $y| |
| 194 | :discarded solids: $actor $x $y |
| 195 | :no more solids: |
| 196 | |:: next solid| |
| 197 | :no more solids: |
| 198 | |:: rollback solids? :discarded solids: $solid $x $y| |
| 199 | :solids: $solid $x $y |
| 200 | |:: rollback solids| |
| 201 | |
| 202 | |
| 203 | |:: draw current room :current room: $room?| |
| 204 | :tile location: 0 0 |
| 205 | :: get tiles for $room |
| 206 | :: draw room |
| 207 | |:: draw room :room data: ($1 $2 $3 $4 $5 $6 $7 $8)| |
| 208 | :: render tile $1 to screen |
| 209 | :: render tile $2 to screen |
| 210 | :: render tile $3 to screen |
| 211 | :: render tile $4 to screen |
| 212 | :: render tile $5 to screen |
| 213 | :: render tile $6 to screen |
| 214 | :: render tile $7 to screen |
| 215 | :: render tile $8 to screen :: last column |
| 216 | :: draw room |
| 217 | |:: draw room :tile location: $x $y| |
| 218 | |
| 219 | |:: render tile $id to screen :: last column| |
| 220 | :: is $id actor :: draw sprite $id :: next tile row |
| 221 | |:: render tile $id to screen| |
| 222 | :: is $id actor :: draw sprite $id :: next tile column |
| 223 | |
| 224 | |
| 225 | |
| 226 | |:: draw npcs? :tile location: $x $y| |
| 227 | |:: draw npcs :no more actors:| |
| 228 | :: rollback actors |
| 229 | |:: draw npcs? :actors: $actor $x $y?| |
| 230 | :: draw sprite $actor :tile location: $x $y |
| 231 | :: next actor |
| 232 | |
| 233 | |
| 234 | |
| 235 | |:: draw player :player actor: $actor $x $y?| |
| 236 | :: draw sprite $actor :tile location: $x $y |
| 237 | |
| 238 | |
| 239 | |
| 240 | |:: draw sprite $actor :actor: $actor yes| |
| 241 | :: draw sprite . |
| 242 | |:: draw sprite $actor? :actor: $actor no| |
| 243 | |:: draw sprite $sprite :frame for sprites: $frame? :tile location: $x $y?| |
| 244 | :pixel location: $x $y |
| 245 | :: get sprite $frame for $sprite |
| 246 | :: draw sprite |
| 247 | |
| 248 | |:: draw sprite :sprite data: ($1 $2 $3 $4 $5 $6 $7 $8)| |
| 249 | :: plot $1 :: next pixel column |
| 250 | :: plot $2 :: next pixel column |
| 251 | :: plot $3 :: next pixel column |
| 252 | :: plot $4 :: next pixel column |
| 253 | :: plot $5 :: next pixel column |
| 254 | :: plot $6 :: next pixel column |
| 255 | :: plot $7 :: next pixel column |
| 256 | :: plot $8 :: next pixel row |
| 257 | :: draw sprite |
| 258 | |:: draw sprite :pixel location: $x $y| |
| 259 | |
| 260 | |
| 261 | |:: plot . :pixel location: $x $y? :color: $r $g $b| |
| 262 | :@graphics: set-pixel $x $y $r $g $b |
| 263 | |:: plot # :pixel location: $x $y? :color: $r $g $b| |
| 264 | :@graphics: set-pixel $x $y $r $g $b |
| 265 | |:: plot $char?| |
| 266 | :: get color for $char |
| 267 | |
| 268 | |:: next pixel column :@math: $x :pixel location: $_ $y| |
| 269 | :pixel location: $x $y |
| 270 | |:: next pixel column? :pixel location: $x $y?| |
| 271 | :@math: add $x 1 |
| 272 | |:: next pixel row :@math: $y :pixel location: $_x $_y :tile location: $x $_?| |
| 273 | :pixel location: $x $y |
| 274 | |:: next pixel row? :pixel location: $x $y?| |
| 275 | :@math: add $y 1 |
| 276 | |
| 277 | |:: next tile column :@math: $x :tile location: $_ $y| |
| 278 | :tile location: $x $y |
| 279 | |:: next tile column? :tile location: $x $y?| |
| 280 | :@math: add $x 8 |
| 281 | |:: next tile row :@math: $y :tile location: $x $_| |
| 282 | :tile location: 0 $y |
| 283 | |:: next tile row? :tile location: $x $y?| |
| 284 | :@math: add $y 8 |
| 285 | |
| 286 | |:: tick frame :frame for sprites: 1| |
| 287 | :frame for sprites: 2 |
| 288 | |:: tick frame :frame for sprites: 2| |
| 289 | :frame for sprites: 1 |
| 290 | |
| 291 | |
| 292 | |
| 293 | |:: move player actor| |
| 294 | :: check if up is pressed :: move player |
| 295 | :: check if right is pressed :: move player |
| 296 | :: check if down is pressed :: move player |
| 297 | :: check if left is pressed :: move player |
| 298 | |
| 299 | |:: move player :key pressed: up :player actor: $actor $x 0?| |
| 300 | |:: move player? :key pressed: up :player actor: $actor $x $y?| |
| 301 | :: move y :@math: subtract $y 8 |
| 302 | |:: move player :key pressed: right :player actor: $actor 56 $y?| |
| 303 | |:: move player? :key pressed: right :player actor: $actor $x $y?| |
| 304 | :: move x :@math: add $x 8 |
| 305 | |:: move player :key pressed: down :player actor: $actor $x 56?| |
| 306 | |:: move player? :key pressed: down :player actor: $actor $x $y?| |
| 307 | :: move y :@math: add $y 8 |
| 308 | |:: move player :key pressed: left :player actor: $actor 0 $y?| |
| 309 | |:: move player? :key pressed: left :player actor: $actor $x $y?| |
| 310 | :: move x :@math: subtract $x 8 |
| 311 | |:: move player| |
| 312 | |
| 313 | |
| 314 | |:: move x? :@math: $x :player actor: $actor $_ $y?| |
| 315 | :: check for solid $x $y |
| 316 | |:: move x :a solid at: $x $y| |
| 317 | |:: move x :a nonsolid at: $x $y :player actor: $actor $_x $_y| |
| 318 | :player actor: $actor $x $y |
| 319 | |
| 320 | |:: move y? :@math: $y :player actor: $actor $x $_?| |
| 321 | :: check for solid $x $y |
| 322 | |:: move y :a solid at: $x $y| |
| 323 | |:: move y :a nonsolid at: $x $y :player actor: $actor $_x $_y| |
| 324 | :player actor: $actor $x $y |
| 325 | |
| 326 | |:: check for solid $x $y :solids: $what $x $y?| |
| 327 | :: rollback solids :a solid at: $x $y |
| 328 | |:: check for solid $x $y :no more solids:| |
| 329 | :: rollback solids :a nonsolid at: $x $y |
| 330 | |:: check for solid $x $y?| |
| 331 | :: next solid |