Files
demo-game/scripts/sprite_atlas.gd
T
skrueckenandCursor 2138039b72 Support dynamic 2–8 player Space Shooter from selected pods.
Replace the fixed left/right split with selectable pod slots and a scalable grid layout so player count follows the chosen pods.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-01 23:36:42 +01:00

53 lines
1.3 KiB
GDScript

class_name SpriteAtlas
extends RefCounted
static var _sheet: Texture2D
static func sheet() -> Texture2D:
if _sheet == null:
_sheet = load("res://assets/Spritesheet/sheet.png")
return _sheet
static func region(x: int, y: int, w: int, h: int) -> AtlasTexture:
var tex := AtlasTexture.new()
tex.atlas = sheet()
tex.region = Rect2i(x, y, w, h)
return tex
static func named(name: String) -> AtlasTexture:
match name:
"meteorBrown_big1":
return region(224, 664, 101, 84)
"playerShip1_blue":
return region(211, 941, 99, 75)
"playerShip1_orange":
return region(247, 84, 99, 75)
"playerShip1_green":
return region(237, 377, 99, 75)
"playerShip1_red":
return region(224, 832, 99, 75)
"playerShip2_blue":
return region(112, 791, 112, 75)
"playerShip2_orange":
return region(112, 716, 112, 75)
"playerShip2_green":
return region(112, 866, 112, 75)
"playerShip2_red":
return region(0, 941, 112, 75)
"laserBlue01":
return region(856, 421, 9, 54)
"laserRed01":
return region(858, 230, 9, 54)
"laserGreen01":
return region(855, 173, 9, 57)
"star1":
return region(628, 681, 25, 24)
"star2":
return region(222, 84, 25, 24)
_:
push_warning("SpriteAtlas: unknown sprite '%s'" % name)
return region(0, 0, 1, 1)