Skip to content

LostBitset/Kaidun

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

436 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kaidun

A 3D game made in Python with moderngl

Gameplay in one sentence

What if Temple Run was a flight simulator?

Gameplay

The game mechanics are inspired by Temple Run. In this version you fly over desert mountains on an alien planet, and try to travel as far as you can without failing checkpoints (shown as red triangles). You can use a and d to adjust the roll of your alien space-plane, and the try to match it with the roll of the checkpoint marker (the marker should appear as horizontal as possible). If you fail, the plane starts shaking and crashes. Start and stop by pressing the enter key.

Running it

  • Just run python main.py
    • Use the arrow keys to look around
    • Toggle following the mountains with the enter key
  • Files ending in .test.py are tests
  • Files ending in .vtest.py are "visual tests" for me to make sure things look right
  • Files ending in .vert or .frag are OpenGL shaders
  • The SAVEFILE.json file is where your scores are stored (it's not tracked by git)

Requirements

The following command installs everything you need (it works on Debian 11):

python -m pip install numpy glcontext moderngl moderngl_window pyopengltk pynput

Massive credit goes to the library authors for allowing this project to run at more than 2 FPS.

Features

  • A simple 3D engine
    • Invokes ModernGL (an OpenGL interface) from cmu_112_graphics
    • Scenes that define geometry and when to update it
    • Controllers to handle events and shader code setup
    • Automatic reallocation of GPU vertex buffer when necessary
    • Full 3D written from scratch in GLSL
      • Perspective camera implemented from scratch
      • Lambertian component (Phong shading)
      • Oren-Nayar reflectance (Gouraud shading)
      • Distance fog (calculated per-pixel using the z-buffer)
      • Bump mapping (finite-difference method)
      • Procedural heightmaps for terrain surfaces
    • Simple physics so you don't fall through the floor
    • Terrain organized into chunks, and generated from a heightmap
    • A chunk loading system
  • Following edges of a graph
    • Use t-values to determine position and derive heading
    • Randomly switch to possible new edges at the end
    • Rotation done using a P-controller
    • Keeps track of how far you've traveled
  • Procedural terrain generation
    • Heightmaps derived from a graph where mountains are edges
    • A triangulation data structure
    • Delaunay Triangulation with Bowyer-Watson
    • Finding the incenter using barycentric coordinates
    • Creating a random Delaunay Triangulation
    • Expanding it until all incenters are far enough away from sides
    • Conversion of triangulations into graphs
  • Checkpoints
    • Generation of checkpoints for each edge
    • Rendered without bump mapping
    • Rotated properly along all three rotation axes
    • Detect when checkpoints have been failed
    • Fall down and start camera shake when you fail
    • Restart when you crash

About

A 3D game made in Python with moderngl

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors