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
1: Introduction | |
1.1: Why learn Odin? | |
1.2: Overview | |
1.3: Installing the Odin compiler | |
1.4: If you get stuck | |
1.5: Let's go! | |
2: Hellope! A tiny program | |
2.1: Compile and run the code | |
2.2: Line-by-line |
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 runefun | |
import fmt "core:fmt" | |
import "core:unicode/utf8" | |
main :: proc() { | |
str := "小猫咪" | |
// i is the byte index | |
for r, i in str { |
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 open_win32_window | |
import win "core:sys/windows" | |
main :: proc() { | |
instance := win.HINSTANCE(win.GetModuleHandleW(nil)) | |
assert(instance != nil, "Failed to fetch current instance") | |
class_name := win.L("Windows Window") | |
cls := win.WNDCLASSW { |
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
// extra things I add to hot reload script to make auto reload work | |
odin build file_version_builder | |
IF %ERRORLEVEL% NEQ 0 exit /b 1 | |
file_version_builder.exe | |
IF %ERRORLEVEL% NEQ 0 exit /b 1 |
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
Rect :: struct { | |
x: f32, | |
y: f32, | |
width: f32, | |
height: f32, | |
} | |
cut_rect_top :: proc(r: ^Rect, y: f32, m: f32) -> Rect { | |
res := r^ | |
res.y += m |
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
refresh_padded_tileset :: proc() { | |
if g_mem.tileset_padded.id != 0 { | |
rl.UnloadTexture(g_mem.tileset_padded) | |
g_mem.tileset_padded = {} | |
} | |
ts_source := load_image(.Tileset) | |
defer rl.UnloadImage(ts_source) | |
tileset_height := ts_source.height / TileHeight |
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
{ | |
"folders": | |
[ | |
{ | |
"path": ".", | |
}, | |
], | |
"build_systems": | |
[ | |
{ |
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 game | |
import rl "vendor:raylib" | |
import "core:mem" | |
import "core:fmt" | |
import "core:encoding/json" | |
import "core:os" | |
Animation_Name :: enum { | |
Idle, |
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 |
NewerOlder