This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local aspect_ratio = 4 / 3 | |
| local game_width = 1000 | |
| local game_height = game_width / aspect_ratio | |
| local bat_height = 200 | |
| local bat_width = 30 | |
| local bats = {} | |
| local bat_lerp = 8 | |
| local ball_dimension = 25 | |
| local ball_speed = 0 | |
| local ball = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local ffi = require "ffi" | |
| ffi.cdef [[ | |
| typedef struct { | |
| float x; | |
| float y; | |
| } vector; | |
| ]] | |
| local storage_size = 8096 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function rewrite_sprite_sheet_with_extruded_borders(file_name, sheet_columns, sheet_rows) | |
| local source_data = love.image.newImageData("resources/" .. file_name) | |
| local padding = vector(2, 2) | |
| local sprite_size = vector(source_data:getWidth() / sheet_columns, source_data:getHeight() / sheet_rows) | |
| local target_container_size = sprite_size + padding | |
| local output = love.image.newImageData(sheet_columns * target_container_size.x, sheet_rows * target_container_size.y) | |
| for column = 0, sheet_columns - 1 do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function frame_scrollbar(content_height) | |
| local frame = get_current_frame() | |
| local frame_origin = get_frame_origin() | |
| local frame_size = get_frame_size() | |
| local frame_height = frame_size.y | |
| local scrollbar_height_relative = frame_height / content_height | |
| if scrollbar_height_relative >= 1 then | |
| return | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| bool mat4_invert(mat4& m, mat4& inv) { | |
| double det; | |
| inv.m11 = m.m22 * m.m33 * m.m44 - | |
| m.m22 * m.m34 * m.m43 - | |
| m.m32 * m.m23 * m.m44 + | |
| m.m32 * m.m24 * m.m43 + | |
| m.m42 * m.m23 * m.m34 - | |
| m.m42 * m.m24 * m.m33; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <chrono> | |
| const int total_objects = 10000; | |
| int group_identifiers[] = { | |
| 123, | |
| 20, | |
| 3, | |
| 41, | |
| 5893, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <chrono> | |
| struct Object { | |
| int property_to_sort_by; | |
| int property_to_group_by; | |
| }; | |
| int compare_objects(const void* a, const void* b) { | |
| Object* left = (Object*) a; | |
| Object* right = (Object*) b; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Folder_Color* string_to_folder_color(String string) { | |
| static Folder_Color None(0, 0xff555555, 0); | |
| static Folder_Color Purple1(0xFFE1BEE7, 0xff8e24aa, 0xffeecbf4); | |
| static Folder_Color Purple2(0xFFCE93D8, 0xff8e24aa, 0xffe4a8ee); | |
| static Folder_Color Purple3(0xFFBA68C8, 0xfff3e5f5, 0xffcb75da); | |
| static Folder_Color Purple4(0xFF8E24AA, 0xfff3e5f5, 0xffa637c5); | |
| static Folder_Color Indigo1(0xFFD1C4E9, 0xff5e35b1, 0xffddd0f5); | |
| static Folder_Color Indigo2(0xFFB39DDB, 0xff5e35b1, 0xffc7b0ef); | |
| static Folder_Color Indigo3(0xFF9575CD, 0xffede7f6, 0xffa281dd); | |
| static Folder_Color Indigo4(0xFF5E35B1, 0xffede7f6, 0xff7146ca); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static u32 color_name_to_color_argb(String &color_name) { | |
| char c = *color_name.start; | |
| switch (color_name.length) { | |
| // Red | |
| case 3: return 0xFFE91E63; | |
| case 4: { | |
| if (c == 'B'/*lue*/) return 0xFF2196F3; else | |
| if (c == 'G'/*ray*/) return 0xFF9E9E9E; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const naive_search_index = []; | |
| for (let folder of folders) { | |
| naive_search_index.push({ | |
| name: folder.title.toLowerCase(), | |
| id: string_id_to_number(folder.id) | |
| }); | |
| } |