world
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
|
||||
return function() {
|
||||
|
||||
}
|
||||
44
sprite.cm
44
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
|
||||
}
|
||||
18
tilemap2d.cm
18
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user