Merge text0
[?]
Apr 10, 2023, 4:03 AM
THJX6RCJEMADQ3O6UOXA5DMGVGHMVKZHG4U7IUEV5E75FC3XRHXQCDependencies
- [2]
JNJ4R56Xsupport running tests multiple times - [3]
N2NUGNN4include a brief reference enabling many useful apps - [4]
HLIF3YQEMerge text0 - [*]
3QNOKBFMbeginnings of a test harness
Change contents
- replacement in reference.md at line 1
# Some useful building blocks# Building blocks for your Freewheeling AppsFreewheeling apps consist of 4 kinds of things:- a small number of functions you can define that get automatically calledfor you as appropriate,- a wide variety of primitives that you can call but not modify,- tests that start with `test_` and run on startup or after any change youmake to the app's code, and- any other function you can define and call at will. - replacement in reference.md at line 11
Apps can be composed of a wide variety of building blocks that youcan use in your functions, including a small number of functions that getautomatically called for you as appropriate.The rest of this document will summarize what is available to you in the firsttwo categories. - replacement in reference.md at line 21
## Functions that get automatically called* `App.initialize_globals()` -- called before running each test and alsobefore the app starts up. As the name suggests, use this to initialize allyour global variables to something consistent. I also find it useful to beable to see all my global variables in one place, and avoid definingtop-level variables anywhere else (unless they're constants and never goingto be modified).## Functions you can implement that will get automatically called - replacement in reference.md at line 23
* `App.initialize(arg)` -- called when app starts up after`App.initialize_globals`. Provides in `arg` an array of words typed in ifyou ran it from a terminal window.* `on.initialize(arg)` -- called when app starts up. Provides in `arg` anarray of words typed in if you ran it from a terminal window. - replacement in reference.md at line 27
* `App.quit()` -- called before the app shuts down.* `on.quit()` -- called before the app shuts down. - replacement in reference.md at line 30
* `App.focus(start?)` -- called when the app starts or stops receiving* `on.save_settings()` -- called after on.quit and should return a table whichwill be saved to disk.* `on.load_settings(settings)` -- called when app starts up, before`on.initialize`. Provides in `settings` the table that was saved to disk thelast time the app shut down.* `on.focus(start?)` -- called when the app starts or stops receiving - replacement in reference.md at line 42
* `App.resize(w,h)` -- called when you resize the app window. Provides new* `on.resize(w,h)` -- called when you resize the app window. Provides new - replacement in reference.md at line 48
* `App.filedropped(file)` -- called when a file icon is dragged and dropped on* `on.file_drop(file)` -- called when a file icon is dragged and dropped on - replacement in reference.md at line 57
* `App.draw()` -- called to draw on the window, around 30 times a second.* `on.code_change()` -- called when you make changes to the app using[driver.love](https://git.sr.ht/~akkartik/driver.love), any time you hit`f4` inside driver.love, after a definition is created or modified.* `on.draw()` -- called to draw on the window, around 30 times a second. - replacement in reference.md at line 64
* `App.update(dt)` -- called after every call to `on.draw`. Make changes to* `on.update(dt)` -- called after every call to `on.draw`. Make changes to - replacement in reference.md at line 70
* `App.mousepressed(x,y, mouse_button)` -- called when you press down on amouse button. Provides in `x` and `y` the point on the screen at which theclick occurred, and in `mouse_button` an integer id of the mouse buttonpressed.* `on.mouse_press(x,y, mouse_button)` -- called when you press down on a mousebutton. Provides in `x` and `y` the point on the screen at which the clickoccurred, and in `mouse_button` an integer id of the mouse button pressed. - replacement in reference.md at line 78
* `App.mousereleased(x,y, mouse_button)` -- called when you release a mouse* `on.mouse_release(x,y, mouse_button)` -- called when you release a mouse - replacement in reference.md at line 82
* `App.wheelmoved(dx,dy)` -- called when you use the scroll wheel on a mousethat has it. Provides in `dx` and `dy` an indication of how fast the wheelis being scrolled. Positive values for `dx` indicate movement to the right.Positive values for `dy` indicate upward movement.* `on.mouse_wheel_move(dx,dy)` -- called when you use the scroll wheel on amouse that has it. Provides in `dx` and `dy` an indication of how fast thewheel is being scrolled. Positive values for `dx` indicate movement to theright. Positive values for `dy` indicate upward movement. - replacement in reference.md at line 88
* `App.keychord_press(chord, key)` -- called when you press a key-combination.* `on.keychord_press(chord, key)` -- called when you press a key-combination. - replacement in reference.md at line 98
* `App.textinput(t)` -- called when you press a key combination that yields* `on.text_input(t)` -- called when you press a key combination that yields - replacement in reference.md at line 103
* `App.keyrelease(key)` -- called when you press a key on the keyboard.* `on.key_release(key)` -- called when you press a key on the keyboard. - edit in app.lua at line 56
App.screen.draw = love.graphics.draw