-use package core
-use package glfw3
-use package opengles
-use package stb_truetype
+use core
+use glfw3
+use opengles
+use stb_truetype
#local {
world_shader: Shader;
-use package core
-use package opengles
+use core
+use opengles
Canvas :: struct {
-use package core
-use package core.intrinsics.onyx {__zero_value}
-use package stb_truetype
-use package opengles
+use core
+use core.intrinsics.onyx {__zero_value}
+use stb_truetype
+use opengles
#local {
font_registry: Map(FontDescriptor, Font);
-use package core
-use package opengles
-use package glfw3
+use core
+use opengles
+use glfw3
immediate_init :: () {
vertex_data = make([] Immediate_Vertex, Maximum_Vertex_Count);
-use package core
-use package opengles
+use core
+use opengles
Mesh :: struct (Vertex_Type: type_expr) {
handle: GLint;
glBindBuffer(GL_ARRAY_BUFFER, mesh.vertex_handle);
glBufferData(GL_ARRAY_BUFFER, sizeof T * verticies.count, verticies.data, gl_hint);
- type_info :: package runtime.info
+ type_info :: runtime.info
vertex_info := cast(^type_info.Type_Info_Struct) type_info.get_type_info(T);
vertex_attr := 0;
for attr: vertex_info.members {
-use package core
-use package opengles
+use core
+use opengles
Shader :: struct {
vs, fs: GLuint;
}
shader_block_create :: (T: type_expr) -> Shader_Block {
- type_info :: package runtime.info
+ type_info :: runtime.info
// This is 2 beacuse the window and world matrix blocks are
// not allocated using this procedure.
}
shader_block_update :: (s: ^Shader_Block, field: str, value: $T) {
- type_info :: package runtime.info
+ type_info :: runtime.info
glBindBuffer(GL_UNIFORM_BUFFER, s.block_buffer);
defer glBindBuffer(GL_UNIFORM_BUFFER, -1);
-use package core
-use package core.intrinsics.onyx { __zero_value as Zero }
-use package opengles
-use package stb_image
+use core
+use core.intrinsics.onyx { __zero_value as Zero }
+use opengles
+use stb_image
#local texture_cache: Map(str, Texture);
//
package ui
-use package core
-use package opengles
-use package glfw3
-use package main
+use core
+use opengles
+use glfw3
+use main
UI_Id :: u32
scroll_states : Map(UI_Id, Scroll_State);
get_site_hash :: macro (site: CallSite, increment := 0) -> UI_Id {
- hash :: package core.hash
- file_hash := hash.to_u32(site.file);
- line_hash := hash.to_u32(site.line);
- column_hash := hash.to_u32(site.column);
+ file_hash := core.hash.to_u32(site.file);
+ line_hash := core.hash.to_u32(site.line);
+ column_hash := core.hash.to_u32(site.column);
return ~~ (file_hash * 0x472839 + line_hash * 0x6849210 + column_hash * 0x1248382 + increment);
}
-use package glfw3
-@GlobalVariable window: GLFWwindow_p;
+@GlobalVariable window: glfw3.GLFWwindow_p;
debug_screen := false;
-use package core
-use package glfw3
-use package opengles
+use core
+use glfw3
+use opengles
#local {
ip_addr: [..] u8;
init :: (_: rawptr) {
array.clear(^port);
port_buffer: [8] u8;
- string.concat(^port, conv.format(port_buffer, "{}", (package runtime.vars).Game_Port));
+ string.concat(^port, conv.format(port_buffer, "{}", runtime.vars.Game_Port));
title_font = font_lookup(.{"./assets/fonts/calibri.ttf", 64});
package game_net
#local {
- use package core
- use package main
- onet :: package onyx_net
- packets :: package packets
+ use core
+ use main
+ onet :: onyx_net
}
#tag Packet_Handler.{ .Verify_Connect }
package game_net
#local {
- use package core
- use package main
- onet :: package onyx_net
- packets :: package packets
+ use core
+ use main
+ onet :: onyx_net
}
register_handles :: () {
- use package runtime.info;
+ use runtime.info;
procs := get_procedures_with_tag(Packet_Handler);
defer delete(^procs);
package game_net
#local {
- use package core
- use package main
- onet :: package onyx_net
- packets :: package packets
+ use core
+ use main
+ onet :: onyx_net
}
send_connect :: (name: str) {
msg := cast(^packets.Connect) calloc(sizeof packets.Connect + name.count);
msg.type = .Connect;
- msg.client_version = (package runtime.vars).Game_Version;
+ msg.client_version = runtime.vars.Game_Version;
msg.name_length = ~~ name.count;
memory.copy(~~ ^msg.name_data, name.data, name.count);
-use package core
+use core
@GlobalVariable
camera: Camera;
-use package core
+use core
Color :: struct {
r, g, b : f32;
-use package core
-use package glfw3
+use core
+use glfw3
// If you are offseting the mouse coordinate for world space
// or UI scrolling etc., set this function to be the function
// This may become an in-game or external file logger in the future,
// but for now this is just for logging to the command line.
-use package core
+use core
Enable_Log_Colors :: false
-use package core
+use core
Ray :: struct {
origin, direction: Vector3;
-#local hash :: package core.hash
-
#tag conv.Custom_Format.{format_vector2i}
#tag conv.Custom_Parse.{parse_vector2i}
Vector2i :: struct {
#operator * macro (v: Vector2i, s: i32) => (typeof v ).{ v.x * s, v.y * s };
#operator * macro (v1, v2: Vector2i) => (typeof v1).{ v1.x * v2.x, v1.y * v2.y };
#operator == macro (v1, v2: Vector2i) => v1.x == v2.x && v1.y == v2.y;
-#match hash.to_u32 macro (v: Vector2i) => 13 * v.x + 17 * v.y;
+#match core.hash.to_u32 macro (v: Vector2i) => 13 * v.x + 17 * v.y;
#operator + macro (v1, v2: Vector2) => (typeof v1).{ v1.x + v2.x, v1.y + v2.y };
#operator - macro (v1, v2: Vector2) => (typeof v1).{ v1.x - v2.x, v1.y - v2.y };
#operator == macro (v1, v2: Vector3i) => v1.x == v2.x && v1.y == v2.y && v1.z == v2.z;
#local {
- conv :: package core.conv
+ conv :: core.conv
format_vector2i :: (output: ^conv.Format_Output, format: ^conv.Format, v: ^Vector2i) {
conv.format(output, "({}, {})", v.x, v.y);
}
parse_vector2i :: (output: ^Vector2i, line_: str, string_allocator: Allocator) -> bool {
- string :: package core.string
-
line := line_;
- xs := string.read_until(^line, #char " ");
- string.advance(^line, 1);
- ys := string.read_until(^line, #char " ");
+ xs := core.string.read_until(^line, #char " ");
+ core.string.advance(^line, 1);
+ ys := core.string.read_until(^line, #char " ");
if xs == "" || ys == "" do return false;
}
parse_vector2 :: (output: ^Vector2, line_: str, string_allocator: Allocator) -> bool {
- string :: package core.string
-
line := line_;
- xs := string.read_until(^line, #char " ");
- string.advance(^line, 1);
- ys := string.read_until(^line, #char " ");
+ xs := core.string.read_until(^line, #char " ");
+ core.string.advance(^line, 1);
+ ys := core.string.read_until(^line, #char " ");
if xs == "" || ys == "" do return false;
-use package core
-use package opengles
+use core
+use opengles
Chunk_Vertex :: struct {
position : Vector3;
-use package core
+use core
AABB :: struct {
x0, y0, z0, x1, y1, z1: f32;
-use package core
-use package glfw3
+use core
+use glfw3
Player :: struct {
camera: ^Camera; // Should the camera exist on the player? Or should the player just control the camera?
-use package core
+use core
Remote_Player :: struct {
name: str;
-use package core
+use core
World :: struct {
chunk_dist: i32;
-use package core
-#local perlin :: package perlin
+use core
#local seed :: 8675309
#load "core/std"
-#local runtime :: package runtime
#load_path "./../src/server"
#library_path "./lib"
-use package core
-use package core.intrinsics.onyx {__initialize}
+use core
+use core.intrinsics.onyx {__initialize}
-#local {
- onet :: package onyx_net
- packets :: package packets
-}
+#local onet :: onyx_net
Player_Data :: struct {
id: u16;
setup_server :: () {
addr: net.Socket_Address;
- addr.port = (package runtime.vars).Game_Port;
+ addr.port = runtime.vars.Game_Port;
host', err := onet.host_create(^addr, 16);
if err != .None {
case .Connect {
connect_packet := cast(^packets.Connect) packet;
- if connect_packet.client_version != (package runtime.vars).Game_Version {
+ if connect_packet.client_version != runtime.vars.Game_Version {
respond_with_error(.Client_Version_Wrong);
}
package packets
-use package main { Vector3, Vector3i }
-use package main { Block }
+use main { Vector3, Vector3i }
+use main { Block }
Type :: enum (u8) {
Connect;
Block_Updates;
}
-#match (package core.hash).to_u32 macro (t: Type) => cast(u32) t;
+#match core.hash.to_u32 macro (t: Type) => cast(u32) t;
Packet_Base :: struct #pack {
type: Type;