Scene and Entities

Games built with Otter are made with Scenes, which contain Entities.  The most common practice is to have Otter's Game class run one Scene at a time.  A Scene will then run all of the Entities it contains.  You could think of an Entity as your base game object, and Scenes can be used for different portions of your game.  For example you might have a Scene for your title screen, and then a Scene for your main gameplay, and maybe a Scene for a pause menu, and so on.

Let's see some code!

using Otter;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ScenesAndEntities {
  class Program {
    static void Main(string[] args) {
      // Create a new game
      var game = new Game("Scenes and Entities");

      // Create an Entity to use at X 350, Y 240
      var testEntity = new Entity(350, 240);
      // Add a red circle graphic to the Entity (so we can see it!)
      testEntity.AddGraphic(Image.CreateCircle(100, Color.Red));

      // Create a new Scene
      var scene = new Scene();
      // Add the Entity to the Scene

      // Start the game using the scene

For this very simple example all we need to do is create a Scene and an Entity in our main Program.cs.  We can then add a graphic to the Entity, and then add that Entity to the Scene.  When we use game.Start(scene) we tell Otter to start the game with our scene.  If all goes well you should end up with something like this: