I moved to a new URL! Check it out!

posts tagged with: otter

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.

Taking a Quick Break

Taking a Quick Break
Whoops! I think this is the longest I've ever let my blog go without an update in a long time. I've been traveling a lot this month and haven't really had a whole lot of time to sit down and do a lot of cool game dev work to talk about.

I was at EVO just two weekends ago, and this last weekend I spent visiting my old college roommates, and some high school friends that I haven't seen in a billion years. Yesterday I was in New York City, and now for the rest of the week I'm in Upstate NY where apparently it's totally okay to convert the shoulder into a driving lane whenever you want. On Saturday I'll finally be back in Phoenix!

I have been working on a little side thing experimenting with near-infinite level generation. It's a little game in Otter right now with just boxes and the game scene is filled in as the player travels through it. Areas of the level also unload when the player gets too far. I wanted to try to make something in which the player can go out in any direction and keep finding stuff, and not have it be bound by any walls or anything like that. I started it on the flight out to the east coast, and worked on it a little bit in a coffee shop in NYC more, but right now it's just a bunch of squares that aren't that exciting.

Image


I think for my developer/mental health I should start working on tiny experiments like this more. It's something that I used to do often, but now I feel like I don't want to take time away from my main project, but that usually ends up being a bad attitude... more thoughts on that later!

Should have more time this week to work on some stuff though before I go back to the west. Sorry about dropping off the face of the internet for awhile!

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.

Otter Updates 0.9.6

Otter Updates 0.9.6
Otter is slowly approaching the big 1.0.0 moment, and I've been tinkering with it little by little trying to fix bugs that pop up. I've also been using the dev branch so you can see my updates as I make them. Otherwise the default branch is supposed to be the "stable" one, and every once in awhile I merge the dev branch in with the default one.

Here's some of the recent changes and fixes!

* Text now has CenterTextOrigin() in an attempt to find the center of the actual text, and not the full bounding box.

* RichText also now has CenterTextOrigin()

* Fixed Text bug that would cause text to jitter when the height of the tallest character was changed.

* Fixed the same issue in RichText.

* Tilemaps have had some improvements in their performance for looking up tiles.

* Tilemaps can now use Enums for their layers.

* Fixed bugs with accessing tiles out of range in a Tilemap. Tiles are now automatically clamped inside of the limits of the Tilemap.

* Tilemap GetTiles() will return a list of TileInfo objects for every tile on a specific layer.

* GridCollider now has a Clear() function

* GridColliders can now load collision data from a Tilemap, using a specific layer on the Tilemap.

* Fixed a bug with not updating Graphics when their alpha was changed.

* Game's "SmoothAll" value should now actually affect Textures. Considering changing this to a static value on Texture.

* Fixed crash bug with Surface's SaveToFile() function.

* Updated the Glide Tween Library to the latest revision.

* Updated the documentation.

That's all for now. If you have any issues you can post on the forums and that'll be the easiest way to get help. Hope everyone out there is having fun with the engine!

Dev Log: Shader Follow Up

Dev Log: Shader Follow Up
My last post went over some of my recent shader developments with displacement maps, and using gradient maps to recolor portions of the screen. I had a couple of questions of what exactly was going on behind the scenes with the render textures that I was using to tell the shader how to actually manipulate the image, so I thought I would address that now!

Here's an example image from the game with a lot of explosions going on:

Image


Each explosion has a shockwave ripple coming out of it which distorts the area around it. The explosion also changes the color of the screen around to a gradient map with pink and yellow. This makes it look like an intense heat, or something.

For reference, here's the shader again (it's been slightly modified since yesterday.)
uniform sampler2D texture;
uniform sampler2D displacementMap;
uniform sampler2D paletteMap;
uniform sampler2D gradientMap;

void main() {
// Get the pixels off of the maps.
vec4 displacementPixel = texture2D(displacementMap, gl_TexCoord[0]);
vec4 palettePixel = texture2D(paletteMap, gl_TexCoord[0]);

// Read the pixel from the displaced position.
vec2 pos = gl_TexCoord[0];
pos.x += (displacementPixel.r * 2.0 - 1.0) * 0.025;
pos.y -= (displacementPixel.g * 2.0 - 1.0) * 0.025;

// Get the displaced pixel.
vec4 pixel = texture2D(texture, pos);

// Proper grayscale conversion.
float gray = dot(pixel.rgb, vec3(0.299, 0.587, 0.114));

// Get the color from the gradient.
float gradientPos = mod(gray + palettePixel.g, 1);

// Get the actual color from the gradient.
vec4 gradientMapPixel = texture2D(gradientMap, new vec2(gradientPos, palettePixel.r));

// Mix the gradient with the pixel color based on the palette pixel.
pixel = mix(pixel, gradientMapPixel, palettePixel.a);

// Apply the final color multiplied by the gl color.
gl_FragColor = pixel * gl_Color;
}
From this point on there's going to be a lot of images and some hefty animated gifs, so I'll hide the rest of this post behind the read more button!