Getting Started

YObject is an engine that extends Geometry Dash's creation capabilities. It allows you to write custom code that runs alongside your levels, creating complex behaviors, and expanded functionality beyond traditional triggers.

Why YObject?

Object-Oriented: Create reusable object structures and traits with inheritance and encapsulation(soon).

Geode Integration: Seamlessly works with the Geode mod loader ecosystem.

Beyond Triggers: Write actual code instead of relying solely on trigger combinations.

More info soon...

Installation

In this section, you can install YObject.

Firstly, you need to download this mod.

Download

Then you need to put this mod in Geode mods folder. This is example path to this folder

Path
C:\Program Files (x86)\Steam\steamapps\common\Geometry Dash\geode\mods

That's all. You can open Geometry Dash and mod will be there

How to use?

To open engine press ALT+C in the editor

You can create or delete file in FileManager window using path of the (new) file by pressing Create or Delete buttons. Example path: root/file.y

ATTENTION!: All code files need to have .y at the end of name

Then click on this file in FileManager (open root folder and click) and you can start programming

To save file press Save in CodeEditorButtons and to build all files press Build

Variables and Values

Since you can't really print Hello, world! to the console using Geometry Dash triggers, we're going to get straight into the main features of YObject, the first of which being variables.

In YObject, variables are defined like this:

Code
// [variable name] = [value]
a = 10
b = 60
c = a + b

// or

// const [variable name] = [value] (to make them constant)
const d = 10
const e = 60
const f = d + e

YObject Values

So, what kind of stuff can you put in your variables? Well, a lot of different things. Some value types are ones you might be familiar with from other languages:

Code
num = 10

text = "Hello, I'm a string!"

array = [1, 2, 3]

boolean = true

These values can be used as you would in any other programming language. Here are some examples:

Code
num = -(1000 * 1000) / 10 // -100000

name = "YaY"
text = "Hello, my name is " + name + "!"

array = [1, 2, 3]
my_number = array[2] // 3

array += [4] // after this, the array will now be [1, 2, 3, 4]

boolean = true
boolean2 = !boolean // false

IDs

In YObject, there are also values that that are useful specifically when making Geometry dash levels:

Code
// Group IDs
background = 1g
player = 2g
enemies = 3g

// Color IDs
playerColor = 1c
bgColor = BG

// Item IDs (for counters)
coinsItem = 1i
timeItem = 2i

// Timer IDs
spawnTimer = 1t
gameTimer = 2t

// Block IDs
spike = 1b
platform = 2b

// Get next available ID
newGroup = ?g
newColor = ?c
newItem = ?i
newTimer = ?t
newBlock = ?b

// You can interact with items and timers like this:
a = 10i
a += 1
a = 0

b = 10t
b -= 2.5
b = 0.5

Basic Triggers

As you probably know, to move objects in Geometry Dash, you move the group the objects are in. If you wanted to, say, move group 5 ten units on the x-axis in 0.5 seconds, you would add a move trigger with those settings. In YObject we do it like this:

Code
/* group.move(x, y, duration, [easing type] = Easing.None,
    [silent] = false, [smallStep] = false) */
5g.move(10, 0, 0.5)

You can add delay to your triggers using wait()

Code
wait(1.5)
1g.move(10, 0, 1)
wait(1)
2g.move(20, 0, 1)
                        

Conditions

YObject has a quite standard syntax for if-statements:

Code
// Basic if statement
if health > 0 {
    player.alpha(1.0, 0.5)
} else {
    player.alpha(0.0, 0.5)
    gameOver = true
}

// Else-if chain
if score >= 1000 {
    rating = "S"
} else if score >= 500 {
    rating = "A"
} else if score >= 200 {
    rating = "B"
} else {
    rating = "C"
}

Also if you have item or timer in condition it will create item compare trigger to make in-game branching

Code
// Item comparisons (creates in-game triggers)
if coinsItem == 10 {
    5g.toggle(true)
}
                        

Loops

YObject has a quite standard syntax for loops:

Code
// While loop
i = 0
while i < 10 {
    spawn_enemy(i * 100, 0)
    i += 1
    wait(0.5)
}

// For loop over array
powerups = ["speed", "jump", "shield"]
for p in powerups {
    create_powerup(p)
    wait(1)
}


// For runtime loops
whileLoop(fn() -> bool { return true }, fn() {
    1g.move(10, 0, 0) 
})

Functions

YObject has 2 types of functions (and one of them has 2 subtypes):

Code
// define a function:
fn function(a: int, b: float = 10.5) {
    1g.move(a, 0, b)
}
fn function(a, b) { // if you don't set type of argument it will be any type
    // code
}

// compile-time call:
func(10, 15)

// runtime call:
func(10, 15)!

// another runtime call, but with recompilation
func(10,15)!!





// also you can return value from function:

fn function2(a: int, b: float = 10.5) -> float {
    return a + b
}


// and you can overload functions:

fn function2(a: int, b: float, c: int) -> float {
    return a + b - c
}
                        

Enums

You can define enums in YObject:

Code
enum MyEnum {
    Apple
    Banana
}
// or
enum MyEnum {
    Apple = 0
    Banana = 1
}
                        

You can create and interact with enums like this:

Code
myEnum = MuEnum.Apple

$print(myEnum)
$print((myEnum)int) // casts will be further
$print((1)MuEnum) // also cast
                        

Pattern Matching

You can check matching to patterns in YObject:

Code
$print(myEnum is MyEnum) // return true
$print(myEnum is ==MyEnum.Apple) // return true

//or

match myEnum {
    ==MyEnum.Apple | ==MyEnum.Banana {
        // code
    }
    else {
        // code 
    }
}
                        

Structures

You can define structures in YObject:

Code
struct MyStruct {
    intProperty: int
    floatProperty: float
}
                        

You can create and interact with structs like this:

Code
myObject = MyStruct

myObject.intProperty = 10
myObject.floatProperty = 20.3
                        

Implementations

You can implement structures in YObject:

Code
impl MyStruct {
    fn staticFunc(a: int) -> int {
        return a + 2
    }
    fn nonstaticFunc(self, a: int) -> int {
        return self.intProperty + a
    }                         
}


MyStruct.staticFunc(10) // return 12

a = MyStruct
a.intProperty = 5
a.nonStaticFunc(10) // return 15 because 5 + 10 = 15
                        

Traits

You can define traits in YObject:

Code
trait MyTrait {
    fn func(self) -> int
    fn func2(self) -> float
    { 
       // you don't need to write code of this function
       // but if you do that, it will be default implementation
    }
}
                        

You can implement traits for structs:

Code
impl MyTrait for MyStruct {
    fn func(self) -> int {
        return self.intProperty
    }                        
}


myObj = MyStruct

myObjButTrait = (myObj)MyTrait // casting will be shown soon
myObjButTrait.func() // return myObj intProperty

Casts

You can cast variables in YObject:

Code
integer = 1
// you can cast like this:
floatNumber = (integer)float

// or this:
floatNumber = 1float

// [number][type] or (variable)[type]
                        

Libraries

You can import other files in YObject:

Code
import "root/filename.y" as libraryName

libraryName.function() // some function from this file
                        

Also you can extract all from this file:

Code
extract import "root/filename.y"

function() // some function from this file,
// you can use it without calling name of this library
                        

Built-in Functions

You can use this functions everywhere:

Code

// $print(value) prints value string form to console  
$print(10)  


// $currentGroup(gr) or $currentGroup(gr, set)
// returns current trigger group or sets new value to this variable 
$currentGroup(0) 
$currentGroup(0, 10g)


// $addObjectString(obj) creates objects in level from string
$addObjectString("1,1049,2,75,3,75,36,1,51,0;")


// $currentXPos() or $currentXPos(set)
// returns current trigger X position or sets new value to this variable
$currentXPos()
$currentXPos($currentXPos() + 1)


// $abs(value)
// Calculates the absolute value of a number
$abs(-10)


// $acos(value)
// Calculates the arccos of a number
$acos(-1)


// $acosh(value)
// Calculates the arccosh of a number
$acosh(num)


// $asin(value)
// Calculates the arcsin of a number
$asin(1)


// $asin(value)
// Calculates the arcsinh of a number
$asinh(num)


// $atan(value)
// Calculates the arctan of a number
$atan(1)


// $atan2(a, b)
// Calculates the arctan^2 of a number
$atan2(a, b)


// $atanh(value)
// Calculates the arctanh of a number
$atanh(num)


// $b64decode(value)
// Returns the input string decoded from base64 encoding (useful for text objects)
$b64decode("aGVsbG8gdGhlcmU=")


// $b64encode(value)
// Returns the input string encoded with base64 encoding (useful for text objects)
$b64encode("hello there")


// $cbrt(value)
// Calculates the cube root of a number
$cbrt(27)


// $ceil(value)
// Calculates the ceil of a number, AKA the number rounded up to the nearest integer
$ceil(27)


// $cos(value)
// Calculates the cos of an angle in radians
$cos(3.1415)


// $cosh(value)
// Calculates the cosh of a number
$cosh(num)


// $exp(value)
// Calculates the e^x of a number
$exp(x)


// $floor(value)
// Calculates the floor of a number, AKA the number rounded down to the nearest integer
$floor(1.5)


// $fract(value)
// Gets the fractional part of a number
$fract(123.456)


// $ln(value)
// Calculates the ln (natural log) of a number
$ln(num)


// $log(value, base)
// Calculates the log base x of a number
$log(num, base)


// $max(a, b)
// Calculates the max of two numbers
$max(1, 2)


// $min(a, b)
// Calculates the min of two numbers
$min(1, 2)


// $pow(a, b)
// Calculates the a^b
$pow(2, 3)


// $random() or $random(array) or $random(floatA, floatB)
// Generates random numbers, or picks a random element of an array
$random()
$random([1, 2, 3, 6])
$random(1.0, 10.0)


// $removeIndex(array, index)
// Removes a specific value from an array
$removeIndex(array, 2)


// $round(value)
// Rounds a number
$round(1.2)


// $sin(value)
// Calculates the sin of an angle in radians
$sin(3.1415)


// $sinh(value)
// Calculates the hyperbolic sin of a number
$sinh(num)


// $sqrt(value)
// Calculates the square root of a number
$sqrt(num)


// $substr(str, start, length)
// Returns a specified part of the input string
$substr("hello there", 1, 4)


// $tan(value)
// Calculates the tan of an angle in radians
$tan(3.1415)


// $tanh(value)
// Calculates the hyperbolic tan of a number
$tanh(num)


// $time()
// Gets the current system time in seconds
$time()


// $spawnGroup(id)
// Spawns group via game engine, not triggers
$spawnGroup(1)


// $getItemValue(id)
// Returns item value
$getItemValue(1)


// $isKeyPressed(key)
// Returns is key pressed or not
$isKeyPressed(65) // "A" key


// $isPlayMode()
// Returns is play mode or not
$isPlayMode()



// ImGui


// $imGuiBegin(name)
// Begins an ImGui window
$imGuiBegin("My Window")


// $imGuiEnd()
// Ends an ImGui window
$imGuiEnd()


// $imGuiGetWindowPos() -> [x, y]
// Gets the position of the current ImGui window
$imGuiGetWindowPos()


// $imGuiSetWindowPos(x, y)
// Sets the position of the current ImGui window
$imGuiSetWindowPos(100, 100)


// $imGuiSetNextWindowPos(x, y)
// Sets the position for the next ImGui window
$imGuiSetNextWindowPos(200, 150)


// $imGuiGetWindowSize() -> [x, y]
// Gets the size of the current ImGui window
$imGuiGetWindowSize()


// $imGuiSetWindowSize(width, height)
// Sets the size of the current ImGui window
$imGuiSetWindowSize(400, 300)


// $imGuiSetNextWindowSize(width, height)
// Sets the size for the next ImGui window
$imGuiSetNextWindowSize(500, 400)


// $imGuiText(text)
// Displays a text label in the current ImGui window
$imGuiText("Hello World")


// $imGuiButton(label)
// Creates a button and returns true if clicked
$imGuiButton("Click Me")


// $imGuiCheckbox(label, value)
// Creates a checkbox and returns the updated value
$imGuiCheckbox("Enable Option", true)


// $imGuiImage(textureID, width, height)
// Displays an image with the specified texture
$imGuiImage(123, 200, 150)


// $imGuiInputText(label, buffer)
// Creates a text input field and returns the entered text
$imGuiInputText("Name", "Default")


// $imGuiInputTextMultiline(label, buffer)
// $imGuiInputTextMultiline(label, buffer, width, height)
// Creates a multiline text input field
$imGuiInputTextMultiline("Description", "Text", 300, 200)


// $imGuiInputFloat(label, value)
// Creates a float input field and returns the updated value
$imGuiInputFloat("Speed", 1.5)


// $imGuiInputInt(label, value)
// Creates an integer input field and returns the updated value
$imGuiInputInt("Count", 10)


// $imGuiIsKeyPressed(key)
// Returns true if the specified key was pressed this frame
$imGuiIsKeyPressed("A")


// $imGuiIsKeyDown(key)
// Returns true if the specified key is currently held down
$imGuiIsKeyDown("A")


// $imGuiIsKeyUp(key)
// Returns true if the specified key was released this frame
$imGuiIsKeyUp("A")


// $imGuiGetMousePos() -> [x, y]
// Returns the current mouse position
$imGuiGetMousePos()


// $imGuiGetMouseDelta() -> [x, y]
// Returns the mouse movement delta since last frame
$imGuiGetMouseDelta()


// $imGuiGetMouseWheel()
// Returns the mouse wheel movement value
$imGuiGetMouseWheel()


// $imGuiIsMouseDown(button)
// Returns true if the specified mouse button is currently down
$imGuiIsMouseDown(0)


// $imGuiIsMouseReleased(button)
// Returns true if the specified mouse button was released this frame
$imGuiIsMouseReleased(0)


// $imGuiIsWindowFocused()
// Returns true if the current ImGui window is focused
$imGuiIsWindowFocused()



// Shader Functions


// $createShader(shaderName, vertexShaderText, fragmentShaderText)
// Creates a shader from vertex and fragment shaders
$createShader("myShader", "vertex shader code", "fragment shader code")


// $setShaderUniform(shaderName, uniformName, value)    value = bool, int, float
// $setShaderUniform(shaderName, uniformName, elem0, elem1)    elem = float
// $setShaderUniform(shaderName, uniformName, elem0, elem1, elem2)    elem = float
// $setShaderUniform(shaderName, uniformName, elem0, elem1, elem2, elem3)    elem = float
// $setShaderUniform(shaderName, uniformName, elem0, elem1, elem2, elem3, elem4, elem5, elem6, elem7, elem8)    elem = float
// $setShaderUniform(shaderName, uniformName, elem0, elem1, elem2, elem3, elem4, elem5, elem6, elem7, elem8, elem9, elem10, elem11, elem12, elem13, elem14, elem15)    elem = float
// Sets a uniform value in the specified shader
$setShaderUniform("myShader", "uColor", 1.0, 0.0, 0.0, 1.0)


// $resizeShaderTexture(shaderName, width, height)
// Resizes the render texture for the specified shader
$resizeShaderTexture("myShader", 1920, 1080)


// $setShaderData(shaderName, positions, uvs, indices)
// Sets custom data for the shader
$setShaderData("myShader", [...], [...], [...])


// $getShaderRenderTextureID(shaderName)
// Returns the render texture ID for the specified shader
$getShaderRenderTextureID("myShader")



// File Operations


// $readFile(filePath)
// Reads and returns the contents of a file
$readFile("root/config.txt")


// $writeFile(filePath, content)
// Writes content to a file
$writeFile("root/output.txt", "Hello World")


// $compileFile(filePath)
// Compiles a script file
$compileFile("scripts/main.y")



// Object Management


// $removeObjectsWithGroup(group)
// Removes all objects with the specified group name
$removeObjectsWithGroup(9999)



// 3D Model Processing


// $parseObjFile(objFileText)
// Parses an OBJ file and returns the mesh data
$parseObjFile("...obj file text..")
                        

Standard Library

This library is imported by default

You can use this functions everywhere

Also you can see full code of this library

See code

This library will be expanded soon

Code


enum Easing {
	None = 0
	BackIn = 17
	BackInOut = 16
	BackOut = 18
	BounceIn = 8
	BounceInOut = 7
	BounceOut = 9
	EaseIn = 2
	EaseInOut = 1
	EaseOut = 3
	ElasticIn = 5
	ElasticInOut = 4
	ElasticOut = 6
	ExponentialIn = 11
	ExponentialInOut = 10
	ExponentialOut = 12
	SineIn = 14
	SineInOut = 13
	SineOut = 15
}

enum Events {
	JumpPush = 69
	JumpRelease = 70
	LeftPush = 71
	LeftRelease = 72
	RightPush = 73
	RightRelease = 74
}



// wait(seconds: float) wait before running next trigger
wait(0.5)


// onEvent(events: [int], func: fn (), extraId2: int = 0)   event trigger
onEvent([Events.JumpPush], fn () { 1g.move(10,0,1) } )


// onEnginePlayUpdate(func: fn ())   this is the engine loop
onEnginePlayUpdate(fn () { $print("loop") } )


// whileLoop(expression: fn() -> bool, func: fn(), delay: float = 0.005)
// or
// whileLoop(expression: fn() -> item, func: fn(), delay: float = 0.005)
// or
// whileLoop(expression: fn() -> timer, func: fn(), delay: float = 0.005)
// creates loop with condition
whileLoop(fn() -> bool { return true }, fn() { 1g.move(10, 0, 0) })


// group:



// group.move(x: int, y: int, time: float, easing: Easing = Easing.None, silent: bool = false, smallStep: bool = false) moves group
1g.move(10, 0, 1.5, Easing.EaseInOut)


// group.moveTo(other: group, center: group, duration: float, easing: Easing = Easing.None, silent: bool = false) moves group to other object
1g.moveTo(2g, 1g, 1.5, Easing.EaseInOut)


// group.alpha(opacity: float, duration: float) sets alpha value to group
1g.alpha(0.5, 2.5)


// group.toggle(on: bool) toggles group
1g.toggle(false)


// group.stop() stops group
1g.stop()


// group.spawn(delay: float = 0) spawns group
1g.spawn(1.5)


// group.rotate(center: group, degrees: float, duration: float, easing: Easing = Easing.None) rotates group
1g.rotate(2g, 360, 2.5, Easing.EaseInOut)


// group.pulse(red: int, green: int, blue: int, fadeIn: float = 0, hold: float = 0, fadeOut: float = 0) pulses group
1g.pulse(255, 0, 0, 0, 0, 0.4)

// block



// block.onCollision(other: block, func: fn (), activateGroup = true) call function on collision enter
1b.onCollision(2b, fn () { 1g.move(0,10,0.1) } )


// block.onCollisionExit(other: block, func: fn (), activateGroup = true) call function on collision exit
1b.onCollisionExit(2b, fn () { 1g.move(0,-10,0.1) } )




// color



// color.pulse(red: int, green: int, blue: int, fadeIn: float = 0, hold: float = 0, fadeOut: float = 0) pulses color
1c.pulse(255, 0, 0, 0, 0, 0.4)


// color.set(red: int, green: int, blue: int, duration: float, opacity: float = 1) sets color
1c.set(255, 0, 0, 1, 1.0)