This file contains 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
// A small test program of me trying Odin + Box2D + Raylib | |
// Made during this stream: https://www.youtube.com/watch?v=LYW7jdwEnaI | |
// I used these bindings https://github.com/cr1sth0fer/odin-box2d download them and put them in a sub-folder "box2d" next to this file. | |
// Then you can build using `odin run .` | |
package game | |
import b2 "box2d" | |
import rl "vendor:raylib" |
This file contains 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 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 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 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 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 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. | |
// Contributors: Karl Zylinski <karl@zylinski.se> | |
// Based on: https://github.com/rdunnington/d3d12-hello-triangle/blob/master/main.c | |
package d3d12_triangle | |
import "core:fmt" | |
import "core:mem" | |
import "core:sys/windows" | |
import "core:os" |
This file contains 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 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): |
This file contains 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 <stdio.h> | |
#include <stdlib.h> | |
#include <assert.h> | |
#include <string.h> | |
struct Color | |
{ | |
unsigned char r, g, b; | |
}; |
NewerOlder