I moved to a new URL! Check it out!

posts filed under: otter

Dev Log: Otter Updates

Dev Log: Otter Updates
Some crazy updates happening in the dev branch of Otter recently! Here's the scoop on what's been going on:

* Changed how Entities are Added to the Scenes. The Entity's Added() method now fires when the Entity is actually added to the Scene at the end of the current frame. The Added method also fires after all Entities in the adding queue have been added.

This means that if you're adding a player object, and then an enemy object afterwards, and the player object needs to reference the enemy object in its Added() method it should be possible to do so.

* In a similar fashion the Components have been changed in regards of when their Added() method is called. Components in the add queue are added at the beginning of Added, UpdateFirst, Update, and UpdateLast, and their Added method will fire when they are actually added to the Entity from the queue.

* GetComponent can now return Components that are still in the adding queue if none are found on the Entity itself.

* GetComponents() returns a list of Components of a certain type.

* Axis now has access to Up Down Left Right buttons. Very handy for having to check for button presses on an Axis and not having to create 4 separate buttons to do so.

* Repeat has been changed to two bools RepeatX and RepeatY.

* Util.Log() now behaves like a format string call (similar to Console.WriteLine())

* BitmapFont support is coming along and now supports data for three different bitmap font generators, as well as support for standard monospaced fonts.

* RichText characters can now be accessed and manipulated individually. This means you can do stuff like animate properties of characters yourself instead of relying on the mark up in strings.

* Other minor clean up and fixes that should make stuff better overall.

In other Otter updates be sure to follow the journey of Otter Pup 681!

Otter Updates

Otter Updates
Some quick updates to Otter in the dev branch!

* Added the Polygon class: For the Polygon collision stuff I created a quick helper class to keep track of the points in a polygon. This class also has some neat functions that are used in the Collider class to figure out polygon collision stuff.

* Added PolygonCollider: Now there is an actual PolygonCollider in Otter! You can use it to check for collisions with any other type of collider too. I expect there to be some bugs so be on the look out when using it.

* Various Collider Updates: Some of the colliders had some minor bugs so I squashed all of the ones I could find.

Dev Log: Polygon Collisions

Dev Log: Polygon Collisions
I never thought I'd be able to get polygon collisions working in Otter but this past week I managed to jam out a quick prototype of an overlapping polygon test that seems to be working.

Image


Probably not the most exciting image in the world, but it's pretty dang cool to me. I found this tutorial on the Separating Axis Theorem. This tutorial specifically has some great images, and amazing pseudocode with explanations that allowed me to finally understand what the hell to do. I still don't understand some things, like what exactly projecting a vector onto an axis means, but right now I think I have the core of it working.

I'll be working on getting the PolygonCollider integrated into Otter properly over the next few days. That means I'll have to get it working with each other Collider type which shouldn't be too crazy, but we'll see if I end up getting stumped by something!

Otter Updates!

Otter Updates!
I've pushed a handful of updates to the dev branch of Otter over the past week. The commits and source and all that good stuff is always available on BitBucket.

* Fixed a minor bug in the Coroutines. (If you opted to use multiple coroutine managers for whatever reason it would break the game's main coroutine manager. This should no longer be the case now.)

* Changed Direction to a bitfield. (Thanks to Fruckert!)

* Added a Prerender() function to Entities. (I realized I needed to draw some graphics before an Entity has rendered its own graphics, and the way I set it up in Otter made it harder to do this than compared to FlashPunk. Now you can render things before the Entity renders by overriding Prerender() and putting your Draw functions there.)

* Added tagging to the debug logs. (You can now log things to the console with a tag, and add or remove tags that you want to see in the console.)

That's all for now. I might be adding a PathFinder component to Otter soon, but we'll see if it makes sense to do so.

Some Otter Updates

Some Otter Updates
Over the past month or so I have been pushing a few updates to the dev branch of Otter. Slowly crawling toward the big 1.0 as I continue to work on, and work with the engine. My experiments of doing some tiny projects every now and then give me more ideas for improving the work flow, but I might save that for a post 1.0 update. Anyway, here's a few things that happened on the dev branch.

* Added SetPosition() to Graphic

* Added Start(Scene firstScene) to Game. (Instead of having to set Game.FirstScene)

* Added SurfaceX() and SurfaceY() to Surface for getting the positions on a surface relative to the game window (doesn't work for scaling and rotating yet though.)

* Added SetLayer() functions to Tilemap.

* Hopefully fixed Game.SetWindowScale() (It was rescaling some resolutions incorrectly, resulting in a few ugly pixels.)

* Added Axis.CreateWASD() and Axis.CreateArrowKeys() shortcuts.

* Fixed Grid not using its Color correctly.

Quick Otter Camera Example

Quick Otter Camera Example
A question about the camera in Otter came up on the forums, and I whipped up a small example that could be useful to take a look at for getting started with Otter in general. The whole program is just this little chunk of code:

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

namespace CameraTestThing {
class Program {
static void Main(string[] args) {

var game = new Game("Camera Test", 320, 180);
game.SetWindowScale(4);
game.Start(new TestScene());
}
}

class TestScene : Scene {

public TestScene() {
var grid = new Grid(1000, 1000, 20, 20, Color.Grey);
AddGraphic(grid);
Add(new Player());
}
}

class Player : Entity {

Vector2 speed = new Vector2();
Vector2 targetSpeed = new Vector2();
Vector2 maxSpeed = new Vector2(2, 2);
float accel = 0.01f;

Axis movementAxis = Axis.CreateArrowKeys();

public Player() {
SetGraphic(Image.CreateRectangle(10, Color.Red));
AddComponent(movementAxis);
}

public override void Update() {
base.Update();

targetSpeed.X = movementAxis.X * maxSpeed.X;
targetSpeed.Y = movementAxis.Y * maxSpeed.Y;

speed.X = Util.Approach(speed.X, targetSpeed.X, accel);
speed.Y = Util.Approach(speed.Y, targetSpeed.Y, accel);

X += speed.X;
Y += speed.Y;

Scene.CenterCamera(X, Y);
}
}
}

Compiling that with the latest dev version of Otter gives you a simple player object that can move around a scene. The background is a grid so that you can actually see scrolling happening. This quickly shows how to set up a movement Axis, how to apply speed to an object while getting input from the Axis, and how to center the camera on the object.