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
// Odin + Box2D + Raylib example with stacking boxes and a shape attached to the cursor that can smack the shapes. | |
// Made (mostly) during this stream: https://www.youtube.com/watch?v=LYW7jdwEnaI | |
// I have updated this to use the `vendor:box2d` bindings instead of the ones I used on the stream. | |
package game | |
import b2 "vendor:box2d" | |
import rl "vendor:raylib" |
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
load_ttf_from_memory :: proc(file_data: []byte, font_size: int) -> rl.Font { | |
font := rl.Font { | |
baseSize = i32(font_size), | |
glyphCount = 95, | |
} | |
font.glyphs = rl.LoadFontData(&file_data[0], i32(len(file_data)), font.baseSize, {}, font.glyphCount, .DEFAULT) | |
if font.glyphs != nil { | |
font.glyphPadding = 4 |
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
// from https://odin-lang.org/docs/overview/#when-statements, see end of that section | |
package main | |
import "core:fmt" | |
import "core:mem" | |
main :: proc() { | |
when ODIN_DEBUG { | |
track: mem.Tracking_Allocator |
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
package assets_builder | |
import "core:fmt" | |
import "core:os" | |
import "core:strings" | |
import "core:path/slashpath" | |
import "core:hash" | |
dir_path_to_file_infos :: proc(path: string) -> []os.File_Info { | |
d, derr := os.open(path, os.O_RDONLY) |
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
Show hidden characters
{ | |
"selector": "source.odin", | |
"file_regex": "^(.+)\\(([0-9]+):([0-9]+)\\) (.+)$", | |
"file_patterns": ["*.odin"], | |
"cmd": ["build.bat"], | |
"working_dir": "c:/repos/cat-game", | |
"variants": [ | |
{ | |
"name": "run", | |
"cmd": "build.bat && start run.bat", |
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
// Handle-based array. Used like this: | |
// | |
// Entity_Handle :: distinct Handle | |
// entities: Handle_Array(Entity, Entity_Handle) | |
// | |
// It expects the type used (in this case | |
// Entity) to contains a field called | |
// `handle`, of type `Entity_Handle`. | |
// | |
// You can then fetch entities using |
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
[EditorTool("Tile Placer Tool", typeof(TileData))] | |
class TilePlacerTool : EditorTool | |
{ | |
private GUIContent m_iconContent; | |
void OnEnable() | |
{ | |
var icon = AssetDatabase.LoadAssetAtPath<Texture2D>("Assets/Textures/Editor/TileEditorIcon.png"); | |
// Icon for tools toolbar |
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
// D3D12 single-function triangle sample. | |
// | |
// Usage: | |
// - copy SDL2.dll from Odin/vendor/sdl2 to your project directory | |
// - odin run . | |
// | |
// Contributors: | |
// - Karl Zylinski <[email protected]> (version 1, version 3) | |
// - Jakub Tomšů (version 2) | |
// |
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
# Linearly propagates the error of a velocity given in celestial coordinates to cartesian via the | |
# formulas identical to the ones in function cartesian_velocity_from_celestial. | |
def celestial_coords_to_cartesian_error( | |
ra, dec, r, | |
ra_error, dec_error, r_error, | |
pmra, pmdec, rv, | |
pmra_error, pmdec_error, rv_error): | |
dvx_dra = -cos(dec)*sin(ra)*rv + r*cos(dec)*cos(ra)*pmra - r*sin(dec)*sin(ra)*pmdec | |
dvx_ddec = -sin(dec)*cos(ra)*rv - r*sin(dec)*sin(ra)*pmra + r*cos(dec)*cos(ra)*pmdec | |
dvx_dr = cos(dec)*sin(ra)*pmra + sin(dec)*cos(ra)*pmdec |
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
# propagates error of |v2 - v1| where v2 and v1 are vectors and parameters are in celestial coordinates | |
def celestial_magnitude_of_velocity_difference_error( | |
ra1_deg, dec1_deg, r1, | |
ra1_error_deg, dec1_error_deg, r1_error, | |
pmra1_deg_per_s, pmdec1_deg_per_s, rv1, | |
pmra1_error_deg_per_s, pmdec1_error_deg_per_s, rv1_error, | |
ra2_deg, dec2_deg, r2, | |
ra2_error_deg, dec2_error_deg, r2_error, | |
pmra2_deg_per_s, pmdec2_deg_per_s, rv2, | |
pmra2_error_deg_per_s, pmdec2_error_deg_per_s, rv2_error): |