1**Bidi** is a lightweight framework and/or fantasy console designed for
2creating tiny video games, perfect for learning and having fun. It takes heavy
3inspiration from [LÖVE](https://www.love2d.org/),
4[Pico8](https://www.lexaloffle.com/pico-8.php), [Atari
52600](https://en.wikipedia.org/wiki/Atari_2600) and [Windows
63.1](https://en.wikipedia.org/wiki/Windows_3.1).
7
8> [!IMPORTANT]
9> The Raylib library in the `vendor` folder contains prebuilt artifacts. All
10> libraries are also available in the `archive` folder. You can manually
11> download and replace them from official repositories if desired; they have
12> not been tampered with.
13
14## Documentation
15
16### Quick example
17
18```lua
19-- mygame.lua
20-- bidi -f mygame.lua
21
22open_window(800, 800, "My Game")
23set_fps(60)
24
25axe_image = load_image("images/axe.png")
26slash_effect = load_sound("sounds/slash.wav")
27
28while window_running() do
29 start_drawing()
30 clear_window(color.BLACK)
31
32 draw_rect(100, 100, 300, 200, color.YELLOW)
33 draw_text("Label text", 10, 10, 20, color.VIOLET)
34 draw_line(400, 10, 500, 100, color.RED)
35 draw_circle(500, 500, 100, color.BLUE)
36 draw_ellipse(200, 500, 100, 50, color.BLUE)
37 draw_triangle(20, 20, 100, 20, 50, 100, color.BLUE)
38 draw_text(string.format("fps: %d", get_fps()), 10, 30, 20, color.VIOLET)
39 draw_text(string.format("dt: %.3f", get_dt()), 10, 50, 20, color.VIOLET)
40
41 if button_down(button.PAD_UP) then
42 draw_text("Pad Up", 10, 10, 20, color.VIOLET)
43 end
44
45 if button_pressed(button.A) then
46 play_sound(slash_effect)
47 end
48
49 draw_image(axe_image, 100, 200)
50
51 draw_info()
52 stop_drawing()
53end
54
55close_window()
56```
57
58### Included functions
59
60| Function | Arguments | Returns |
61| ---------------- | ------------------------------------------------------------------------------------------- | -------- |
62| `open_window` | `number width`, `number height`, `string title` | |
63| `close_window` | | |
64| `window_running` | | `bool` |
65| `start_drawing` | | |
66| `stop_drawing` | | |
67| `clear_window` | `color color` | |
68| `start_camera` | | |
69| `stop_camera` | | |
70| `move_camera` | `number x`, `number y` | |
71| `set_fps` | `number fps` | |
72| `get_fps` | | `number` |
73| `get_dt` | | `number` |
74| `get_time` | | `number` |
75| `get_width` | | `number` |
76| `get_height` | | `number` |
77| `draw_info` | | |
78| `draw_rect` | `number x`, `number y`, `number width`, `number height`, `color color` | |
79| `draw_text` | `string text`, `number x`, `number y`, `number font_size`, `color color` | |
80| `draw_pixel` | `number x`, `number y`, `color color` | |
81| `draw_line` | `number x1`, `number y1`, `number x2`, `number y2`, `color color` | |
82| `draw_circle` | `number center_x`, `number center_y`, `number radius`, `color color` | |
83| `draw_ellipse` | `number center_x`, `number center_y`, `number radius_h`, `number radius_v`, `color color` | |
84| `draw_triangle` | `number x1`, `number y1`, `number x2`, `number y2`, `number x3`, `number y3`, `color color` | |
85| `load_image` | `string filepath` | `uid` |
86| `draw_image` | `uid uid`, `number x`, `number y` | |
87| `button_down` | `button button` | `bool` |
88| `button_pressed` | `button button` | `bool` |
89| `load_sound` | `string filepath` | `uid` |
90| `play_sound` | `uid uid` | |
91| `stop_sound` | `uid uid` | |
92
93### Controller mappings
94
95| Button | Keyboard | Xbox | Playstation |
96| ------------------ | ------------- | ------------- | ------------- |
97| `button.PAD_UP` | `Arrow Up` | `D-pad Up` | `D-pad Up` |
98| `button.PAD_DOWN` | `Arrow Down` | `D-pad Down` | `D-pad Down` |
99| `button.PAD_LEFT` | `Arrow Left` | `D-pad Left` | `D-pad Left` |
100| `button.PAD_RIGHT` | `Arrow Right` | `D-pad Right` | `D-pad Right` |
101| `button.A` | `A` | `A` | `Cross` |
102| `button.B` | `S` | `B` | `Circle` |
103| `button.X` | `Q` | `X` | `Square` |
104| `button.Y` | `W` | `Y` | `Triangle` |
105| `button.SELECT` | `D` | `Back` | `Share` |
106| `button.START` | `E` | `Start` | `Options` |
107
108### Default colors
109
110| Color Name | Red (r) | Green (g) | Blue (b) | Alpha (a) |
111| ------------------ | ------- | --------- | -------- | --------- |
112| `color.LIGHTGRAY` | 200 | 200 | 200 | 255 |
113| `color.GRAY` | 130 | 130 | 130 | 255 |
114| `color.DARKGRAY` | 80 | 80 | 80 | 255 |
115| `color.YELLOW` | 253 | 249 | 0 | 255 |
116| `color.GOLD` | 255 | 203 | 0 | 255 |
117| `color.ORANGE` | 255 | 161 | 0 | 255 |
118| `color.PINK` | 255 | 109 | 194 | 255 |
119| `color.RED` | 230 | 41 | 55 | 255 |
120| `color.MAROON` | 190 | 33 | 55 | 255 |
121| `color.GREEN` | 0 | 228 | 48 | 255 |
122| `color.LIME` | 0 | 158 | 47 | 255 |
123| `color.DARKGREEN` | 0 | 117 | 44 | 255 |
124| `color.SKYBLUE` | 102 | 191 | 255 | 255 |
125| `color.BLUE` | 0 | 121 | 241 | 255 |
126| `color.DARKBLUE` | 0 | 82 | 172 | 255 |
127| `color.PURPLE` | 200 | 122 | 255 | 255 |
128| `color.VIOLET` | 135 | 60 | 190 | 255 |
129| `color.DARKPURPLE` | 112 | 31 | 126 | 255 |
130| `color.BEIGE` | 211 | 176 | 131 | 255 |
131| `color.BROWN` | 127 | 106 | 79 | 255 |
132| `color.DARKBROWN` | 76 | 63 | 47 | 255 |
133| `color.WHITE` | 255 | 255 | 255 | 255 |
134| `color.BLACK` | 0 | 0 | 0 | 255 |
135| `color.BLANK` | 0 | 0 | 0 | 0 |
136| `color.MAGENTA` | 255 | 0 | 255 | 255 |
137
138#### Using custom colors
139
140Color is essentially a structure with RGBA data. So constructing new colors is
141very easy.
142
143Alpha channel can be omitted and will by default be 255.
144
145```lua
146-- my_game.lua
147
148open_window(800, 800, "My Game")
149set_fps(60)
150
151my_color1 = { r = 200, g = 200, b = 200, a = 255 }
152my_color2 = { r = 200, g = 200, b = 200 }
153
154while window_running() do
155 start_drawing()
156 clear_window(color.BLACK)
157
158 draw_rect(100, 100, 100, 100, my_color1)
159 draw_rect(300, 100, 100, 100, my_color2)
160
161 draw_info()
162 stop_drawing()
163end
164
165close_window()
166```
167
168## Libraries & Assets
169
170- https://github.com/rxi/microtar
171- https://github.com/lua/lua
172- https://github.com/raysan5/raylib
173- https://github.com/rxi/json.lua
174- https://dejavu-fonts.github.io/
175- https://freetestdata.com/audio-files/
176
177## Cool tools
178
179- Controller testing:
180 - https://hardwaretester.com/gamepad
181 - https://www.raylib.com/examples/core/loader.html?name=core_input_gamepad
182- Sound effect generators:
183 - https://www.bfxr.net
184 - https://sfxr.me
185
186## Interesting games
187
188- https://www.old-games.com/download/3873/aethra-s-chronicles
189- https://www.old-games.com/download/10746/wintrek-1992
190- https://www.old-games.com/download/3887/bard-s-tale-1
191- https://www.old-games.com/download/3902/castle-of-the-winds
192- https://www.old-games.com/download/3923/decker
193- https://www.old-games.com/download/3920/darkspyre
194- https://www.old-games.com/download/6089/exile-3-ruined-world
195
196## Development references
197
198- https://www.love2d.org/wiki/Main_Page
199- https://www.lexaloffle.com/dl/docs/pico-8_manual.html
200- https://home.cs.colorado.edu/~main/bgi/doc/