Lithium

Directory

↓ About

About

↑ Top

General

Lythium is the 2D successor to Lithium. It comes packaged with a graphical editor and supports
scripting in C++ or Lua. It is cross platform, supporting Windows, Mac and Linux.

A screenshot of the editor.

Technical


The engine uses SDL 2, FMOD, RapidJSON, Lua, MatrixUtil, stb, ImGuiColorTextEdit,
IconFontCppHeaders, glad, and clip as third party libraries.

Examples

↑ Top

Example Game Script

This script is an example of Lua scripting in Lythium. If the user presses the A key,
it will log the position of the camera.

test.lua

					local‌ Test = {}
					Test.prototype = {
					‌   lastDown = false
					}
					
					-- Called every frame
					function‌ Test.prototype:update()
					-- Test if A key is pressed
					local‌ keyDown = Input.getKey(Key.A)
					
					if not self.‌lastDown and‌ keyDown then
					-- Find and log the camera's entity
					local‌ camera = self‌.entity:find("Viewport"‌):find("Camera"‌)
					‌      Lythium.log(camera.position)
					end
					
					-- Save key state for next frame
					self.lastDown = keyDown
					end
					
					return‌ Test
					
				

A scripting doing the same thing as above, but in C++.

test.cpp

					#include<lythium.h>
					
					// Create behavior by deriving LyComponent, which are attachable to entities
					classTest : publicLyComponent {
					public:
					// Used for serialization
					static constexprLySerialUID‌ SERIAL_UID = "Test";
					static constexprLySerialUID‌ SERIAL_PARENT_UID = LyComponent::SERIAL_UID;
					
					// Called every frame
					virtual voidupdate() override‌ {
					// Test if A key is pressed
					bool‌ keyDown = lyGetKey(SDL_SCANCODE_A);
					
					if‌ (!_lastDown && keyDown) {
					// Find and log the camera's entity
					LyEntity‌ *camera = lyGetScene()->find("Viewport")->find("Camera");
					Vector2‌ &p = camera->transform.position;
					lyLog("(%g, %g)", (double)p.x, (double)p.y);
					‌      }
					
					// Save key state for next frame
					‌      _lastDown = keyDown;
					‌   }
					private:
					bool‌ _lastDown = false;
					}
					
				

Screenshots

↑ Top

Graphics debugger, tracking draw calls

The resource browser, with the context menu open

A nice Minecraft tree, with 73 different sprites, all done in 1 draw call.

© 2024 Ethan Vrhel

view on github