Problem: usually, when creating games with several levels, I create the "engine" that executes the game logic, and then particular levels are specified by data; possibly loaded from files. In my latest project I came with requirement to specify levels also by several functions that influence their behavior. Of course, usage an expression with many ifs or switch/case statements checking the current level would be too cumbersome. Instead, it would be nice if it is possible to use the same "engine" with pluggable components.
Suggested solution: to allow values/variables of type component and assignments to CallComponent.Component property. In addition, expressions like this should also be allowed:
Code: Select all
component var1;
var1 = <component name>;
@CallComponent(Cmponent: var1);
"Engine extension points" would be defined as CallComponent components and definition of level just assigned appropriate components to CallComponent.Component properties.
Note: Other possible solutions could come from C with pointers to functions, or from other languages supporting lambda calculus or closures. But these features would be too "hardcore" for ZGE, I think.