# Ideas about to be discussed These ideas are from Unity engine and Godot engine. I spent much time looking into them before, so I wanna convince you guys that these ideas are amazing! ## Idea 1: Make everything a Component if possible Some things can appear to be implemented as merely a simple class, but if we make them Component, they can be very flexible. For example, - Camera (https://docs.unity3d.com/Manual/class-Camera.html) We probably only need a global unique one. We can then place it onto the root node of the scene. - Renderable (https://docs.unity3d.com/Manual/class-SpriteRenderer.html) - AudioPlayer (https://docs.unity3d.com/Manual/class-AudioSource.html) - ... - MOST IMPORTANTLY, custom java class! (https://docs.unity3d.com/2021.1/Documentation/Manual/CreatingAndUsingScripts.html) Combining idea 1 and idea 2, we can do powerful stuff. Because everything can be seen as a component of some GameObject instance, we can pass references to the gameobject that contains the component we want to another gameobject however we like. I don't know how to explain this clearly, please see the example below. ## Idea 2: generalized way to reference basically everything We can set up a generalized way of referecing class methods, game objects, assets (image, audio, etc), and so on. Then in the config files, we can use the reference to specify payloads, action handlers, objects, etc. This is useful IF we want to make a game editor so user can drag and drop anything to a slot, where slot is a parameter of a component or a place to register input handler, etc. Moreover, this is very flexible. ## Example Level Definition The string format of reference can be revised, for now: ```json= { // ... objects: [ { name: "player", "components": [ { compName: "SwordController", // sword controller animate the swinging of sword sword: '[GameObject name=sword]' }, { compName: "PlayerCollider", image: '[Asset player_image]', onCollide: [ with: '[GameObject tag=Block]', action: [ { action: '[Method that registerWalk]', // for example, show dirt on the ground when player walk payload: '[GameObject self]' // registerWalk can use gameObject.getComponent<Transform>.getPosition() }, { action: '[Method [Component [GameObject name=root] AudioManager] playAudio]', payload: '[Asset player_walk]' } ] ] } ], }, { name: "sword", "components": [ { compName: "SwordController", onCollide: [ with: '[GameObject tag=enemy]', action: '[Method [Component [GameObject name=player] PlayerController] doDamage]', payload: ['[GameObject self]', '[Config sword_damage_value]'] ] }, ] }, { name: "enemy1", tag: enemy, }, { name: "block1", tag: block, }] } ``` Similarly, we can use this in the input configuration. The shortcomings: - We need to write a parser to parse string to a Reference class - Might overcomplicate things for simple levels