o
odin.langpkg.dev
packages / app / valkyrie

valkyrie

9449638app

valkyrie engine (odin game engine)

MIT · updated 2 months ago

Valkyrie

Valkyrie is a lightweight game development library written in Odin, currently centered around 2D rendering and core game framework features.
It is being developed as a reusable foundation for future game projects and is open source under the MIT License.

Valkyrie primarily developed for learning new stuff and also future game projects, so some features are added specifically to support those needs. At least thats the main reason why I'm building this.

Warning

This project is currently in active development.
Expect changes, breaking APIs, and incomplete features.

Usage

To use Valkyrie, copy the valkyrie folder into your codebase, import it, and run your game project with:

odin run . -debug

Example

package main

import "core:log"
import vl "valkyrie"

main :: proc() {
	context.logger = log.create_console_logger()

	vl.create_window(800, 600, "My Window")
	defer vl.shutdown()

	vl.set_vsync(true)

	x: f32 = 0
	dir: f32 = 1
	mouse_texture := vl.load_texture("assets/mouse_hand.png")

	for !vl.should_close() {
		vl.poll_events()
		if vl.key_is_pressed(.Escape) do vl.close_window()

		x += dir * 400 * vl.delta_time()
		if x >= f32(vl.window_width() - 100) {
			dir = -1
		} else if x < 0 {
			dir = 1
		}

		vl.render_begin()
		{
			vl.clear_color(vl.VALKYRIE_BLUE)
			vl.draw_rectangle({700 - x, 300, 100, 100}, {1.0, 0.66, 0.2, 1.0})
			vl.draw_texture_pos(mouse_texture, {x, 100})
		}
		vl.render_end()

		free_all(context.temp_allocator)
	}
}

Roadmap

First version (OpenGL)

  • Create a window
  • Load shaders
  • Batch rendering for colored rectangles
  • Load textures (stb_image)
  • Draw 2D textures
  • Load and render fonts (stb_truetype)
  • Batch rendering for textures and even fonts
  • Simple 2D camera
  • Keyboard input
  • Audio support (minimal)
  • Font/UI text alignment
  • Font/UI word wrapping
  • Audio Volume + Spatial Sound Fade
  • Get/Set Mouse Position
  • Audio Bus Mixer System
  • Draw Circle
  • Draw Circle Lines
  • Check Circle Collision
  • Check Rectangle Collision (AABB)
  • Create a simple example game

Dependencies

Valkyrie currently depends on libraries from Odin's vendor collection:

  • GLFW: Window management
  • OpenGL: Rendering api
  • stb_image: Loading textures
  • stb_truetype: Loading & generating fonts
  • miniaudio: Loading & playing sounds

Troubleshooting

Valkyrie does not compile or link

Because Valkyrie uses dependencies from the vendor libraries, you may need to install the required system dependencies on your machine.

In many cases, it is enough to install Odin correctly and make sure its path is available in your environment variables.

Valkyrie does not run as expected

  1. Import logging with: import "core:log" in your main file
  2. Activate console logging inside your main function: context.logger = log.create_console_logger()
  3. Run your code in debug mode: odin run ./<project-path> -debug and check whether any assets or shaders aren't loading.