This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
dragengine:modules:dragonscript:abstractions [2020/05/05 20:36] – dragonlord | dragengine:modules:dragonscript:abstractions [2025/03/13 17:03] (current) – dragonlord | ||
---|---|---|---|
Line 4: | Line 4: | ||
</ | </ | ||
- | + | ====== | |
- | ====== | + | |
The **DragonScript Scripting Module** provides 3 main ways to build your game depending on your skill level and project requirements. The layers are listed from the most simple one (which is recommended for most projects) to the most flexible one. | The **DragonScript Scripting Module** provides 3 main ways to build your game depending on your skill level and project requirements. The layers are listed from the most simple one (which is recommended for most projects) to the most flexible one. | ||
+ | ====== Behavior Elements ====== | ||
- | + | <WRAP center round tip 60%> | |
- | ====== Behavior Elements: | + | The Quick and Easy way to Development |
+ | </ | ||
**Behavior Elements** are build on top of the **Scenery Elements** and provide a **composeable** way to build game logic. This is the fastest way to build your game by befitting elements with reusable **behavior** while still retaining all the powerful coupling to other script classes. | **Behavior Elements** are build on top of the **Scenery Elements** and provide a **composeable** way to build game logic. This is the fastest way to build your game by befitting elements with reusable **behavior** while still retaining all the powerful coupling to other script classes. | ||
- | Behavior elements are created by subclassing from [[https:// | + | [[dragengine:modules: |
- | Behavior definitions are created by subclassing from [[https:// | + | ====== Scenery Elements ====== |
+ | <WRAP center round tip 60%> | ||
+ | Customized and Optimized for Special Needs | ||
+ | </WRAP> | ||
- | Element class properties can be used with **XML Subclassing**. You can created a new element class just using an XML file (*.deeclass) and change the properties added by the behavior definition. This is especially useful for mappers to add variations of **Game Objects** without needing to touch script code for such a simple task. | + | TODO |
- | Furthermore **Element Stubs** used to create **Game Objects** in your game world use the same names as the element class properties. This allows mappers to modify behaviors on a per **Game Object** basis if required. | + | ====== Bare-Bone Implementation ====== |
- | + | <WRAP center round tip 60%> | |
- | You can query [[https:// | + | Create all from Scratch mostly |
- | + | </WRAP> | |
- | Once a [[https:// | + | |
- | + | ||
- | Behaviors are split in two groups: **Basic Behaviors** and **Complex Behaviors**. **Basic Behaviors** add a small basic building block of game logic like for example a component showing the visual appearance of a game object. These are highly reusable. **Complex Behaviors** on the other hand typically expect one or more **Basic Behaviors** to be present in the element class to provide a complex behavior for example animating the visual appearance. | + | |
- | + | ||
- | + | ||
- | The **DragonScript Scripting Module** provides these **Basic Behaviors** as starting help: | + | |
- | * [[https:// | + | |
- | * [[https:// | + | |
- | * [[https:// | + | |
- | * [[https:// | + | |
- | * [[https:// | + | |
- | + | ||
- | The **DragonScript Scripting Module** provides these **Complex Behaviors** as starting help: | + | |
- | * [[https:// | + | |
- | * [[https:// | + | |
- | * [[https:// | + | |
- | * [[https:// | + | |
- | * [[https:// | + | |
- | + | ||
- | + | ||
- | Many more complex behaviors can be created either just for this game project or to be shared with other projects. Behaviors can extend other behaviors by subclassing or by using other behaviors present in the behavior element class. | + | |
- | + | ||
- | TODO: | + | |
- | * [[behaviors_use_cases|Behaviors Explained: By Use-Case]] | + | |
- | * [[behaviors_a_to_z|Behaviors Explained: From A to Z]] | + | |
- | + | ||
- | This is an example of an element class which which has a visual appearance, physical interaction, | + | |
- | + | ||
- | < | + | |
- | pin Dragengine.Gui | + | |
- | pin Dragengine.Scenery | + | |
- | pin Dragengine.Utils | + | |
- | + | ||
- | class MyTrainClass extends BehaviorElementClass | + | |
- | public var ECBehaviorComponent component | + | |
- | public var ECBehaviorAnimated animated | + | |
- | public var ECBehaviorCollider collider | + | |
- | public var ECBehaviorMoveOnRail moveOnRail | + | |
- | public var ECBehaviorLight headLightLeft | + | |
- | public var ECBehaviorLight headLightRight | + | |
- | public var ECBehaviorSpeaker speaker | + | |
- | + | ||
- | public func new() super(" | + | |
- | // create visual appearance with default model(mesh), | + | |
- | // physical interaction and animation purpose. this method assigns the resources located | + | |
- | // in the common directory "/ | + | |
- | component.setCommonPath("/ | + | |
- | + | ||
- | // create collider which is used for physical interaction. in most situations you want to | + | |
- | // animate the component with the rig. this requires to component behavior to go first | + | |
- | collider | + | |
- | + | ||
- | // create head lights. attached to collider with id " | + | |
- | headLightLeft | + | |
- | headLightLeft.getLight().getColor().setColor(Color.yellow) | + | |
- | headLightLeft.getAttach().getPosition().setVector(Vector.new(-1, 0.5, 2)) | + | |
- | + | ||
- | headLightRight | + | |
- | headLightRight.getLight().getColor().setColor(Color.yellow) | + | |
- | headLightRight.getAttach().getPosition().setVector(Vector.new(1, | + | |
- | + | ||
- | // create engine speaker. attached to the collider | + | |
- | speaker | + | |
- | speaker.getSpeaker().getSound().setPath("/ | + | |
- | speaker.getAttach().getPosition().setVector(Vector.new(0.0, | + | |
- | + | ||
- | // create behavior animating the visual appearance (component) using an animator | + | |
- | animated | + | |
- | animated.getAnimator().getAnimator().setPath("/ | + | |
- | + | ||
- | // create behavior moving collider on rail. the mapper defines what rail to use. | + | |
- | // if you assign also the trigger table from the BaseGameApp then the mapper | + | |
- | // can use triggers to start/stop moving the train. if you want to control this | + | |
- | // on your own (or by other behaviors only) leave out this argument | + | |
- | moveOnRail | + | |
- | end | + | |
- | end | + | |
- | </code> | + | |
- | + | ||
- | The above script code creates a working element class which adds instances of BehaviorElement to the game world set up with the defined behaviors. If you want to have a unique element instance | + | |
- | < | + | |
- | class MyTrainClass extends BehaviorElementClass | + | |
- | ... | + | |
- | protected func Element createElement() | + | |
- | return MyTrain.new(this) | + | |
- | end | + | |
- | end | + | |
- | + | ||
- | class MyTrain extends BehaviorElement | + | |
- | public func new(MyTrainClass eclass) super(eclass) | + | |
- | ... | + | |
- | end | + | |
- | end | + | |
- | </code> | + | |
- | + | ||
- | Using unique instances allows to add run-time features to your class on top of what BehaviorElement provides without creating an own behavior. In general it is recommended to work with behaviors only and creating your own ones. This way you can reuse game logic across different projects easily. | + | |
- | ====== Scenery Elements: Customized and Optimized for Special Needs ====== | + | |
TODO | TODO | ||
- | ====== Bare-Bone Implementation: | ||
- | TODO |