I moved to a new URL! Check it out!

posts dated from: march 2014

Dev Log: Coroutine Example

Image


Thanks to knowledge passed down from Chevy Ray I was able to get Coroutines working in Otter recently! Coroutines are magical chunks of code that are able to yield their execution and remember their state. It's bonkers what you can do with them using this power.

I added an example to Otter to hopefully help out any folks that are looking into using them:
using Otter;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CoroutineExample {
class CoroutineScene : Scene {

public Image ImageBox = Image.CreateRectangle(50);

public Color NextColor = Color.White;
public Color CurrentColor = Color.White;

public CoroutineScene() : base() {
// Center that box.
ImageBox.CenterOrigin();

// Gotta draw the box.
AddGraphic(ImageBox);

// Set the box position.
ImageBox.X = 100;
ImageBox.Y = 100;
}

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

// Start the coroutine, yo.
Game.Coroutine.Start(MainRoutine());
}

/// <summary>
/// The main coroutine to execute. This will move the box around and change its color.
/// </summary>
/// <returns>Whatever a coroutine thing returns. Sometimes 0 I guess.</returns>
IEnumerator MainRoutine() {
// Wait for 30 frames.
yield return Coroutine.Instance.WaitForFrames(30);
// Set the next color.
NextColor = Color.Red;
// Move the box to the top right.
yield return MoveBoxTo(540, 100);

// Wait for 30 frames.
yield return Coroutine.Instance.WaitForFrames(30);
// Set the next color.
NextColor = Color.Yellow;
// Move the box to the bottom right.
yield return MoveBoxTo(540, 380);

// Wait for 30 frames.
yield return Coroutine.Instance.WaitForFrames(30);
// Set the next color.
NextColor = Color.Green;
// Move the box to the bottom left.
yield return MoveBoxTo(100, 380);

// Wait for 30 frames.
yield return Coroutine.Instance.WaitForFrames(30);
// Set the next color.
NextColor = Color.Cyan;
// Move the box to the top left.
yield return MoveBoxTo(100, 100);

// Start a new coroutine.
Game.Coroutine.Start(MainRoutine());
}

IEnumerator MoveBoxTo(float x, float y) {
// Used to determine the completion.
var initialDistance = Util.Distance(ImageBox.X, ImageBox.Y, x, y);

float currentDistance = float.MaxValue;
while (currentDistance > 1) {
currentDistance = Util.Distance(ImageBox.X, ImageBox.Y, x, y);

// Determine the completion of the movement from 0 to 1.
var completion = Util.ScaleClamp(currentDistance, 0, initialDistance, 1, 0);

// Lerp the color of the box.
ImageBox.Color = Util.LerpColor(CurrentColor, NextColor, completion);

// Spin the box along with its movement.
ImageBox.Angle = Util.ScaleClamp(completion, 0, 1, 0, 360);

// Actually move the box.
ImageBox.X = Util.Approach(ImageBox.X, x, 5);
ImageBox.Y = Util.Approach(ImageBox.Y, y, 5);

// Wait until next frame.
yield return 0;
}

// Done moving. Update the color.
CurrentColor = NextColor;
}
}
}
I'm actually totally not sure if I'm doing it correctly in the example, but it seems to be working out well so far. Going to try using them for various things now in my current projects!

Doodle Post

Image


Colored this with 20% monitor brightness so hopefully it came out okay.

Otter Updates

Otter Updates
Over the past week I've finally pushed some updates to Otter after managing to rip out the Spine animation stuff. It turns out that in order to use the Spine runtime you need a purchased copy of Spine, meaning that if I include the Spine code in Otter everyone that uses Otter would need a copy of Spine... not ideal. (I wish Spine wouldn't license their code like this.)

So now the Spine runtime for Otter lives in a separate repository. It can be used along with Otter if you import it into your solution also using Otter. After you import it you need to give it a reference to Otter (also in your solution) and then give your game project a reference to OtterSpine. Then you should be ready to roll with SpineAnimation.cs.

Other updates to otter include:

* Renamed GetClass to GetEntities on Scene
* Add Vertices graphics type
* Added Color.Mix()
* Corrected issue between game angle and graphics angles
* Fixed issue with BoxCollider constructor
* Fixed some collision bugs
* Added shortcut of Left-Alt in Debugger to hide debugger (useful for screenshots)
* Minor updates to Particle
* Added LerpColor to Util
* Slight changes to Vector2

If there's any bugs or horrific things broken then let me know in the Otter forums!

Doodle Post

Image


Image

TowerFall Tournament Finals



Check out me playing TowerFall at the Humble Bundle 2014 World Invitational Tournament vs. my good friend and training buddy Will Courtney. It was a best of 5 set and each of us had to play through amazing opponents to get to the finals. Good times!

Humble Weekly Sale!

Humble Weekly Sale!
Just a quick heads up, Offspring Fling is currently in the Humble Weekly Sale along with seven other amazing games.

This particular bundle is in support of the software and tools that we use to create our games, including FlashDevelop which was used for Offspring Fling.

It works the same way as a regular bundle, and you get more amazing games if you pay enough moneys. You also get Steam activations for all of the games.