I moved to a new URL! Check it out!

posts dated from: december 2016

Doodle Post

Image

Dev Log: SortedDictionaryList

Dev Log: SortedDictionaryList
As I transfer all of my framework making knowledge over to the land of FNA I've been trying to clean up a few things that turned out pretty dang messy in the original Otter.

In the Scene class of Otter it keeps track of Entities, and Entities have an Order and Layer. Multiple entities can be in the same layer, and can be in the same order as well. Order is the order in which they update every tick, and layer is the order in which they render. So what I usually do is have a sorted dictionary of lists. The dictionary sorts on an integer value that matches the value of the order or the layer, and the value is the list of entities that belong to that order or layer.

Old Otter has kind of a big mess of copied and pasted code for this system, so for new Otter I tried to make a cleaner version of it.
class SortedDictionaryList<TKey, TValue> : SortedDictionary<TKey, List<TValue>> {
public SortedDictionaryList(IComparer<TKey> comparer) : base(comparer) { }
public SortedDictionaryList() { }
public bool HasItem(TKey key, TValue item) {
if (!ContainsKey(key))
return false;
else
return this[key].Contains(item);
}
public TKey FindKey(TValue item) {
foreach(var key in Keys)
if (this[key].Contains(item)) return key;
return default(TKey);
}
public void AddItem(TKey key, TValue item) {
if (!ContainsKey(key))
Add(key, new List<TValue>());
this[key].Add(item);
}
public void RemoveItem(TKey key, TValue item) {
this[key].Remove(item);
}
}

Another thing I'm looking to implement is a generic version of a "buffered" list of items somehow. A lot of times in Otter I don't want to add or remove items in a list in the middle of the update, so I end up buffering adds and removes until I get to the end of the frame and then all of them execute. I end up doing this in both Scenes for Entities, and in Entities for Components, so I'm rewriting a lot of the same code in both spots, but I'm still questioning if its worth it to try a generic solution for this or if it's fine the way it is.

Anyway I'm still on "break" for another couple of days. At this point I'm looking forward to my vacation being over!

Doodle Post

Image


I wanna be back on my desktop aaugh

Dev Log: FNA Tiles

Dev Log: FNA Tiles
Been working a little bit on getting tile maps set up in the FNA version of Otter along with a quick platforming movement test.

Image


I'm still wrestling with some issues in FNA that I'm sure are totally my fault, but so far things have been working pretty nicely. Understanding the whole sprite batch drawing thing is still a little bit tricky for me, and I'm hoping that I can wrangle my familiar engine api into something that doesnt perform like garbage. Trying to manage when I should be calling End() and Begin() is a little bit more challenging than I hoped, and I don't want to just be calling them both for every single draw if I can help it.

I've hit a weird snag with my initialization process and render targets, and I think it's related to some kinda weird race condition that I can't pin down... but probably more on this in a future post.

Doodle Post

Image


Trying my best to draw on my laptop but gotta have my tablet on my lap and it ain't pretty.

Dev Log: FNA Font Stuff

Dev Log: FNA Font Stuff
I'm currently in the midst of an actual break from development but I'll try to catch up on some recent developments while I'm loungin' about.

I'm still developing my new version of Otter using FNA instead of SFML. I'm slowly but hopefully surely finding out the best way to go about certain things like rendering and input. Fonts and text graphics are working pretty well now and I also have some basic input stuff hooked up for things like keyboard, mouse, and text entry.

Image


I'm using a C# binding of freetype for rendering fonts and text, and recently I implemented a system to handle huge font sizes. I say system but all it's really just a list of textures for the font instead of just one texture. Unfortunately the upper limit of font sizes is still the maximum size of the texture though... so right now 2048 I think.

I've almost got enough in my FNA engine to make a simple game aside from a few missing collision overlap checks and a handful of bugs. As much as I hate to say it I think I actually like SFML's rendering system better because so far using SpriteBatch feels like a giant pain in the butt most of the time. I understand why SpriteBatch is so important, but it seems like it'd be easier just to pass my own vertices and textures into the renderer... but for some reason that's mega slow. Right now one of the bugs I have to look into is the fact that rendering 10 or so primitives already starts to take a toll on performance, and it's only rendering a bunch of untextured vertices! Nothin' makes sense.