Add basic app interface

- Add pool struct for data pools
This commit is contained in:
2026-05-04 15:49:54 +01:00
parent 9e85763f9e
commit 55f4b4d933
9 changed files with 334 additions and 113 deletions
+9 -8
View File
@@ -3,9 +3,9 @@
width, height = 720, 480
image = Image.new "assets/loading.png"
image = Tiles.from("assets/loading.png").first
app = App.new width, height, title: "My Game", loading_bg: image
app = App.new width, height, title: "My Game", loading_bg: image # can be image or animation
app.map_key ?w, :forward
app.map_key ?s, :backward
@@ -57,8 +57,8 @@ world.spawn do |e| # Name is optional
c.collision = true
end
e.add_component :sprite do |c|
c.tiles = Tiles.from "assets/sprite.png", tile_width: 50, tile_height: 50
animation1 = {tiles: 0..3, frame_rate: 10, loop: true}
tiles = Tiles.from "assets/sprite.png", tile_width: 50, tile_height: 50
animation1 = {tiles: tiles[0..3], frame_rate: 10, loop: true}
c.animations = {idle: animation1}
c.current_animation = :idle
end
@@ -81,8 +81,8 @@ world.spawn "Trap Preview" do |e|
e.tags = [:trap_preview]
e.active = false
e.add_component :sprite do |c|
c.tiles = Tiles.from "assets/trap.png", tile_width: 50, tile_height: 50
animation1 = {tiles: 0..3, frame_rate: 10, loop: true}
tiles = Tiles.from "assets/trap.png", tile_width: 50, tile_height: 50
animation1 = {tiles: tiles[0..3], frame_rate: 10, loop: true}
c.animations = {idle: animation1}
c.current_animation = :idle
end
@@ -123,8 +123,9 @@ world.system :trap_placement, trigger: trigger do |dt|
e.tags = [:trap]
e.position = world.mouse_position_world
e.add_component :sprite do |c|
c.tiles = Tiles.from "assets/trap.png", tile_width: 50, tile_height: 50
animation1 = {tiles: 0..3, frame_rate: 10, loop: true}
tiles = Tiles.from "assets/trap.png", tile_width: 50, tile_height: 50
tiles2 = Tiles.from "assets/trap_2.png", tile_width: 50, tile_height: 50
animation1 = {tiles: tiles[0..3] + tiles2[0..3], frame_rate: 10, loop: true}
c.animations = {idle: animation1}
c.current_animation = :idle
end