├── .gitattributes
├── README.md
├── _config.yml
├── builds
├── README.md
├── b8p.data
├── b8p.js
└── play.html
├── docs
├── changelog.md
├── imgs
│ ├── coordinate.png
│ ├── head.png
│ ├── logo.png
│ ├── welcome.png
│ ├── workshop.png
│ ├── workshop_mount.png
│ ├── workshop_push.png
│ ├── workshop_remove.png
│ ├── workshop_submit.png
│ └── workshop_subscribe.png
├── manual.md
├── welcome.md
└── workshop.md
├── examples
├── Boing Ball
│ ├── README.md
│ └── content
│ │ ├── info.json
│ │ ├── main.bas
│ │ ├── main.palette
│ │ └── sticker.png
├── Cosmos Saga
│ ├── README.md
│ └── content
│ │ ├── enemy_bank.sprite
│ │ ├── explosion_bank.sprite
│ │ ├── galaxy_scroll.map
│ │ ├── info.json
│ │ ├── main.bas
│ │ ├── main.palette
│ │ ├── main.tiles
│ │ ├── over_txt.quantized
│ │ ├── spaceship.sprite
│ │ ├── sticker.png
│ │ ├── title_bg.quantized
│ │ └── title_txt.quantized
└── Infinity Fighter
│ ├── README.md
│ └── content
│ ├── battle_bg.map
│ ├── battle_fg.map
│ ├── fighter_bank.sprite
│ ├── hp_bank.sprite
│ ├── info.json
│ ├── main.bas
│ ├── main.palette
│ ├── main.tiles
│ ├── sticker.png
│ └── title_txt.quantized
├── favicon.ico
├── pages
├── about.md
├── gallery.md
├── imgs
│ ├── app.png
│ ├── banner_platforms.png
│ ├── boing_ball.gif
│ ├── cosmos_saga.gif
│ ├── creating_images.png
│ ├── creating_maps.png
│ ├── creating_sprites.png
│ ├── infinity_fighter.gif
│ ├── integrated.png
│ ├── mailto.png
│ ├── more_disks1.png
│ ├── more_disks2.png
│ ├── on_steam.png
│ ├── playable_now.png
│ ├── steam.png
│ ├── tools.png
│ └── writing_programs.png
└── why.md
└── vars
└── urls.txt
/.gitattributes:
--------------------------------------------------------------------------------
1 | builds/*.html linguist-vendored
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
71 |
75 |
78 |
79 |
80 |
Powered by BASIC8, disk player build (32)
81 |
82 |
168 |
169 |
170 |
171 |
--------------------------------------------------------------------------------
/docs/changelog.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ### v1.5.5
4 |
5 | Community:
6 |
7 | * Fixed a Workshop submission issue after stuck
8 |
9 | Editor:
10 |
11 | * Added font customization by config for full app
12 | * Added navigation by keypad support
13 | * Changed the in-app document reader to support key navigation and sidebar index
14 |
15 | Player:
16 |
17 | * Added icon, splash, frame customization
18 |
19 | ### v1.5.4
20 |
21 | Driver:
22 |
23 | * Added MIDI support
24 | * Fixed an unexpected error when set SoundFont more than once
25 |
26 | Libraries:
27 |
28 | * Added intersection detection functions
29 |
30 | Editor:
31 |
32 | * Fixed a table splitting issue in the document viewer
33 | * Fixed a mouse cursor rendering issue of the code editor
34 | * Fixed a selection issue after typing in the code editor
35 |
36 | ### v1.5.3
37 |
38 | Libraries:
39 |
40 | * Added a `RAYCASTER` algorithm
41 | * Fixed a crash bug of UDP sending
42 | * Fixed an input value validation issue of the `WALKER` module
43 |
44 | Editor:
45 |
46 | * Fixed a menu loading issue
47 |
48 | Player:
49 |
50 | * Added SoundFont support for HTML5 build
51 |
52 | ### v1.5.2
53 |
54 | Driver:
55 |
56 | * Fixed an indexing bug with multiple joysticks
57 |
58 | Libraries:
59 |
60 | * Added a `WALKER` algorithm
61 | * Added an error code for the `MGET` function instead of raising an error
62 | * Added a new stable random generator
63 | * Fixed a type checking bug with JSON serialization
64 |
65 | Editor:
66 |
67 | * Added font customization by config for code editor
68 |
69 | ### v1.5.1
70 |
71 | Libraries:
72 |
73 | * Added custom headers for the `WEB_REQUEST` function
74 | * Added a return value for expected duration of a `SAY` calling
75 |
76 | Editor:
77 |
78 | * Fixed an inoperable issue after clicking a URL
79 |
80 | ### v1.5 Feb. 2020
81 |
82 | Libraries:
83 |
84 | * Added a `SAY` function to synthesize speech
85 |
86 | Editor:
87 |
88 | * Added a `PICK_DIRECTORY_DIALOG` function to scriptable plugin
89 | * Added `GET_ASSETS`, `OPEN_ASSETS` functions to scriptable plugin
90 | * Fixed a crash bug if frame count was greater than the limitation with scriptable plugin
91 | * Fixed a selection bug when frame count was greater than 256
92 | * Fixed an asset invalidation issue with cross frame operations with scriptable plugin
93 | * Fixed an acquiring issue when copying an entire asset
94 |
95 | ### v1.4.9
96 |
97 | Language:
98 |
99 | * Fixed a crash bug with number parsing
100 | * Fixed a crash bug with invalid expression
101 | * Fixed a crash bug with invalid routine invoking
102 | * Fixed a memory leak when reassigning an array element with string
103 |
104 | Libraries:
105 |
106 | * Added a `PLOT` function to put individual pixels
107 | * Added an `ARC` function to draw arc or pie shapes
108 | * Added an `ARCFILL` function to fill arc or pie shapes
109 |
110 | Editor:
111 |
112 | * Added immediate saving on new sprite, map assets created
113 | * Changed plot mode of the pencil tool to linked
114 |
115 | ### v1.4.8
116 |
117 | Language:
118 |
119 | * Fixed a crash bug when using an iterator in a conditional expression
120 | * Fixed a crash bug when `MOD` by zero
121 | * Fixed a memory leak with wrong iterator usage
122 | * Fixed a wrong scope processing bug when resetting the interpreter
123 |
124 | Libraries:
125 |
126 | * Added file and directory selection dialogs to the GUI library
127 | * Fixed a crash bug with invalid database value
128 | * Fixed a crash bug with closed archive
129 | * Fixed a memory leak with non-closed archive
130 | * Fixed an option accessing issue with the network library
131 |
132 | Editor:
133 |
134 | * Fixed a crash bug with pen size greater than 1px
135 |
136 | ### v1.4.7
137 |
138 | Language:
139 |
140 | * Fixed a multiple disposing bug with lambda
141 | * Fixed a crash bug with incomplete structures
142 | * Fixed a crash bug with unused coroutine
143 |
144 | Libraries:
145 |
146 | * Added a `FONT` function to customize font face with quantized image for the `TEXT` function
147 | * Added a `POLL` function to poll network events manually
148 | * Fixed a return value overwriting bug with network callback
149 | * Fixed a real number formatting bug with different locales
150 | * Fixed a potential crash bug with network callback
151 | * Fixed a random seeding issue
152 |
153 | Editor:
154 |
155 | * Added an assets navigation tab, by pressing Ctrl+Tab
156 | * Added shortcut GUI elements to create new disks
157 | * Fixed a number clamp issue with the ranged slider controls
158 | * Fixed a wrong context menu appearance bug by right mouse click
159 |
160 | Player:
161 |
162 | * Added an option to disable pause on focus lost
163 |
164 | ### v1.4.6
165 |
166 | Driver:
167 |
168 | * Fixed a sharp/flat accidental issue with music playing
169 |
170 | Libraries:
171 |
172 | * Fixed a loop bug with the `PLAY` function
173 | * Fixed a deadlock issue with the `PLAY` function
174 |
175 | Editor:
176 |
177 | * Added an option to disable invoking the `GET_CLIPBOARD_TEXT` function
178 | * Added an option to disable invoking the `SYS` function
179 | * Fixed a real number input bug with different locales
180 |
181 | Player:
182 |
183 | * Added an option to disable invoking the `GET_CLIPBOARD_TEXT` function
184 | * Added an option to disable invoking the `SYS` function
185 |
186 | ### v1.4.5
187 |
188 | Driver:
189 |
190 | * Fixed a crash bug with the `LOAD_BLANK` function
191 | * Fixed an audio sampling issue
192 |
193 | Libraries:
194 |
195 | * Added rotation center specifier to the `SPR`, `SSPR`, `MAP`, `IMG`, `SIMG` functions
196 | * Fixed a crash bug with invalid file accessor
197 | * Fixed potential memory leaks when passing unexpected referenced values to some functions
198 |
199 | Editor:
200 |
201 | * Fixed a crash of wrong error raised with scriptable plugin
202 | * Fixed a target selection bug with scriptable plugin
203 |
204 | Player:
205 |
206 | * Added HTML player for web browsers, as experimental
207 |
208 | ### v1.4.4
209 |
210 | Language:
211 |
212 | * Added call stack checking to prevent stack overflow
213 |
214 | Libraries:
215 |
216 | * Fixed a directory path splitting bug
217 | * Fixed an unzipping bug with sub directories
218 |
219 | Editor:
220 |
221 | * Fixed a crash bug with invalid font setting
222 |
223 | Player:
224 |
225 | * Fixed a crash bug if error occurs at parsing time
226 |
227 | ### v1.4.3
228 |
229 | Language:
230 |
231 | * Fixed a crash bug in invalid conditional expression with class member
232 | * Fixed a wrong error with the `VAL` statement
233 |
234 | Libraries:
235 |
236 | * Added a `TRITEX` function to draw textured triangles
237 | * Fixed a pointing issue on touch screen with the `TOUCH` function
238 | * Fixed a matching issue with regex
239 |
240 | Editor:
241 |
242 | * Added an onscreen gamepad
243 | * Fixed a pointing issue on touch screen
244 | * Fixed a quitting bug when paused a running disk
245 |
246 | ### v1.4.2
247 |
248 | Editor:
249 |
250 | * Changed cursor drawing to always use system's way
251 | * Fixed a crash bug with plugin missing
252 |
253 | Player:
254 |
255 | * Fixed a termination issue with the `END` statement
256 | * Fixed a termination issue with errors
257 |
258 | ### v1.4.1
259 |
260 | Libraries:
261 |
262 | * Added a rotate parameter to the `MAP` function
263 | * Added JPG support to the image library
264 |
265 | Editor:
266 |
267 | * Added a scriptable plugin mechanism to paintable editors
268 | * Added JPG support to the quantized editor
269 | * Fixed a range selection bug with paintable assets
270 | * Fixed an Enter key handling issue on numeric pad in the code editor
271 |
272 | ### v1.4 Apr. 2018
273 |
274 | Driver:
275 |
276 | * Added a switch of automatic frame buffer clearing
277 | * Fixed a state checking bug with right mouse click
278 | * Fixed an accuracy issue with the `TOUCH` function
279 |
280 | Libraries:
281 |
282 | * Added a `CLS` function to clear frame buffer manually
283 | * Added a `SET_CLEARER` function to set the switch of automatic frame buffer clearing
284 | * Fixed a termination issue with music
285 |
286 | ### v1.3.4
287 |
288 | Language:
289 |
290 | * Fixed a boolean evaluating bug with library object
291 |
292 | Libraries:
293 |
294 | * Added an ID type to sound effect
295 | * Added a `WAVE` type to prefab sound effect
296 | * Added functionality to play prefab sound effect with wave object to the `SFX` function
297 | * Added a `STOP` function to stop any audio
298 |
299 | Editor:
300 |
301 | * Added an option to surf Steam pages using internal browser
302 | * Added a welcome page
303 | * Added a frame cache to the sprite editor
304 | * Fixed a tag setting bug with undo operation in the sprite editor
305 | * Fixed a preview issue with inactive map layers
306 | * Fixed an unsaved state issue with new created assets
307 |
308 | ### v1.3.3
309 |
310 | Driver:
311 |
312 | * Added an initialization procedure of the `TICKS` base to the boot program
313 |
314 | Libraries:
315 |
316 | * Added error prompt to the `PERSIST` function
317 | * Added return value to the `OPEN`, and `CLOSE` functions of the archive library
318 | * Added return value to the `OPEN`, and `CLOSE` functions of the database library
319 | * Added return value to the `OPEN`, and `CLOSE` functions of the file library
320 | * Added return value to the `OPEN`, and `CLOSE` functions of the network library
321 |
322 | ### v1.3.2
323 |
324 | Editor:
325 |
326 | * Added an outline view to the code editor
327 | * Fixed a text finding issue with whitespace
328 |
329 | ### v1.3.1
330 |
331 | Libraries:
332 |
333 | * Fixed a blank content issue with the `INPUT` statement
334 |
335 | Editor:
336 |
337 | * Added a disk filter
338 | * Added a sprite to GIF exporter
339 | * Fixed a GIF exporting issue with few color count at the beginning frame
340 | * Fixed an icon arranging issue
341 |
342 | ### v1.3 Mar. 2018
343 |
344 | Libraries:
345 |
346 | * Added a network library
347 | * Fixed popping issues with the bytes library
348 |
349 | Editor:
350 |
351 | * Fixed a key retrieving bug with input config
352 | * Fixed a program locating issue with long path
353 |
354 | Player:
355 |
356 | * Added native player for desktop systems, as experimental
357 |
358 | ### v1.2.3
359 |
360 | Added Linux version.
361 |
362 | Language:
363 |
364 | * Fixed a GC bug with the ranged `FOR` statement
365 | * Fixed a string assignment issue with class member
366 | * Fixed a termination issue with the `END` statement
367 |
368 | Driver:
369 |
370 | * Added fixed function pipeline
371 |
372 | Libraries:
373 |
374 | * Added a `COPY_TO` function to the file information library
375 | * Fixed a path resolving bug of file and directory with UTF-8 character
376 | * Fixed a crash bug with path concatenating
377 | * Fixed a packing issue for existing package with the archive library
378 |
379 | Editor:
380 |
381 | * Added automatic arranging feature to editor windows
382 | * Added a modification indicator to the code editor
383 | * Changed large quantized image to readonly, with configurable threshold
384 | * Fixed a crash bug with undo operation in the code editor
385 | * Fixed an execution issue with large entry code
386 |
387 | ### v1.2.2
388 |
389 | Added MacOS version.
390 |
391 | Editor:
392 |
393 | * Changed the scale item into the expendable bar
394 | * Fixed an error marking bug when importing another source code
395 | * Fixed some text finding issues in the code editor
396 | * Fixed a rendering issue with blank source code
397 |
398 | ### v1.2.1
399 |
400 | Driver:
401 |
402 | * Fixed a frame buffer filling issue
403 |
404 | Libraries:
405 |
406 | * Added a `RESIZE` function to the image library
407 | * Fixed an accessing bug with the `PGET` function
408 |
409 | Editor:
410 |
411 | * Fixed a string literal issue with uppercase
412 | * Fixed some coloring issues with syntax highlighting
413 |
414 | ### v1.2 Feb. 2018
415 |
416 | Libraries:
417 |
418 | * Fixed a vector calculation bug
419 |
420 | Editor:
421 |
422 | * Added syntax highlighting feature to the code editor
423 | * Added navigation methods in the code editor
424 | * Added default license to prebuilt source code
425 | * Fixed a crash bug when switching to layer 0 of a map, with invalid tool selected
426 |
427 | ### v1.1.2
428 |
429 | Language:
430 |
431 | * Fixed a crash bug with invalid collection index
432 | * Fixed a memory leak with invalid invoking
433 |
434 | Libraries:
435 |
436 | * Added a loading option to the `LOAD_BLANK` for quantized image
437 | * Added `TRI`, `TRIFILL` functions to draw triangles
438 | * Added `QUAD`, `QUADFILL` functions to draw quadrangles
439 | * Added `IGET`, `ISET` functions to access quantized image
440 | * Added a new constructor to `VEC2`
441 | * Fixed a palette color setting issue
442 | * Fixed a color interpolation bug
443 |
444 | Editor:
445 |
446 | * Added an editor for quantized image
447 |
448 | ### v1.1.1
449 |
450 | Libraries:
451 |
452 | * Changed IO functions to return uniformed separator
453 | * Fixed an out of bound bug with the pathfinding algorithm
454 | * Fixed a wrong loading bug of map assets if tiles missing
455 |
456 | Editor:
457 |
458 | * Changed disk overwriting to put files and directories into recycle bin
459 |
460 | ### v1.1 Jan. 2018
461 |
462 | Community:
463 |
464 | * Added tools for Steam Workshop
465 |
466 | Language:
467 |
468 | * Fixed a parsing bug with the unary negative operator
469 | * Fixed a real number parsing bug with different locales
470 |
471 | Libraries:
472 |
473 | * Added non-referenced vector and matrix data types, with operators and functions
474 | * Added a pathfinding algorithm
475 |
476 | Editor:
477 |
478 | * Added indicator of unsaved file
479 | * Added a dedicated file type for customized data
480 | * Fixed a running issue under offline mode with Steam
481 |
482 | ### v1.0 Jan. 2018
483 |
484 | Added Windows version. First release with features including:
485 |
486 | * Added a BASIC programming language
487 | * Added programming interfaces
488 | * Added GUI based shell
489 | * Added graphics primitives
490 | * Added input functions
491 | * Added audio functions
492 |
--------------------------------------------------------------------------------
/docs/imgs/coordinate.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/paladin-t/b8/f025e2555aac7afced7321419cee2619a17603e6/docs/imgs/coordinate.png
--------------------------------------------------------------------------------
/docs/imgs/head.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/paladin-t/b8/f025e2555aac7afced7321419cee2619a17603e6/docs/imgs/head.png
--------------------------------------------------------------------------------
/docs/imgs/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/paladin-t/b8/f025e2555aac7afced7321419cee2619a17603e6/docs/imgs/logo.png
--------------------------------------------------------------------------------
/docs/imgs/welcome.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/paladin-t/b8/f025e2555aac7afced7321419cee2619a17603e6/docs/imgs/welcome.png
--------------------------------------------------------------------------------
/docs/imgs/workshop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/paladin-t/b8/f025e2555aac7afced7321419cee2619a17603e6/docs/imgs/workshop.png
--------------------------------------------------------------------------------
/docs/imgs/workshop_mount.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/paladin-t/b8/f025e2555aac7afced7321419cee2619a17603e6/docs/imgs/workshop_mount.png
--------------------------------------------------------------------------------
/docs/imgs/workshop_push.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/paladin-t/b8/f025e2555aac7afced7321419cee2619a17603e6/docs/imgs/workshop_push.png
--------------------------------------------------------------------------------
/docs/imgs/workshop_remove.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/paladin-t/b8/f025e2555aac7afced7321419cee2619a17603e6/docs/imgs/workshop_remove.png
--------------------------------------------------------------------------------
/docs/imgs/workshop_submit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/paladin-t/b8/f025e2555aac7afced7321419cee2619a17603e6/docs/imgs/workshop_submit.png
--------------------------------------------------------------------------------
/docs/imgs/workshop_subscribe.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/paladin-t/b8/f025e2555aac7afced7321419cee2619a17603e6/docs/imgs/workshop_subscribe.png
--------------------------------------------------------------------------------
/docs/welcome.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | Press F1 to read the [manual](manual), or click to read about the [Workshop](workshop).
4 |
5 | Double click on a disk to run it directly (this behaviour could be changed by setting); right click on a disk then `Open` it for editing, it will show the entry source code of the disk, click corresponding items under the `Disk` menu on the main menu bar to create, open assets in the editing disk.
6 |
7 | Consider exploring the fantastic world of BASIC8 from [important](https://steamcommunity.com/app/767240/discussions/4/2906376154311390056/) notice, and [learning](https://steamcommunity.com/app/767240/discussions/4/1696040635922300967/) materials.
8 |
9 | There are also some extra tools available as regular disks on Workshop:
10 |
11 | * [Player Maker](https://steamcommunity.com/sharedfiles/filedetails/?id=1328727512)
12 | * [HTML Maker](https://steamcommunity.com/sharedfiles/filedetails/?id=1391948686)
13 | * [Wave Maker](https://steamcommunity.com/sharedfiles/filedetails/?id=1352790993)
14 |
15 | It's also possible to [bring your own tools](https://steamcommunity.com/sharedfiles/filedetails/?id=1350153766) with built-in libraries; and use [plugins](https://github.com/paladin-t/b8.plugins) to extend the editors.
16 |
--------------------------------------------------------------------------------
/docs/workshop.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | ## Sharing via Workshop
4 |
5 | You can share your creative disks with the Steam community via Workshop, subscribe to play others' games and programs, and discuss or comment on any creation.
6 |
7 | Don't forget to close any external editors that opening the source disk you are going to push, pull, etc.
8 |
9 | ### Submitting
10 |
11 | To submit a new disk to Workshop, select it, then click `Community`, `Workshop`, `Push`. It will prompt you to fill in some information as following:
12 |
13 | 
14 |
15 | It's recommended to use a good looking preview, choose a proper genre, and write necessary introduction and notes to help others to get better acquainted with your submission. Then click the `Push` button to submit it, with agreeing to the terms of service. You could edit submitted information in browser later, including changing description, chaging visibility, updating preview images and videos, etc.
16 |
17 | ### Subscribing
18 |
19 | Use a web browser to explore the [BASIC8 Workshop](https://steamcommunity.com/app/767240/workshop/) on Steam to make subscriptions:
20 |
21 | 
22 |
23 | All subscribed disks will be automatically downloaded for mounting. Notice that you still have to subscribe to your own disk to keep it up to date, if you were collaborating with other people on a same project.
24 |
25 | ### Unsubscribing
26 |
27 | Click `Unsubscribe` on an already subscribed disk in browser to stop following it.
28 |
29 | Unsubscribe mounted disk when removing it with `Unsubscribe` option checked, otherwise it will be removed from local storage only:
30 |
31 | 
32 |
33 | ### Pushing
34 |
35 | When you want to push modifications of a submitted disk, select the disk, then click `Community`, `Workshop`, `Push`. It will prompt you with a dialog (similar to submission):
36 |
37 | 
38 |
39 | It will download and re-mount the disk after success of either submitting and pushing, so **make backup as possible before pushing**, especially when you were collaborating with others.
40 |
41 | ### Pulling
42 |
43 | All subscribed disks are supposed to be updated automatically when BASIC8 boots up, but in case you'd like to check updates manually, just select it, click `Community`, `Workshop`, `Pull`. This will always prompt with a mounting dialog:
44 |
45 | 
46 |
47 | Choose a proper mounting strategy for pulled disk, check `Don't ask me` to make it quiet and keeps the current strategy for future updates. You could change the strategy later in the properties dialog of a disk.
48 |
49 | To pull all disks manually, click `Community`, `Workshop`, `Pull all`; or click `Force to pull all` with `Shift` key pressed to force it showing mounting options for all disks. It's required to have your Steam client to "online" mode to get subscriptions.
50 |
51 | ### Dismounting
52 |
53 | To make a disk into a local one by dismounting it, open the properties dialog of it, then click `Dismount`.
54 |
55 | [HOME](#sharing-via-workshop)
56 |
--------------------------------------------------------------------------------
/examples/Boing Ball/README.md:
--------------------------------------------------------------------------------
1 | ## Boing Ball
2 |
3 | ### Preview
4 |
5 | 
6 |
7 | ### Content
8 |
9 | [GitHub](https://github.com/paladin-t/b8/tree/master/examples/Boing%20Ball/content)
10 |
11 | ### Code at a glance
12 |
13 | ~~~~~~~~~~bas
14 | REM Boing Ball - Entry program
15 | REM Recreated of the classic Amiga demo.
16 | REM Based on Toddl's work:
17 | REM http://lowres.inutilis.com/programs/?lccpost=YDxBl4UZxp.
18 | REM
19 | REM Press Ctrl+R to run.
20 |
21 | REM Initializes the driver.
22 |
23 | drv = driver()
24 | print drv, ", detail type is: ", typeof(drv);
25 |
26 | REM Constants.
27 |
28 | ' Colors.
29 | RED = rgba(255, 0, 0)
30 | WHITE = rgba(255, 255, 255)
31 | ' How many radians is the ball tilted.
32 | ROTATE_ANGLE = 0.5
33 |
34 | REM Resources.
35 |
36 | the_ball = load_blank("sprite", 61, 61)
37 |
38 | REM Variables.
39 |
40 | white_start = 1
41 | ball_x = 5
42 | parabel_x = 0
43 | ball_dir = 1
44 | parabel_dir = 9.25
45 |
46 | REM Functions.
47 |
48 | ' Shows the background.
49 | def background()
50 | col rgba(225, 150, 225)
51 | for y = 0 to 111 step 16
52 | for x = 23 to 134 step 16
53 | rect x, y, x + 17, y + 17
54 | next
55 | next
56 | for x = 23 to 135 step 16
57 | line x, 112, (x - 80) / 96 * 160 + 81, 127
58 | next
59 | line 15, 116, 144, 116
60 | line 3, 121, 155, 121
61 | line 0, 127, 159, 127
62 | enddef
63 |
64 | ' Cycles the palette.
65 | def cycle_palette()
66 | white_start = white_start - ball_dir
67 | if white_start > 13 then white_start = 2
68 | if white_start < 2 then white_start = 13
69 | for ci = 0 to 11
70 | if ci < 6 then
71 | pv = RED
72 | else
73 | pv = WHITE
74 | endif
75 | c = (ci + (white_start - 2)) mod 12 + 2
76 | pset c, pv
77 | next
78 | enddef
79 |
80 | ' Draws one line of the ball.
81 | def plot_line(x)
82 | for y = 0 to PI step 0.008
83 | c0 = (floor((x + PI) * 15 + 0.5)) mod 12 + 2
84 | c1 = ((c0 - 2) + 6) mod 12 + 2
85 | v = 0
86 | if y * 2.5 mod 2 = 0 then
87 | v = c0
88 | else
89 | v = c1
90 | endif
91 | xx = sin(y) * cos(x) * 30
92 | yy = cos(y) * 30
93 | s = sin(ROTATE_ANGLE)
94 | c = cos(ROTATE_ANGLE)
95 | posx = xx * c - yy * s
96 | posy = xx * s + yy * c
97 | sset the_ball, 1, floor(posx + 30.5), floor(posy + 30.5), v
98 | next
99 | enddef
100 |
101 | ' The main loop.
102 | def update(delta)
103 | ' Shows the background.
104 | background()
105 | ' Processes bouncing.
106 | parabel_x = parabel_x + parabel_dir * delta
107 | ball_y = parabel_x * parabel_x * 1.5
108 | if ball_y >= 45 then
109 | ball_y = 45
110 | parabel_x = sqr(ball_y / 1.5)
111 | parabel_dir = -parabel_dir
112 | endif
113 | ' Moves the ball left and right.
114 | if ball_x <= 0 then
115 | ball_x = 0
116 | ball_dir = -ball_dir
117 | sfx 5,110,0.08
118 | elseif ball_x >= 99 then
119 | ball_x = 99
120 | ball_dir = -ball_dir
121 | sfx 5,110,0.08
122 | endif
123 | ball_x = ball_x + ball_dir * delta * 25
124 | ' Shows shadow of the ball.
125 | clip 23, 0, 113, 128
126 | circfill ball_x + 40, ball_y + 37, 30, rgba(20, 20, 20, 110)
127 | clip
128 | ' Cycles palette and shows the ball.
129 | cycle_palette()
130 | spr the_ball, ball_x, ball_y + 18
131 | if ball_y >= 45 then
132 | sfx 5,80,0.1
133 | endif
134 | enddef
135 |
136 | ' Prefabs the chequered ball.
137 | for i = 0 to 1
138 | text 80, 120, "LOADING..."
139 | sync
140 | next
141 | for x = 0 to PI / 2 + 0.025 step 0.025
142 | plot_line(x)
143 | next
144 | for x = PI to PI / 2 + 0.025 step -0.025
145 | plot_line(x)
146 | next
147 |
148 | ' Enters the main loop.
149 | update_with(drv, call(update))
150 | ~~~~~~~~~~
151 |
--------------------------------------------------------------------------------
/examples/Boing Ball/content/info.json:
--------------------------------------------------------------------------------
1 | {"lang":1,"usage":1,"ugcid":0,"uid":"31c579df-8f94-4b2d-8a9f-366207b29f4e","sticker":"sticker.png","title":"Boing Ball","description":"","author":"Tony","version":"1.1","genre":"Demo","email":"","url":"https://paladin-t.github.io/b8/examples/Boing%20Ball/","creation":1511589086,"controls":[],"entries":{"main":"main.bas","editor":""}}
--------------------------------------------------------------------------------
/examples/Boing Ball/content/main.bas:
--------------------------------------------------------------------------------
1 | REM Boing Ball - Entry program
2 | REM Recreated of the classic Amiga demo.
3 | REM Based on Toddl's work:
4 | REM http://lowres.inutilis.com/programs/?lccpost=YDxBl4UZxp.
5 | REM
6 | REM Press Ctrl+R to run.
7 |
8 | REM Initializes the driver.
9 |
10 | drv = driver()
11 | print drv, ", detail type is: ", typeof(drv);
12 |
13 | REM Constants.
14 |
15 | ' Colors.
16 | RED = rgba(255, 0, 0)
17 | WHITE = rgba(255, 255, 255)
18 | ' How many radians is the ball tilted.
19 | ROTATE_ANGLE = 0.5
20 |
21 | REM Resources.
22 |
23 | the_ball = load_blank("sprite", 61, 61)
24 |
25 | REM Variables.
26 |
27 | white_start = 1
28 | ball_x = 5
29 | parabel_x = 0
30 | ball_dir = 1
31 | parabel_dir = 9.25
32 |
33 | REM Functions.
34 |
35 | ' Shows the background.
36 | def background()
37 | col rgba(225, 150, 225)
38 | for y = 0 to 111 step 16
39 | for x = 23 to 134 step 16
40 | rect x, y, x + 17, y + 17
41 | next
42 | next
43 | for x = 23 to 135 step 16
44 | line x, 112, (x - 80) / 96 * 160 + 81, 127
45 | next
46 | line 15, 116, 144, 116
47 | line 3, 121, 155, 121
48 | line 0, 127, 159, 127
49 | enddef
50 |
51 | ' Cycles the palette.
52 | def cycle_palette()
53 | white_start = white_start - ball_dir
54 | if white_start > 13 then white_start = 2
55 | if white_start < 2 then white_start = 13
56 | for ci = 0 to 11
57 | if ci < 6 then
58 | pv = RED
59 | else
60 | pv = WHITE
61 | endif
62 | c = (ci + (white_start - 2)) mod 12 + 2
63 | pset c, pv
64 | next
65 | enddef
66 |
67 | ' Draws one line of the ball.
68 | def plot_line(x)
69 | for y = 0 to PI step 0.008
70 | c0 = (floor((x + PI) * 15 + 0.5)) mod 12 + 2
71 | c1 = ((c0 - 2) + 6) mod 12 + 2
72 | v = 0
73 | if y * 2.5 mod 2 = 0 then
74 | v = c0
75 | else
76 | v = c1
77 | endif
78 | xx = sin(y) * cos(x) * 30
79 | yy = cos(y) * 30
80 | s = sin(ROTATE_ANGLE)
81 | c = cos(ROTATE_ANGLE)
82 | posx = xx * c - yy * s
83 | posy = xx * s + yy * c
84 | sset the_ball, 1, floor(posx + 30.5), floor(posy + 30.5), v
85 | next
86 | enddef
87 |
88 | ' The main loop.
89 | def update(delta)
90 | ' Shows the background.
91 | background()
92 | ' Processes bouncing.
93 | parabel_x = parabel_x + parabel_dir * delta
94 | ball_y = parabel_x * parabel_x * 1.5
95 | if ball_y >= 45 then
96 | ball_y = 45
97 | parabel_x = sqr(ball_y / 1.5)
98 | parabel_dir = -parabel_dir
99 | endif
100 | ' Moves the ball left and right.
101 | if ball_x <= 0 then
102 | ball_x = 0
103 | ball_dir = -ball_dir
104 | sfx 5,110,0.08
105 | elseif ball_x >= 99 then
106 | ball_x = 99
107 | ball_dir = -ball_dir
108 | sfx 5,110,0.08
109 | endif
110 | ball_x = ball_x + ball_dir * delta * 25
111 | ' Shows shadow of the ball.
112 | clip 23, 0, 113, 128
113 | circfill ball_x + 40, ball_y + 37, 30, rgba(20, 20, 20, 110)
114 | clip
115 | ' Cycles palette and shows the ball.
116 | cycle_palette()
117 | spr the_ball, ball_x, ball_y + 18
118 | if ball_y >= 45 then
119 | sfx 5,80,0.1
120 | endif
121 | enddef
122 |
123 | ' Prefabs the chequered ball.
124 | for i = 0 to 1
125 | text 80, 120, "LOADING..."
126 | sync
127 | next
128 | for x = 0 to PI / 2 + 0.025 step 0.025
129 | plot_line(x)
130 | next
131 | for x = PI to PI / 2 + 0.025 step -0.025
132 | plot_line(x)
133 | next
134 |
135 | ' Enters the main loop.
136 | update_with(drv, call(update))
137 |
--------------------------------------------------------------------------------
/examples/Boing Ball/content/main.palette:
--------------------------------------------------------------------------------
1 | {"colors":[[0,0,0,0],[29,43,83,255],[126,37,83,255],[0,135,81,255],[171,82,54,255],[95,87,79,255],[194,195,199,255],[255,241,232,255],[255,0,77,255],[255,163,0,255],[255,236,39,255],[0,228,54,255],[41,173,255,255],[131,118,156,255],[255,119,168,255],[255,204,170,255]]}
--------------------------------------------------------------------------------
/examples/Boing Ball/content/sticker.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/paladin-t/b8/f025e2555aac7afced7321419cee2619a17603e6/examples/Boing Ball/content/sticker.png
--------------------------------------------------------------------------------
/examples/Cosmos Saga/README.md:
--------------------------------------------------------------------------------
1 | ## Cosmos Saga
2 |
3 | ### Preview
4 |
5 | 
6 |
7 | ### Content
8 |
9 | [GitHub](https://github.com/paladin-t/b8/tree/master/examples/Cosmos%20Saga/content)
10 |
11 | ### Code at a glance
12 |
13 | ~~~~~~~~~~bas
14 | REM Cosmos Saga - Entry program
15 | REM Shoot'em up, survive as long as you can.
16 | REM
17 | REM Press Ctrl+R to run.
18 | REM Control:
19 | REM Up/Down: move spaceship
20 | REM A: shoot
21 |
22 | REM Initializes the driver.
23 |
24 | drv = driver()
25 | print drv, ", detail type is: ", typeof(drv);
26 | use_sound_font("soundfonts/pixels.sf2")
27 |
28 | REM Constants.
29 |
30 | ' Colors.
31 | WHITE = rgba(255, 255, 255)
32 | ' Game stages.
33 | INTRO = 0
34 | PLAYING = 1
35 | LOSE = 2
36 | OVER = 3
37 | ' Enemy types.
38 | LETTER = 1
39 | INVADER = 2
40 | ' Gameplay.
41 | OWN_BULLETS_MAX_COUNT = 3
42 |
43 | REM Classes.
44 |
45 | class point
46 | var x = 0
47 | var y = 0
48 | endclass
49 | class bullet(point)
50 | var vx = 0
51 | endclass
52 | class explosion(point)
53 | var res = nil
54 | var elapsed = 0
55 | endclass
56 |
57 | REM Resources.
58 |
59 | title_bg = load_resource("title_bg.quantized")
60 | title_txt = load_resource("title_txt.quantized")
61 | over_txt = load_resource("over_txt.quantized")
62 | galaxy_scroll = load_resource("galaxy_scroll.map")
63 | galaxy1 = galaxy_scroll(1)
64 | galaxy2 = galaxy_scroll(2)
65 | galaxy3 = galaxy_scroll(3)
66 | explosion_bank = load_resource("explosion_bank.sprite")
67 | enemy_bank = load_resource("enemy_bank.sprite")
68 | spaceship = load_resource("spaceship.sprite")
69 | spaceship.play()
70 |
71 | REM Variables.
72 |
73 | ' Bullets and explosions.
74 | own_bullets = list()
75 | enemy_bullets = list()
76 | explosion_fxs = list()
77 | ' Enemies.
78 | spawning = nil
79 | alive_enemies = dict()
80 | dead_enemies = list()
81 | ' Gameplay.
82 | stage = INTRO
83 | score = 0
84 | highscore = 0
85 | persist highscore
86 | gx1 = 0
87 | gx2 = 0
88 | gx3 = 0
89 | sx = 8
90 | sy = 48
91 | t = 0
92 |
93 | REM Functions.
94 |
95 | ' Spawns an enemy.
96 | def spawn(t)
97 | ' Initializes variables.
98 | x = 160
99 | y = 0
100 | dy = 0
101 | mov = nil
102 | emt = nil
103 | ' Chooses behaviours according to enemy type.
104 | if t = LETTER then
105 | y = 48
106 | mov = lambda (delta)
107 | (
108 | x = x - delta * 24
109 | dy = sin(x / 4) * 20
110 | )
111 | elseif t = INVADER then
112 | y = rnd(0, 96)
113 | vx = 28
114 | vy = 0
115 | if rnd > 0.25 then
116 | vy = (sy - y) / (160 - sx) * vx
117 | endif
118 | mov = lambda (delta)
119 | (
120 | x = x - delta * vx
121 | dy = dy + vy * delta
122 | )
123 | emt = lambda (ty)
124 | (
125 | if rnd < 0.6 then
126 | b = new(bullet)
127 | b.x = x - 7
128 | b.y = ty + 8
129 | b.vx = -60
130 | push(enemy_bullets, b)
131 | sfx 4096+1,860,0.2, 1,380,0.01
132 | emt = nil
133 | endif
134 | )
135 | endif
136 | ' Returns an enemy closure.
137 | return lambda (e, delta)
138 | (
139 | mov(delta)
140 | ty = y + dy
141 | if x < 143 and emt then emt(ty)
142 | if x < -16 then
143 | push(dead_enemies, e)
144 | else
145 | for b in own_bullets
146 | if abs(ty + 8 - b.y) < 12 and x >= b.x and x <= b.x + 10 then ' The bullet has hit an enemy.
147 | b.x = 999 ' Moves it far away.
148 | if not exists(dead_enemies, e) then
149 | push(dead_enemies, e)
150 | score = score + 1
151 | if score > highscore then highscore = score
152 | endif
153 | ex = new(explosion)
154 | ex.x = x
155 | ex.y = ty
156 | ex.res = clone(explosion_bank)
157 | ex.res.play(-1, -1, false)
158 | push(explosion_fxs, ex)
159 | sfx 4096+5,260,0.8, 5,80,0.1
160 | endif
161 | next
162 | endif
163 | if stage < LOSE then
164 | if abs(x - sx) < 10 and abs(ty - sy) < 10 then stage = LOSE
165 | endif
166 | spr e, x, ty
167 | )
168 | enddef
169 |
170 | ' Initializes states, starts an enemy spawner, etc.
171 | def setup()
172 | ' Initializes variables.
173 | score = 0
174 | sx = 8
175 | sy = 48
176 | ' Clears collections.
177 | clear(alive_enemies)
178 | clear(dead_enemies)
179 | ' Starts an enemy spawner.
180 | if spawning then
181 | abort(spawning)
182 | spawning = nil
183 | endif
184 | spawning = coroutine
185 | (
186 | lambda ()
187 | (
188 | yield wait_for(1.0)
189 | ' "W".
190 | e = clone(enemy_bank)
191 | e.play("W", "WE")
192 | set(alive_enemies, e, spawn(LETTER))
193 | yield wait_for(0.8)
194 | ' "E".
195 | e = clone(enemy_bank)
196 | e.play("E", "EE")
197 | set(alive_enemies, e, spawn(LETTER))
198 | yield wait_for(0.8)
199 | ' "L".
200 | e = clone(enemy_bank)
201 | e.play("L", "LE")
202 | set(alive_enemies, e, spawn(LETTER))
203 | yield wait_for(0.8)
204 | ' "C".
205 | e = clone(enemy_bank)
206 | e.play("C", "CE")
207 | set(alive_enemies, e, spawn(LETTER))
208 | yield wait_for(0.8)
209 | ' "O".
210 | e = clone(enemy_bank)
211 | e.play("O", "OE")
212 | set(alive_enemies, e, spawn(LETTER))
213 | yield wait_for(0.8)
214 | ' "M".
215 | e = clone(enemy_bank)
216 | e.play("M", "ME")
217 | set(alive_enemies, e, spawn(LETTER))
218 | yield wait_for(0.8)
219 | ' "E".
220 | e = clone(enemy_bank)
221 | e.play("E", "EE")
222 | set(alive_enemies, e, spawn(LETTER))
223 | yield wait_for(2.8)
224 | ' Invaders.
225 | while true
226 | e = clone(enemy_bank)
227 | e.play("E1", "E1E")
228 | set(alive_enemies, e, spawn(INVADER))
229 | yield wait_for(rnd(700, 1800) / 1000)
230 | wend
231 | )
232 | )
233 | start(spawning)
234 | enddef
235 |
236 | ' Updates bullets.
237 | def pelter(delta)
238 | ' Updates own bullets.
239 | for b in own_bullets
240 | b.x = b.x + b.vx * delta
241 | line b.x, b.y, b.x + 10, b.y, 2, WHITE
242 | next
243 | if len(own_bullets) then
244 | b = get(own_bullets, 0)
245 | if b.x > 160 then
246 | remove(own_bullets, 0)
247 | endif
248 | endif
249 | ' Updates enemies' bullets.
250 | for b in enemy_bullets
251 | b.x = b.x + b.vx * delta
252 | line b.x, b.y, b.x + 10, b.y, 2, WHITE
253 | if stage < LOSE then
254 | if abs(sy + 8 - b.y) < 10 and sx + 16 >= b.x and sx + 16 <= b.x + 10 then stage = LOSE
255 | endif
256 | next
257 | if len(enemy_bullets) then
258 | b = get(enemy_bullets, 0)
259 | if b.x < -10 then
260 | remove(enemy_bullets, 0)
261 | endif
262 | endif
263 | enddef
264 |
265 | ' Updates all explosion effects.
266 | def boom(delta)
267 | for e in explosion_fxs
268 | e.elapsed = e.elapsed + delta
269 | spr e.res, e.x, e.y
270 | next
271 | if len(explosion_fxs) then
272 | e = get(explosion_fxs, 0)
273 | if e.elapsed > 1 then
274 | remove(explosion_fxs, 0)
275 | endif
276 | endif
277 | enddef
278 |
279 | ' Common routine of a galaxy scene.
280 | def galaxy(delta, sp)
281 | ' Updates scrolling variables.
282 | gx1 = gx1 - delta * 120
283 | if gx1 < -160 then gx1 = gx1 + 160
284 | gx2 = gx2 - delta * 150
285 | if gx2 < -160 then gx2 = gx2 + 160
286 | gx3 = gx3 - delta * 170
287 | if gx3 < -160 then gx3 = gx3 + 160
288 | ' Shows the two background layers.
289 | map galaxy1, gx1, 0
290 | map galaxy1, gx1 + 160, 0
291 | map galaxy2, gx2, 0
292 | map galaxy2, gx2 + 160, 0
293 | ' Shows the spaceship.
294 | if sp then spr spaceship, sx, sy
295 | ' Updates and shows all enemies.
296 | for i in alive_enemies
297 | ctrl = alive_enemies(i)
298 | ctrl(i, delta)
299 | next
300 | ' Shows the forground layer.
301 | map galaxy3, gx3, 0
302 | map galaxy3, gx3 + 160, 0
303 | ' Processes bullets and explosions.
304 | pelter(delta)
305 | boom(delta)
306 | ' Processes dead enemies.
307 | if len(dead_enemies) then
308 | for i in dead_enemies
309 | if exists(alive_enemies, i) then
310 | remove(alive_enemies, i)
311 | endif
312 | next
313 | clear(dead_enemies)
314 | endif
315 | ' Shows scores.
316 | text 0, 1, "SCORE:", WHITE
317 | text 47, 1, score, WHITE
318 | text 80, 1, "HI:", WHITE
319 | text 104, 1, highscore
320 | enddef
321 |
322 | ' Game over stage.
323 | def gameover(delta)
324 | ' If just lost.
325 | if stage = LOSE then
326 | t = 0
327 | stage = OVER
328 | if spawning then
329 | abort(spawning)
330 | spawning = nil
331 | endif
332 | clear(own_bullets)
333 | sfx 4,120,0.2, 4,0,0.2, 4,120,0.3, 4,140,0.3, 4,100,0.2, 4,0,0.2, 4,100,0.3
334 | ex = new(explosion)
335 | ex.x = sx
336 | ex.y = sy
337 | ex.res = clone(explosion_bank)
338 | ex.res.play(-1, -1, false)
339 | push(explosion_fxs, ex)
340 | sfx 4096+5,260,0.8, 5,80,0.1
341 | endif
342 | ' Updates the galaxy.
343 | galaxy(delta, false)
344 | ' Shows the "GAME OVER" text.
345 | img over_txt, 0, 128 * (3 - t) / 3
346 | ' Ticks.
347 | if t < 3 then
348 | t = t + delta
349 | if t > 3 then t = 3
350 | else
351 | if btnp() or keyp() then
352 | t = 0
353 | stage = INTRO
354 | endif
355 | endif
356 | enddef
357 |
358 | ' Battle stage.
359 | def battle(delta)
360 | ' Ticks.
361 | t = t + delta
362 | ' Processes input.
363 | if btn(2) then
364 | sy = sy - delta * 50
365 | if sy < 0 then sy = 0
366 | elseif btn(3) then
367 | sy = sy + delta * 50
368 | if sy >= 112 then sy = 111
369 | endif
370 | if btnp(4) then
371 | if len(own_bullets) < OWN_BULLETS_MAX_COUNT then
372 | b = new(bullet)
373 | b.x = sx + 16
374 | b.y = sy + 8
375 | b.vx = 60
376 | push(own_bullets, b)
377 | sfx 4096+2,860,0.2, 2,380,0.01
378 | endif
379 | endif
380 | ' Updates the galaxy.
381 | galaxy(delta, true)
382 | enddef
383 |
384 | ' Title stage.
385 | def title(delta)
386 | ' Plays music.
387 | if not bgm then
388 | bgm = true
389 | play "T128 F8G8A8B8 >C