u/Cat2DEngine

▲ 3 r/lua

Cat2D, the new mobile engine for creating Lua games 😻

Simple and easy! Install a new mobile framework now! Find us on social media: Reddit, GitHub, YouTube, and Discord!

u/Cat2DEngine — 11 days ago
▲ 30 r/love2d+1 crossposts

Cat2D – A Mobile-First Lua Game Engine for Android Focused on Performance

🚀 Getting Started with Cat2D – Loading and Centering an Image

Hi everyone!

I'm the creator of Cat2D, a new Lua game engine for Android focused on performance, simplicity, and community-driven development.

Today I wanted to share a simple example that loads an image and automatically centers it on the screen.

local player

local scale = 0.5

function load()

player = graphics.loadTexture("player.png")

end

function draw()

graphics.clear(0, 0, 0, 1)

if player then

local sw = system.getScreenWidth()

local sh = system.getScreenHeight()

local w = player:getWidth() * scale

local h = player:getHeight() * scale

local x = (sw - w) / 2

local y = (sh - h) / 2

graphics.draw(player, x, y, 0, scale, scale)

end

end

What this example demonstrates

Loading a texture with graphics.loadTexture()

Getting the screen resolution with system.getScreenWidth() and system.getScreenHeight()

Reading texture dimensions with getWidth() and getHeight()

Scaling an image to 50% of its original size

Automatically centering the image on any screen size

Cat2D's goal is to make creating games and applications in Lua on Android simple while still exposing powerful native features and maintaining good performance.

The engine is still evolving and I'd love feedback from other developers.

What features would you like to see in a mobile-first Lua game engine? 🐱🚀

u/Cat2DEngine — 11 days ago