Designing 2D Games or simulations with Nerma2D Version 1.0



Introduction
Installation
The Global Idea
The Global User Interface
Defining Objets
Defining Interactions
Adding and configuring instances on the scene
User interaction
Special considerations




Introduction



Nerma2D is 3 things:
  • an object-oriented meta-model for discrete time simulation,
  • a 2D display system that plugs on the core architecture to allow to visualize running instances of your models,
  • an editor that helps you greatly to create models and their instances,
  • a runtime engine to run and debug the final system.
It can thus be used to create simulations with or without 2D output. But it surely has a powerfull 2D architecture that makes it well suitable for designing 2D games. It leads users to divide intuitively their wanted system into separated objects that interacts. As a result maximum reusability of artefacts is one of the main advantages of Nerma2D.



Installation



Nerma2d is a freeware: you can use or redistribute it freely. A windows installer is available for download on the project main site: http://nerma2d.free.fr/download.html


The Global Idea



There are two main resources to manipulate in Nerma2D: "Objects" and "Interactions".
  • Objects are meant to be representation of real world objects or any other somehow logically separated resource (sprites, backgounds, timer, AI,...).
  • Interactions are used to specify the way objects will influence each other. After having created former resources you have design the scene start configuration by adding instances of objects and connecting them through instances of intercations.



The Global User Interface



The main window of Neram2D is divided vertically in two parts:
At the left part of the window you have a tabbed control and a "Frame/s" small area.
  • The Frame/s area lets you view or edit the number of frames rate of wanted system. But the runtime frames rate may be lower according to your computer power and the scene complexity.
  • The tabbed control gives you acces to 2 pages:
    • Data page where you can add, edit, duplicate or remove objects and interactions,
    • Instances page where you can instantiate objects or interactions that you have defined in the preceding tab.
At the right part of the window, there is the scene canvas hat gives an overview of the start configuration of the scene.



Defining Objets



  • Generic Parameters are values for flexibility of instanciation of each object.
    Note that there are some predefined generic parameters for each object instance shape attribute. This will be covered in Adding and configuring instances on the scene section.
  • Properties represent aspects of the object viewable from the environment.
  • Collision Layers are used to represent tagged collidable zones made available to the environment.
    Note that there are 2 predefined collision layers: one for the current image box (imageBox) and one for its non transparent area (default) which can be used when specifying interaction instances.
  • Influence Ports are used by the object to get information from the environment.
  • Images are loaded from files with most of the well-known image types. The transparent colour must be defined for each image.
  • Sounds are also loaded from most of audio formats files. Only one sound can be emitted at a given time by one object.
  • Animations control the changes of the internal state of the object. An animation is composed of at least one step. Each step can be associated with an image, a sound and some actions that will be used when the step will be the current one. A loop step can be defined to allow the animation to loop infinitely on it. Otherwise, the animation ends up after the last step.



Defining Interactions



  • Generic Parameters are values for flexibility of instanciation of each interaction.
    Note that there are some predefined generic parameters for each interaction instance shape attribute. This will be covered in Adding and configuring instances on the scene section.
  • Property ports represent values that must be provided by each object taking part in the interaction process.
  • Collision Layer ports are collidable zones provided by each object.
  • Temporary Vars may be used to simplify complex calculations made during an interaction process by storing intermediary results.
  • Influences are values thrown by each object instance through an interaction instance to any other object linked to the same interaction instance. That means that if there are N objects connected to an interaction, they will either receive N-1 influence values. It is then useless to have only one object connected to an interaction instance since it will receive 1-1=0 influences. Note that the final influence received on an object influence port is the sum of all the influences values received from all the other interacting objects.



Adding and configuring instances on the scene



Instances of objects or interactions can be accessed in the "Instances" tab at the left of the main window. They can be added, edited, duplicated or deleted. Every object instance added to the scene appears on the scene canvas widget at the right of the main window. This canvas gives an overview of the start configuration of the scene and highlight connections between objects and interaction instances by drawing green lines between them. Note that each instance or connection can be moved, edited, duplicated or deleted indifferently through the scene canvas or the "Instances" tab.
  • An object instance has the following attributes:
    • (shapeX, shapeY): position of the object shape's center on the scene canvas. The camera (moveX,moveY) and (width,height) are respectively the center and the dimensions of the scene canvas,
    • (shapeXScale, shapeYScale): horizontal and vertical scaling of the object shape,
    • shapeRotation: the angle in radians the object shape is rotated by. Note that the rotation is applied after the scaling,
    • shapeSoundVolume: the volume affected to the sound emitted by the the object shape when it is clicked on.
  • An interaction instance has the following attributes:
    • (shapeX, shapeY): position of the interaction shape's center on the scene canvas,
    • objectInInteractionRegistrations: They represent the set of object instances that will take part to the a particular interaction instance process when the scene will be running. Each registration contains the mapping values of each interaction port (propery ports and collision layer ports) and each influence port of the registered object instance. They are represented by green lines connecting object and interaction shapes on the scene canvas.
These attributes are in fact predefined generic parameters and can be used exactly like generic parameters.
Note the presence of the "System" element at the top of interaction instances list box. It will be discussed further in the User interaction section.



User interaction



The System element is a special predefined interaction instance that allows object instances to be aware of the state of some system related aspects (keyboard and mouse states). The end-user ability to influence the scene process will thus be specified in this instance. It just contains objectInSystemRegistration that are sets of mappings from system related values to each added object instance influence ports.



Special considerations



  • Pay attention to the collision detection because it consumes much processor resources. Use collision masks with their precision as lowest as possible. Prefer the use of the "imageBox" collision layer in any case it suits.
  • If we consider N as the number of object instances contributing to an interaction process, you must be aware that the number of influences is N*(N-1) since each object influences the others. You must then split as much as possible object instances into different interaction instances so that 2 object instances that are not expected to interact don't reside in the same interaction instance.
    For instance:
    • N=5, NbInfluences=20
    • N=10, NbInfluences=90
    • N=20, NbInfluences=380
  • Try to conceive objects that all behave normally with the frames rate set to 24. It would allow more reusability. If the object is normally slow, you can duplicate animation steps to fake the slowness.