1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-29 14:51:17 +00:00

ecs: actions have queries

This commit is contained in:
Steven Hugg 2022-01-27 12:43:27 -06:00
parent 4c2442dd90
commit 47461b5a28

View File

@ -25,8 +25,8 @@ function mkscopesymbol(s: EntityScope, c: ComponentType, fieldName: string) {
export interface Entity { export interface Entity {
id: number; id: number;
etype: EntityArchetype; etype: EntityArchetype;
consts: {[component_field: string]: DataValue}; consts: { [component_field: string]: DataValue };
inits: {[scope_component_field: string]: DataValue}; inits: { [scope_component_field: string]: DataValue };
} }
export interface EntityConst { export interface EntityConst {
@ -54,17 +54,16 @@ export interface Query {
export interface System { export interface System {
name: string; name: string;
actions: CodeFragment[]; actions: Action[];
query: Query;
tempbytes?: number; tempbytes?: number;
emits?: string[]; emits?: string[];
live?: EntityArchetype[] | null;
} }
export interface CodeFragment { export interface Action {
text: string; text: string;
event: string; event: string;
iterate: 'once' | 'each' query: Query;
select: 'once' | 'each' | 'source'
} }
export type DataValue = number | boolean | Uint8Array; export type DataValue = number | boolean | Uint8Array;
@ -115,7 +114,7 @@ interface ArchetypeMatch {
} }
class SourceFileExport { class SourceFileExport {
lines : string[] = []; lines: string[] = [];
comment(text: string) { comment(text: string) {
this.lines.push(';' + text); this.lines.push(';' + text);
@ -152,12 +151,12 @@ class SourceFileExport {
} }
class Segment { class Segment {
symbols: {[sym: string]: number} = {}; symbols: { [sym: string]: number } = {};
ofs2sym = new Map<number,string[]>(); ofs2sym = new Map<number, string[]>();
fieldranges: {[cfname: string]: FieldArray} = {}; fieldranges: { [cfname: string]: FieldArray } = {};
size: number = 0; size: number = 0;
initdata: (number | ConstByte | undefined)[] = []; initdata: (number | ConstByte | undefined)[] = [];
codefrags : string[] = []; codefrags: string[] = [];
addCodeFragment(code: string) { addCodeFragment(code: string) {
this.codefrags.push(code); this.codefrags.push(code);
@ -175,7 +174,7 @@ class Segment {
// TODO: optimize shared data // TODO: optimize shared data
allocateInitData(name: string, bytes: Uint8Array) { allocateInitData(name: string, bytes: Uint8Array) {
let ofs = this.allocateBytes(name, bytes.length); let ofs = this.allocateBytes(name, bytes.length);
for (let i=0; i<bytes.length; i++) { for (let i = 0; i < bytes.length; i++) {
this.initdata[ofs + i] = bytes[i]; this.initdata[ofs + i] = bytes[i];
} }
} }
@ -183,7 +182,7 @@ class Segment {
for (let code of this.codefrags) { for (let code of this.codefrags) {
file.text(code); file.text(code);
} }
for (let i=0; i<this.size; i++) { for (let i = 0; i < this.size; i++) {
let syms = this.ofs2sym.get(i); let syms = this.ofs2sym.get(i);
if (syms) { if (syms) {
for (let sym of syms) file.label(sym); for (let sym of syms) file.label(sym);
@ -240,8 +239,8 @@ const ASM_ITERATE_EACH = `
`; `;
export class EntityScope { export class EntityScope {
childScopes : EntityScope[] = []; childScopes: EntityScope[] = [];
entities : Entity[] = []; entities: Entity[] = [];
bss = new Segment(); bss = new Segment();
rodata = new Segment(); rodata = new Segment();
code = new Segment(); code = new Segment();
@ -257,10 +256,10 @@ export class EntityScope {
) { ) {
parent?.childScopes.push(this); parent?.childScopes.push(this);
} }
newEntity(etype: EntityArchetype) : Entity { newEntity(etype: EntityArchetype): Entity {
// TODO: add parent ID? lock parent scope? // TODO: add parent ID? lock parent scope?
let id = this.entities.length; let id = this.entities.length;
let entity : Entity = {id, etype, consts:{}, inits:{}}; let entity: Entity = { id, etype, consts: {}, inits: {} };
this.em.archtypes.add(etype); this.em.archtypes.add(etype);
for (let c of etype.components) { for (let c of etype.components) {
this.componentsInScope.add(c.name); this.componentsInScope.add(c.name);
@ -269,24 +268,24 @@ export class EntityScope {
return entity; return entity;
} }
*iterateFields() { *iterateFields() {
for (let i=0; i<this.entities.length; i++) { for (let i = 0; i < this.entities.length; i++) {
let e = this.entities[i]; let e = this.entities[i];
for (let c of e.etype.components) { for (let c of e.etype.components) {
for (let f of c.fields) { for (let f of c.fields) {
yield {i, e, c, f, v:e.consts[mksymbol(c, f.name)]}; yield { i, e, c, f, v: e.consts[mksymbol(c, f.name)] };
} }
} }
} }
} }
buildSegments() { buildSegments() {
let iter = this.iterateFields(); let iter = this.iterateFields();
for (var o=iter.next(); o.value; o=iter.next()) { for (var o = iter.next(); o.value; o = iter.next()) {
let {i,e,c,f,v} = o.value; let { i, e, c, f, v } = o.value;
let segment = v === undefined ? this.bss : this.rodata; let segment = v === undefined ? this.bss : this.rodata;
let cfname = mksymbol(c, f.name); let cfname = mksymbol(c, f.name);
let array = segment.fieldranges[cfname]; let array = segment.fieldranges[cfname];
if (!array) { if (!array) {
array = segment.fieldranges[cfname] = {component:c, field:f, elo:i, ehi:i}; array = segment.fieldranges[cfname] = { component: c, field: f, elo: i, ehi: i };
} else { } else {
array.ehi = i; array.ehi = i;
} }
@ -295,7 +294,7 @@ export class EntityScope {
} }
allocateSegment(segment: Segment, readonly: boolean) { allocateSegment(segment: Segment, readonly: boolean) {
let fields = Object.values(segment.fieldranges); let fields = Object.values(segment.fieldranges);
fields.sort((a,b) => (a.ehi - a.elo + 1) * getPackedFieldSize(a.field)); fields.sort((a, b) => (a.ehi - a.elo + 1) * getPackedFieldSize(a.field));
let f; let f;
while (f = fields.pop()) { while (f = fields.pop()) {
let name = mksymbol(f.component, f.field.name); let name = mksymbol(f.component, f.field.name);
@ -304,13 +303,13 @@ export class EntityScope {
// variable size? make it a pointer // variable size? make it a pointer
if (bits == 0) bits = 16; // TODO? if (bits == 0) bits = 16; // TODO?
let rangelen = (f.ehi - f.elo + 1); let rangelen = (f.ehi - f.elo + 1);
let bytesperelem = Math.ceil(bits/8) * rangelen; let bytesperelem = Math.ceil(bits / 8) * rangelen;
// TODO: packing bits // TODO: packing bits
// TODO: split arrays // TODO: split arrays
f.access = []; f.access = [];
for (let i=0; i<bits; i+=8) { for (let i = 0; i < bits; i += 8) {
let symbol = name + '_b' + i; let symbol = name + '_b' + i;
f.access.push({symbol, bit:0, width:8}); // TODO f.access.push({ symbol, bit: 0, width: 8 }); // TODO
if (!readonly) { if (!readonly) {
segment.allocateBytes(symbol, rangelen * bytesperelem); // TODO segment.allocateBytes(symbol, rangelen * bytesperelem); // TODO
} }
@ -319,8 +318,8 @@ export class EntityScope {
} }
allocateROData(segment: Segment) { allocateROData(segment: Segment) {
let iter = this.iterateFields(); let iter = this.iterateFields();
for (var o=iter.next(); o.value; o=iter.next()) { for (var o = iter.next(); o.value; o = iter.next()) {
let {i,e,c,f,v} = o.value; let { i, e, c, f, v } = o.value;
let cfname = mksymbol(c, f.name); let cfname = mksymbol(c, f.name);
let fieldrange = segment.fieldranges[cfname]; let fieldrange = segment.fieldranges[cfname];
if (v !== undefined) { if (v !== undefined) {
@ -333,8 +332,8 @@ export class EntityScope {
segment.allocateInitData(datasym, v); segment.allocateInitData(datasym, v);
let loofs = segment.allocateBytes(ptrlosym, entcount); let loofs = segment.allocateBytes(ptrlosym, entcount);
let hiofs = segment.allocateBytes(ptrhisym, entcount); let hiofs = segment.allocateBytes(ptrhisym, entcount);
segment.initdata[loofs + e.id - fieldrange.elo] = {symbol:datasym, bitofs:0}; segment.initdata[loofs + e.id - fieldrange.elo] = { symbol: datasym, bitofs: 0 };
segment.initdata[hiofs + e.id - fieldrange.elo] = {symbol:datasym, bitofs:8}; segment.initdata[hiofs + e.id - fieldrange.elo] = { symbol: datasym, bitofs: 8 };
} else if (fieldrange.ehi > fieldrange.elo) { } else if (fieldrange.ehi > fieldrange.elo) {
// more than one element, add an array // more than one element, add an array
// TODO // TODO
@ -348,8 +347,8 @@ export class EntityScope {
allocateInitData(segment: Segment) { allocateInitData(segment: Segment) {
let initbytes = new Uint8Array(segment.size); let initbytes = new Uint8Array(segment.size);
let iter = this.iterateFields(); let iter = this.iterateFields();
for (var o=iter.next(); o.value; o=iter.next()) { for (var o = iter.next(); o.value; o = iter.next()) {
let {i,e,c,f,v} = o.value; let { i, e, c, f, v } = o.value;
let scfname = mkscopesymbol(this, c, f.name); let scfname = mkscopesymbol(this, c, f.name);
let initvalue = e.inits[scfname]; let initvalue = e.inits[scfname];
if (initvalue !== undefined) { if (initvalue !== undefined) {
@ -389,7 +388,7 @@ export class EntityScope {
} }
let s = ''; let s = '';
//s += `\n; event ${event}\n`; //s += `\n; event ${event}\n`;
let emitcode : {[event: string] : string} = {}; let emitcode: { [event: string]: string } = {};
for (let sys of systems) { for (let sys of systems) {
// TODO: does this work if multiple actions? // TODO: does this work if multiple actions?
if (sys.tempbytes) this.allocateTempBytes(sys.tempbytes); if (sys.tempbytes) this.allocateTempBytes(sys.tempbytes);
@ -421,13 +420,14 @@ export class EntityScope {
this.tempOffset += n; this.tempOffset += n;
this.maxTempBytes = Math.max(this.tempOffset, this.maxTempBytes); this.maxTempBytes = Math.max(this.tempOffset, this.maxTempBytes);
} }
replaceCode(code: string, sys: System, action: CodeFragment): string { replaceCode(code: string, sys: System, action: Action): string {
const re = /\%\{(.+?)\}/g; const re = /\%\{(.+?)\}/g;
let label = sys.name + '_' + action.event; let label = sys.name + '_' + action.event;
let atypes = this.em.archetypesMatching(sys.query); let atypes = this.em.archetypesMatching(action.query);
let entities = this.entitiesMatching(atypes); let entities = this.entitiesMatching(atypes);
// TODO: find loops // TODO: detect cycles
if (action.iterate == 'each') { // TODO: "source"?
if (action.select == 'each') {
code = this.wrapCodeInLoop(code, sys, action, entities); code = this.wrapCodeInLoop(code, sys, action, entities);
//console.log(sys.name, action.event, ents); //console.log(sys.name, action.event, ents);
//frag = this.iterateCode(frag); //frag = this.iterateCode(frag);
@ -460,17 +460,17 @@ export class EntityScope {
this.subroutines.add(symbol); this.subroutines.add(symbol);
return symbol; return symbol;
} }
wrapCodeInLoop(code: string, sys: System, action: CodeFragment, ents: Entity[]): string { wrapCodeInLoop(code: string, sys: System, action: Action, ents: Entity[]): string {
// TODO: check ents // TODO: check ents
// TODO: check segment bounds // TODO: check segment bounds
let s = ASM_ITERATE_EACH; let s = ASM_ITERATE_EACH;
s = s.replace('%{elo}', ents[0].id.toString()); s = s.replace('%{elo}', ents[0].id.toString());
s = s.replace('%{ehi}', ents[ents.length-1].id.toString()); s = s.replace('%{ehi}', ents[ents.length - 1].id.toString());
s = s.replace('%{ecount}', ents.length.toString()); s = s.replace('%{ecount}', ents.length.toString());
s = s.replace('%{code}', code); s = s.replace('%{code}', code);
return s; return s;
} }
generateCodeForField(sys: System, action: CodeFragment, generateCodeForField(sys: System, action: Action,
atypes: ArchetypeMatch[], entities: Entity[], atypes: ArchetypeMatch[], entities: Entity[],
fieldName: string, bitofs: number): string { fieldName: string, bitofs: number): string {
// find archetypes // find archetypes
@ -513,7 +513,7 @@ export class EntityScope {
systemListensTo(sys: System, events: string[]) { systemListensTo(sys: System, events: string[]) {
for (let action of sys.actions) { for (let action of sys.actions) {
if (action.event != null && events.includes(action.event)) { if (action.event != null && events.includes(action.event)) {
let archs = this.em.archetypesMatching(sys.query); let archs = this.em.archetypesMatching(action.query);
for (let arch of archs) { for (let arch of archs) {
for (let ctype of arch.cmatch) { for (let ctype of arch.cmatch) {
if (this.hasComponent(ctype)) { if (this.hasComponent(ctype)) {
@ -559,9 +559,9 @@ export class EntityScope {
export class EntityManager { export class EntityManager {
archtypes = new Set<EntityArchetype>(); archtypes = new Set<EntityArchetype>();
components : {[name: string]: ComponentType} = {}; components: { [name: string]: ComponentType } = {};
systems : {[name: string]: System} = {}; systems: { [name: string]: System } = {};
scopes : {[name: string]: EntityScope} = {}; scopes: { [name: string]: EntityScope } = {};
newScope(name: string, parent?: EntityScope) { newScope(name: string, parent?: EntityScope) {
let scope = new EntityScope(this, name, parent); let scope = new EntityScope(this, name, parent);
@ -591,11 +591,11 @@ export class EntityManager {
return list; return list;
} }
archetypesMatching(q: Query) { archetypesMatching(q: Query) {
let result : ArchetypeMatch[] = []; let result: ArchetypeMatch[] = [];
this.archtypes.forEach(etype => { this.archtypes.forEach(etype => {
let cmatch = this.componentsMatching(q, etype); let cmatch = this.componentsMatching(q, etype);
if (cmatch.length > 0) { if (cmatch.length > 0) {
result.push({etype, cmatch}); result.push({ etype, cmatch });
} }
}); });
return result; return result;
@ -843,39 +843,60 @@ const INITFROMARRAY = `
function test() { function test() {
let em = new EntityManager(); let em = new EntityManager();
let c_kernel = em.defineComponent({name:'kernel', fields:[ let c_kernel = em.defineComponent({
{name:'lines', dtype:'int', lo:0, hi:255} name: 'kernel', fields: [
]}) { name: 'lines', dtype: 'int', lo: 0, hi: 255 },
let c_sprite = em.defineComponent({name:'sprite', fields:[ { name: 'bgcolor', dtype: 'int', lo: 0, hi: 255 },
{name:'height', dtype:'int', lo:0, hi:255}, ]
{name:'plyrindex', dtype:'int', lo:0, hi:1}, })
{name:'flags', dtype:'int', lo:0, hi:255}, let c_sprite = em.defineComponent({
]}) name: 'sprite', fields: [
let c_player = em.defineComponent({name:'player', fields:[ { name: 'height', dtype: 'int', lo: 0, hi: 255 },
//TODO: optional? { name: 'plyrindex', dtype: 'int', lo: 0, hi: 1 },
]}) { name: 'flags', dtype: 'int', lo: 0, hi: 255 },
let c_hasbitmap = em.defineComponent({name:'hasbitmap', fields:[ ]
{name:'bitmap', dtype:'ref', query:{include:['bitmap']}}, })
]}) let c_player = em.defineComponent({
let c_hascolormap = em.defineComponent({name:'hascolormap', fields:[ name: 'player', fields: [
{name:'colormap', dtype:'ref', query:{include:['colormap']}}, //TODO: optional?
]}) ]
let c_bitmap = em.defineComponent({name:'bitmap', fields:[ })
{name:'bitmapdata', dtype:'array', elem:{ dtype:'int', lo:0, hi:255 }} let c_hasbitmap = em.defineComponent({
]}) name: 'hasbitmap', fields: [
let c_colormap = em.defineComponent({name:'colormap', fields:[ { name: 'bitmap', dtype: 'ref', query: { include: ['bitmap'] } },
{name:'colormapdata', dtype:'array', elem:{ dtype:'int', lo:0, hi:255 }} ]
]}) })
let c_xpos = em.defineComponent({name:'xpos', fields:[ let c_hascolormap = em.defineComponent({
{name:'xpos', dtype:'int', lo:0, hi:255} name: 'hascolormap', fields: [
]}) { name: 'colormap', dtype: 'ref', query: { include: ['colormap'] } },
let c_ypos = em.defineComponent({name:'ypos', fields:[ ]
{name:'ypos', dtype:'int', lo:0, hi:255} })
]}) let c_bitmap = em.defineComponent({
let c_xyvel = em.defineComponent({name:'xyvel', fields:[ name: 'bitmap', fields: [
{name:'xvel', dtype:'int', lo:-8, hi:7}, { name: 'bitmapdata', dtype: 'array', elem: { dtype: 'int', lo: 0, hi: 255 } }
{name:'yvel', dtype:'int', lo:-8, hi:7} ]
]}) })
let c_colormap = em.defineComponent({
name: 'colormap', fields: [
{ name: 'colormapdata', dtype: 'array', elem: { dtype: 'int', lo: 0, hi: 255 } }
]
})
let c_xpos = em.defineComponent({
name: 'xpos', fields: [
{ name: 'xpos', dtype: 'int', lo: 0, hi: 255 }
]
})
let c_ypos = em.defineComponent({
name: 'ypos', fields: [
{ name: 'ypos', dtype: 'int', lo: 0, hi: 255 }
]
})
let c_xyvel = em.defineComponent({
name: 'xyvel', fields: [
{ name: 'xvel', dtype: 'int', lo: -8, hi: 7 },
{ name: 'yvel', dtype: 'int', lo: -8, hi: 7 }
]
})
// init -> [start] -> frameloop // init -> [start] -> frameloop
// frameloop -> [preframe] [kernel] [postframe] // frameloop -> [preframe] [kernel] [postframe]
@ -884,23 +905,29 @@ function test() {
// temp between preframe + frame? // temp between preframe + frame?
// TODO: check names for identifierness // TODO: check names for identifierness
em.defineSystem({ em.defineSystem({
name:'kernel_simple', name: 'kernel_simple',
tempbytes:8, tempbytes: 8,
query:{ actions: [
include:['sprite','hasbitmap','hascolormap','ypos'], {
}, text: TEMPLATE4_S, event: 'preframe', select: 'once', query: {
actions:[ include: ['sprite', 'hasbitmap', 'hascolormap', 'ypos'],
{ text:TEMPLATE4_S, event:'preframe', iterate:'once' }, },
{ text:TEMPLATE4_K, event:'kernel', iterate:'once' }, },
{
text: TEMPLATE4_K, event: 'kernel', select: 'once', query: {
include: ['kernel']
}
},
] ]
}) })
em.defineSystem({ em.defineSystem({
name:'set_xpos', name: 'set_xpos',
query:{ actions: [
include:['sprite','xpos'] {
}, text: SET_XPOS, event: 'preframe', select: 'each', query: {
actions:[ include: ['sprite', 'xpos']
{ text:SET_XPOS, event:'preframe', iterate:'each' }, },
},
//{ text:SETHORIZPOS }, //{ text:SETHORIZPOS },
] ]
}) })
@ -911,68 +938,55 @@ function test() {
// https://docs.unity3d.com/Packages/com.unity.entities@0.17/manual/ecs_systems.html // https://docs.unity3d.com/Packages/com.unity.entities@0.17/manual/ecs_systems.html
em.defineSystem({ em.defineSystem({
name:'frameloop', name: 'frameloop',
emits:['preframe','kernel','postframe'], emits: ['preframe', 'kernel', 'postframe'],
query:{ actions: [
include:['kernel'], // ??? { text: TEMPLATE1, event: 'start', select: 'once', query: { include: [] } } // TODO: []?
},
actions:[
{ text:TEMPLATE1, event:'start', iterate:'once' }
] ]
}) })
em.defineSystem({ em.defineSystem({
name:'joyread', name: 'joyread',
query:{ tempbytes: 1,
include:['player'] emits: ['joyup', 'joydown', 'joyleft', 'joyright', 'joybutton'],
}, actions: [
tempbytes:1, { text: TEMPLATE2_a, event: 'postframe', select: 'once', query: { include: ['player'] } },
emits:['joyup','joydown','joyleft','joyright','joybutton'], { text: TEMPLATE2_b, event: 'postframe', select: 'each', query: { include: ['player'] } }
actions:[
{ text:TEMPLATE2_a, event:'postframe', iterate:'once' },
{ text:TEMPLATE2_b, event:'postframe', iterate:'each' }
] ]
}); });
em.defineSystem({ em.defineSystem({
name:'move_x', name: 'move_x',
query:{ actions: [
include:['player','xpos'] { text: TEMPLATE3_L, event: 'joyleft', select: 'source', query: { include: ['player', 'xpos'] }, },
}, { text: TEMPLATE3_R, event: 'joyright', select: 'source', query: { include: ['player', 'xpos'] }, },
actions:[
{ text:TEMPLATE3_L, event:'joyleft', iterate:'once' }, // TODO: event source?
{ text:TEMPLATE3_R, event:'joyright', iterate:'once' }, // TODO: event source?
] ]
}); });
em.defineSystem({ em.defineSystem({
name:'move_y', name: 'move_y',
query:{ actions: [
include:['player','ypos'] { text: TEMPLATE3_U, event: 'joyup', select: 'source', query: { include: ['player', 'ypos'] } },
}, { text: TEMPLATE3_D, event: 'joydown', select: 'source', query: { include: ['player', 'ypos'] } },
actions:[
{ text:TEMPLATE3_U, event:'joyup', iterate:'once' }, // TODO: event source?
{ text:TEMPLATE3_D, event:'joydown', iterate:'once' }, // TODO: event source?
] ]
}); });
em.defineSystem({ em.defineSystem({
name:'SetHorizPos', name: 'SetHorizPos',
query:{ include:[] }, // TODO? actions: [
actions:[ { text: SETHORIZPOS, event: 'SetHorizPos', select: 'once', query: { include: [] } }, // TODO: []?
{ text:SETHORIZPOS, event:'SetHorizPos', iterate:'once' }, // TODO: event source?
] ]
}); });
let root = em.newScope("Root"); let root = em.newScope("Root");
let scene = em.newScope("Scene", root); let scene = em.newScope("Scene", root);
let e_ekernel = root.newEntity({components:[c_kernel]}); let e_ekernel = root.newEntity({ components: [c_kernel] });
root.setConstValue(e_ekernel, c_kernel, 'lines', 192); root.setConstValue(e_ekernel, c_kernel, 'lines', 192);
let e_bitmap0 = root.newEntity({components:[c_bitmap]}); let e_bitmap0 = root.newEntity({ components: [c_bitmap] });
// TODO: store array sizes? // TODO: store array sizes?
root.setConstValue(e_bitmap0, c_bitmap, 'bitmapdata', new Uint8Array([0,1,3,7,15,31,0])); root.setConstValue(e_bitmap0, c_bitmap, 'bitmapdata', new Uint8Array([0, 1, 3, 7, 15, 31, 0]));
let e_colormap0 = root.newEntity({components:[c_colormap]}); let e_colormap0 = root.newEntity({ components: [c_colormap] });
root.setConstValue(e_colormap0, c_colormap, 'colormapdata', new Uint8Array([0,3,6,9,12,14,0])); root.setConstValue(e_colormap0, c_colormap, 'colormapdata', new Uint8Array([0, 3, 6, 9, 12, 14, 0]));
let ea_playerSprite = {components:[c_sprite,c_hasbitmap,c_hascolormap,c_xpos,c_ypos,c_player]}; let ea_playerSprite = { components: [c_sprite, c_hasbitmap, c_hascolormap, c_xpos, c_ypos, c_player] };
let e_player0 = root.newEntity(ea_playerSprite); let e_player0 = root.newEntity(ea_playerSprite);
root.setInitValue(e_player0, c_sprite, 'plyrindex', 0); root.setInitValue(e_player0, c_sprite, 'plyrindex', 0);
root.setInitValue(e_player0, c_sprite, 'height', 8); root.setInitValue(e_player0, c_sprite, 'height', 8);