Skip to content

vinceswu/voxel-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Voxel Engine

Dogfood Voxel Engine written in Olive

swappy-20241017-160041

Overview

A voxel engine written in Olive. This is a dogfood project for the language, using it to build something non-trivial that touches structs, references, FFI, math, and real-time rendering.

Olive handles all the game logic. Rendering goes through pygame and ModernGL via import py. Noise generation is a native Olive implementation of OpenSimplex2 (no Python noise libraries needed).

Prerequisites

  • Olive >= 0.1.23 - see installation below
  • Python 3.x - with dependencies from requirements.txt

Controls

Movement

Input Action
W / A / S / D Move forward / left / backward / right
Space Jump
Space (double-tap) Toggle flying
Left Shift Sprint (ground) / speed boost (flying)
Left Ctrl Descend (flying) / sneak (ground)
Mouse Look around
\ Toggle noclip (free camera, no collision)

Block Interaction

Input Action
Left Click Remove targeted block (hold to break)
Right Click Place selected block
1-7 Select block type (Sand / Grass / Dirt / Stone / Snow / Leaves / Wood)
Scroll Wheel Cycle block type

Other

Input Action
Escape Quit
F12 Save screenshot

Installation

  1. Clone the repository:
git clone https://github.com/ecnivs/voxel-engine.git
cd voxel-engine
  1. Install Python dependencies:
pip install -r requirements.txt
  1. Install Olive:

    Linux / macOS:

    curl -sSL https://raw.githubusercontent.com/olive-language/olive/master/install.sh | sh

    Windows: download from the releases page

  2. Run:

pit run

What it exercises in Olive

  • Structs with mutable and immutable references (&mut, &)
  • Python interop (import py) for pygame, moderngl, glm, Pillow
  • Native math - 727-line OpenSimplex2 noise implementation
  • Const expressions evaluated at compile time
  • Tuple returns and destructuring
  • Manual memory layout - packed vertex data (6b pos + 8b voxel + 3b face + 2b AO + 1b flip per uint32 vertex)

I'd appreciate any feedback or code reviews you might have!

About

Dogfood Voxel Engine written in Olive

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors