I moved to a new URL! Check it out!

posts tagged with: otter

Otter Example: Tilemaps

Otter Example: Tilemaps
The next Otter example is up and deals with the wild world of using tilemaps. The following example is a way to drop some tiles into a scene and also use the mouse to edit them.

namespace TilemapExample {
class Program {
static void Main(string[] args) {
// Create a Game.
var game = new Game("Tilemap Example");

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

// Set the mouse visibility to true for this example.
game.MouseVisible = true;

// Start the Game.
game.Start(scene);
}
}

class Tiles : Entity {
// The Tilemap Graphic to use for rendering tiles.
public Tilemap Tilemap;
// The grid size to use for the Tilemap.
public static int GridSize = 32;
// The current selected tile to place.
public int CurrentTile;

public Tiles() : base() {
// Create the Tilemap the size of the game window using the defined grid size.
Tilemap = new Tilemap("tiles.png", Game.Instance.Width, Game.Instance.Height, GridSize, GridSize);
// Add the Tilemap to the list of Graphics to render.
AddGraphic(Tilemap);

// Place some tiles.
Tilemap.SetTile(0, 0, 0);
Tilemap.SetTile(1, 0, 0);
Tilemap.SetTile(2, 0, 0);

// Place some more tiles.
Tilemap.SetTile(0, 4, 1);
Tilemap.SetTile(1, 4, 1);
Tilemap.SetTile(2, 4, 1);

// Even more tiles.
Tilemap.SetTile(0, 8, 2);
Tilemap.SetTile(1, 8, 2);
Tilemap.SetTile(2, 8, 2);

// Want more tiles?
Tilemap.SetTile(0, 12, 3);
Tilemap.SetTile(1, 12, 3);
Tilemap.SetTile(2, 12, 3);
}

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

// Determine the grid position of the mouse.
var gridX = (int)Util.SnapToGrid(Input.MouseX, GridSize) / GridSize;
var gridY = (int)Util.SnapToGrid(Input.MouseY, GridSize) / GridSize;

// Switch the current tile to place based on the mouse wheel movement.
CurrentTile += Input.MouseWheelDelta;
CurrentTile %= 4; // Make sure the current tile is always 0 to 3.

if (Input.MouseWheelDelta != 0) {
// Log the current tile value.
Console.WriteLine("Current Tile is now {0}", CurrentTile);
}

// Place a tile when the left mouse button is down.
if (Input.MouseButtonDown(MouseButton.Left)) {
Tilemap.SetTile(gridX, gridY, CurrentTile);
}
// Remove a tile when the right mouse button is down.
if (Input.MouseButtonDown(MouseButton.Right)) {
Tilemap.ClearTile(gridX, gridY);
}
}
}
}
Make sure to download the tilemap source image as well. The final result should end up something like this:

Image


Even more examples on the way!

Otter Example: More Collisions

Otter Example: More Collisions
Hot of the presses with a new Otter example! This example goes over more of the collider types that can be used in Otter. In total Otter has a Box, Circle, Grid, Polygon, Pixel, Point, and Line collider, and this example will cover all of them except for the Pixel collider (because that one should be used very sparingly anyway.)

Here's a quick preview of the code that can be found in the example:
class PolygonTest : Entity {

PolygonCollider polygonCollider;

public PolygonTest(float x, float y) : base(x, y) {
// Create a PolygonCollider and give it some Vector2 points.
polygonCollider = new PolygonCollider(
new Vector2(0, 0),
new Vector2(80, -10),
new Vector2(30, 90),
new Vector2(-5, 15),
new Vector2(0, 5)
);

// Add the Walls tag (since this isn't in the constructor.)
polygonCollider.AddTag(Tags.Walls);

// Set the rotation to a random angle.
polygonCollider.Rotation = Rand.Angle;

// Add the Collider.
AddCollider(polygonCollider);
// Center the origin of the Collider.
polygonCollider.CenterOrigin();
}

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

// Render the Collider for debug purposes.
polygonCollider.Render();
}
}
The full example places a bunch of colliders in a scene with a moving object to test collisions with.

Image


A lot more examples are on the way!

Status Report

Status Report
It seems like 2015 is really flying by and once again I'm trying to figure out what happened to it! Obviously I have kind of shifted my priorities again to maintain some sort of sanity and happiness. What started out as a year of working on the island game tentatively titled Stratoforce has turned into working on a bunch of smaller stuff. The stress of working on one big thing for a long time got to me so I took a break, and now that break is pretty extended.

Image


I'm still working on finishing Super Sky Sisters which is probably 98% done at this point. There's just a few more things to do, like figure out how I'm releasing it. I've gotten a lot of feedback from people that suggests I should put it on Steam or something, but that honestly sounds like more trouble than it's worth. My current plan is to release on itch.io for a small amount of dollars.

Image


Other than that I'm working on a prototype involving dice. I've posted some gifs and such of it from time to time. I haven't spent a super long time on it yet so there's no real game yet, but I've been trying to figure out how to make rolling digital dice feel cool and not like a chore.

I currently have a contract gig that is taking up some of my time. I'm doing some character art and level tile art for an upcoming indie game that for now I don't think I can say what it is, but it is pretty cool to work on!

On top of that I'm still trying to flesh out all the examples I can for Otter. I think pretty soon I'll be able to call it version 1.0 and figure out what I want to do with it after that. I have tinkered around with some other frameworks and engines, but I still always go back to Otter... I just wish it were easier to export to Mac and Linux.

I think that covers everything! I'm staying busy, still just living that indie life I suppose. Eventually I will have to buckle down and release a new proper game, but for now I still think I'm having fun and keeping my emotional health up which can be very important. Working on small projects that have no expectations is way more comfortable for me, but I know that eventually that won't be paying my bills.

Otter Example: Player Sessions

Otter Example: Player Sessions
Things have been pretty hectic for me for the past week so unfortunately all I've really had time to do is more Otter examples.

Image


A Session in Otter is a cool way to keep track of a player playing your game. You can set the controls in a session, and also keep track of other data such as high scores, levels unlocked, whatever else. Sessions also have an easy way to export data in a semi-encrypted format to prevent most players from tampering with it.

The full example is just a click away and you should totally check it out!

Otter Example: Basic Collision

Otter Example: Basic Collision
Fresh out of the oven is another example for Otter, the 2d game making framework based on SFML.net. The new example covers basic collision detection and response.

Image


On the examples page I've listed out all of the examples I want to cover in the next few weeks. I'm going to try to keep working on posting an example every few days or so, but I have some upcoming travel that might make that difficult. We'll see!

Oh and so many people are sending me this image so I might as well post it here:

Image

Otter Example: Spritemap Animations

Otter Example: Spritemap Animations
I want to keep the Otter example train rolling until I manage to flesh out enough examples to cover all the basics of making a game. The newest example covers animating sprites using a quick example sprite sheet from the Spriter's Resource.

The example with all of the code and required image is available right here.

Image


Also a reminder: if you're using Otter actively make sure to stop by the forums, or sign up for the relatively new Otter Slack Team. There's actually quite a bit of activity happening in the Slack, and recently one of the Otter community members posted a new GUI suite of components to use in your Otter made games!