Karl Zylinski před 6 měsíci
rodič
revize
90f1f861dd
3 změnil soubory, kde provedl 43 přidání a 39 odebrání
  1. 3 3
      examples/box2d/karl2d_box2d.odin
  2. 38 35
      karl2d.doc.odin
  3. 2 1
      karl2d.odin

+ 3 - 3
examples/box2d/karl2d_box2d.odin

@@ -98,7 +98,7 @@ main :: proc() {
 		k2.process_events()
 		k2.clear(k2.BLACK)
 
-		k2.draw_rect(ground, k2.RED)
+		k2.draw_rect(ground, k2.RL_RED)
 		mouse_pos := k2.get_mouse_position()
 
 		b2.Body_SetTransform(body_id, {mouse_pos.x, -mouse_pos.y}, {})
@@ -113,10 +113,10 @@ main :: proc() {
 			r := b2.Body_GetRotation(b)
 			a := math.atan2(r.s, r.c)
 			// Y position is flipped because raylib has Y down and box2d has Y up.
-			k2.draw_rect_ex({position.x, -position.y, 40, 40}, {20, 20}, a*(180/3.14), k2.YELLOW)
+			k2.draw_rect_ex({position.x, -position.y, 40, 40}, {20, 20}, a*(180/3.14), k2.RL_YELLOW)
 		}
 
-		k2.draw_circle(mouse_pos, 40, k2.MAGENTA)
+		k2.draw_circle(mouse_pos, 40, k2.RL_MAGENTA)
 		k2.present()
 
 		free_all(context.temp_allocator)

+ 38 - 35
karl2d.doc.odin

@@ -60,6 +60,8 @@ set_window_size :: proc(width: int, height: int)
 //     uses a blank, white texture. For the same reasons as (1), drawing something else than shapes
 //     before drawing a shape will break up the batches. TODO: Add possibility to customize shape
 //     drawing texture so that you can put it into an atlas.
+//
+// TODO: Name of this proc? submit_current_batch, flush_current_batch, draw_current_batch
 draw_current_batch :: proc()
 
 //-------//
@@ -153,9 +155,6 @@ set_internal_state :: proc(state: ^State)
 // TYPES AND CONSTANTS //
 //---------------------//
 
-// A RGBA (Red, Greeen, Blue, Alpha) color. Each channel can have a value between 0 and 255.
-Color :: [4]u8
-
 // A two dimensinal vector.
 Vec2 :: [2]f32
 
@@ -174,6 +173,42 @@ Rect :: struct {
 	w, h: f32,
 }
 
+// An RGBA (Red, Green, Blue, Alpha) color. Each channel can have a value between 0 and 255.
+Color :: [4]u8
+
+WHITE :: Color { 255, 255, 255, 255 }
+BLACK :: Color { 0, 0, 0, 255 }
+BLANK :: Color { 0, 0, 0, 0 }
+BLUE  :: Color { 30, 116, 240, 255 }
+
+// These are from Raylib. They are here so you can easily port a Raylib program to Karl2D.
+RL_LIGHTGRAY  :: Color { 200, 200, 200, 255 }
+RL_GRAY       :: Color { 130, 130, 130, 255 }
+RL_DARKGRAY   :: Color { 80, 80, 80, 255 }
+RL_YELLOW     :: Color { 253, 249, 0, 255 }
+RL_GOLD       :: Color { 255, 203, 0, 255 }
+RL_ORANGE     :: Color { 255, 161, 0, 255 }
+RL_PINK       :: Color { 255, 109, 194, 255 }
+RL_RED        :: Color { 230, 41, 55, 255 }
+RL_MAROON     :: Color { 190, 33, 55, 255 }
+RL_GREEN      :: Color { 0, 228, 48, 255 }
+RL_LIME       :: Color { 0, 158, 47, 255 }
+RL_DARKGREEN  :: Color { 0, 117, 44, 255 }
+RL_SKYBLUE    :: Color { 102, 191, 255, 255 }
+RL_BLUE       :: Color { 0, 121, 241, 255 }
+RL_DARKBLUE   :: Color { 0, 82, 172, 255 }
+RL_PURPLE     :: Color { 200, 122, 255, 255 }
+RL_VIOLET     :: Color { 135, 60, 190, 255 }
+RL_DARKPURPLE :: Color { 112, 31, 126, 255 }
+RL_BEIGE      :: Color { 211, 176, 131, 255 }
+RL_BROWN      :: Color { 127, 106, 79, 255 }
+RL_DARKBROWN  :: Color { 76, 63, 47, 255 }
+RL_WHITE      :: WHITE
+RL_BLACK      :: BLACK
+RL_BLANK      :: BLANK
+RL_MAGENTA    :: Color { 255, 0, 255, 255 }
+RL_RAYWHITE   :: Color { 245, 245, 245, 255 }
+
 Texture :: struct {
 	handle: Texture_Handle,
 	width: int,
@@ -306,38 +341,6 @@ Mouse_Button :: enum {
 	Max = 255,
 }
 
-WHITE :: Color { 255, 255, 255, 255 }
-BLACK :: Color { 0, 0, 0, 255 }
-BLANK :: Color { 0, 0, 0, 0}
-
-// These are from Raylib. They are here so you can easily port a Raylib program to Karl2D.
-RL_LIGHTGRAY  :: Color { 200, 200, 200, 255 }
-RL_GRAY       :: Color { 130, 130, 130, 255 }
-RL_DARKGRAY   :: Color { 80, 80, 80, 255 }
-RL_YELLOW     :: Color { 253, 249, 0, 255 }
-RL_GOLD       :: Color { 255, 203, 0, 255 }
-RL_ORANGE     :: Color { 255, 161, 0, 255 }
-RL_PINK       :: Color { 255, 109, 194, 255 }
-RL_RED        :: Color { 230, 41, 55, 255 }
-RL_MAROON     :: Color { 190, 33, 55, 255 }
-RL_GREEN      :: Color { 0, 228, 48, 255 }
-RL_LIME       :: Color { 0, 158, 47, 255 }
-RL_DARKGREEN  :: Color { 0, 117, 44, 255 }
-RL_SKYBLUE    :: Color { 102, 191, 255, 255 }
-RL_BLUE       :: Color { 0, 121, 241, 255 }
-RL_DARKBLUE   :: Color { 0, 82, 172, 255 }
-RL_PURPLE     :: Color { 200, 122, 255, 255 }
-RL_VIOLET     :: Color { 135, 60, 190, 255 }
-RL_DARKPURPLE :: Color { 112, 31, 126, 255 }
-RL_BEIGE      :: Color { 211, 176, 131, 255 }
-RL_BROWN      :: Color { 127, 106, 79, 255 }
-RL_DARKBROWN  :: Color { 76, 63, 47, 255 }
-RL_WHITE      :: WHITE
-RL_BLACK      :: BLACK
-RL_BLANK      :: BLANK
-RL_MAGENTA    :: Color { 255, 0, 255, 255 }
-RL_RAYWHITE   :: Color { 245, 245, 245, 255 }
-
 // Based on Raylib / GLFW
 Keyboard_Key :: enum {
 	None            = 0,

+ 2 - 1
karl2d.odin

@@ -755,7 +755,8 @@ Color :: [4]u8
 
 WHITE :: Color { 255, 255, 255, 255 }
 BLACK :: Color { 0, 0, 0, 255 }
-BLANK :: Color { 0, 0, 0, 0}
+BLANK :: Color { 0, 0, 0, 0 }
+BLUE  :: Color { 30, 116, 240, 255 }
 
 // These are from Raylib. They are here so you can easily port a Raylib program to Karl2D.
 RL_LIGHTGRAY  :: Color { 200, 200, 200, 255 }