From 50bee7a5c0d780e879bd0da2870b37fe4147502a Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Sat, 3 Jan 2026 08:25:55 -0600 Subject: [PATCH] world --- compositor.cm | 6 ++++-- particles2d.cm | 5 +++++ sprite.cm | 44 +++++++++++++++++++++++--------------------- tilemap2d.cm | 18 +++++++++++------- world.cm | 7 +++++++ 5 files changed, 50 insertions(+), 30 deletions(-) create mode 100644 world.cm diff --git a/compositor.cm b/compositor.cm index 8e0458ce..d0c21044 100644 --- a/compositor.cm +++ b/compositor.cm @@ -13,6 +13,8 @@ var effects_mod = use('effects') +var gpu = use('sdl_gpu') + var compositor = {} // Presentation modes @@ -32,7 +34,7 @@ compositor.BLEND = { } // Compile a composition tree into a render plan -compositor.compile = function(comp, renderers, backend) { +compositor.compile = function(comp, renderers, backend = gpu) { var ctx = { renderers: renderers, backend: backend, @@ -555,7 +557,7 @@ compositor.calculate_presentation_rect = function(source_size, dest_size, mode) } // Execute a compiled render plan -compositor.execute = function(plan, renderers, backend) { +compositor.execute = function(plan, renderers, backend = gpu) { var target_cache = {} // Pre-allocate targets diff --git a/particles2d.cm b/particles2d.cm index e69de29b..914064d8 100644 --- a/particles2d.cm +++ b/particles2d.cm @@ -0,0 +1,5 @@ + + +return function() { + +} \ No newline at end of file diff --git a/sprite.cm b/sprite.cm index 564cae88..c59bcfd5 100644 --- a/sprite.cm +++ b/sprite.cm @@ -2,27 +2,9 @@ // // Returns a function that creates sprite instances via meme() +var dirty = {} + var sprite = { - type: 'sprite', - pos: null, - layer: 0, - image: null, - width: 1, - height: 1, - anchor_x: 0, - anchor_y: 0, - scale_x: 1, - scale_y: 1, - color: null, - uv_rect: null, - slice: null, - tile: null, - material: null, - opacity: 1, - - // Dirty tracking - dirty: 7, // DIRTY.ALL - // Setters that mark dirty set_pos: function(x, y) { if (!this.pos) this.pos = {x: 0, y: 0} @@ -79,5 +61,25 @@ stone(sprite) // Factory function return function(props) { - return meme(sprite, props) + var defaults = { + pos: {x:0,y:0}, + layer: 0, + image: null, + width: 1, + height: 1, + anchor_x: 0, + anchor_y: 0, + scale_x: 1, + scale_y: 1, + color: null, + uv_rect: null, + slice: null, + tile: null, + material: null, + opacity: 1, + } + + var newsprite = meme(sprite, [defaults,props]) + newsprite[dirty] = 7 + return newsprite } \ No newline at end of file diff --git a/tilemap2d.cm b/tilemap2d.cm index b7fd6091..46538dd8 100644 --- a/tilemap2d.cm +++ b/tilemap2d.cm @@ -1,11 +1,5 @@ // tilemap.js - MUCH SIMPLER var tilemap = { - tiles: [], // Just strings: [['grass', 'dirt'], ['stone', null]] - offset_x: 0, - offset_y: 0, - layer: 0, - tile_width: 1, // world units - tile_height: 1, at(pos) { var x = pos.x - this.offset_x var y = pos.y - this.offset_y @@ -30,5 +24,15 @@ var tilemap = { stone(tilemap) return function(props) { - return meme(tilemap, props) + var defaults = { + tiles: [], + offset_x: 0, + offset_y: 0, + layer: 0, + tile_width: 1, + tile_height: 1, + } + var newtilemap = meme(tilemap, [defaults,props]) + newtilemap.tiles = [] + return newtilemap } diff --git a/world.cm b/world.cm new file mode 100644 index 00000000..fd881274 --- /dev/null +++ b/world.cm @@ -0,0 +1,7 @@ +var world = {} + + + +return function() { + return meme(world) +} \ No newline at end of file