I moved to a new URL! Check it out!

posts dated from: august 2013

Dev Log: Collisions!

Dev Log: Collisions!
I'm back working on my C# and SFML framework after many weeks of very very slow progress. I've been tackling all the different kinds of collision detection that I want to have, and although the rectangle to rectangle collisions are easy, stuff like rectangle to grid started to get a little messy.

So then I got to the point where I wanted to add line segments and circles into the mix, and even with just these four types I found myself in a maze of code and math.

After trying to figure out some math on my own, I finally stumbled upon some line segment intersection code that helped out quite a bit. After I got that running, I was also able to find a line segment to circle collision example, and that gave me enough to fill in the rest of the blanks.

So now I have four collider types: Rectangles, Grids, Circles, and Lines, and they are all able to collide with each other. I haven't super thoroughly tested this stuff out yet though, so I'm sure some of it must be broken somewhere, but for the rest of the week I'll be testing this stuff out a little more.

Triforce Geek Interview

Triforce Geek Interview
Another quick post! You should check out this interview I did with Triforce Geek. It was a lot of fun, and I was also very sick during the interview but I did my best to not throw up or cough for the duration of it. We covered stuff like game jams, my experience working on Offspring Fling and Snapshot, and some other indie game dev related stuff.

They translated the whole thing into Spanish which is pretty neat. I like to imagine myself being able to speak fluent Spanish in the interview as I try to read through the translation. The audio on soundcloud is still in English though just in case you can't read Spanish.

Some Podcasts

Some Podcasts
Just a quick post to say that my housemates and I successfully recorded a new podcast last week! It's been about... 6 months since the last one, oops.

In related news, a new episode of This Week in Zublax was recorded. This Week in Zublax is a podcast featuring a bunch of Phoenix game developers talking about game design in depth, or at least that's what we try to do. It's more purely about game design and not just general indie game dev stuff.

Doodle Post

Image


Image

Dev Log: Code Snippets

Dev Log: Code Snippets
Yesterday I posted about my amazing tile collisions, so I thought I'd post a quick code example on some of the things involved with setting it up. This isn't any of the code from the actual collision detection, but it's code that most users would see if they ever use this framework.

This is the code for the moving white box:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Otter;

namespace HelloSFML {
class BoxDude : Entity {

BasicMovement movement = new BasicMovement(500, 500, 50);
Image img;
BoxCollider hitbox;
Axis axis = new Axis();

uint size = 50;

public BoxDude() {
refreshSize();

AddComponent(movement);
AddComponent(axis);

movement.CollidesWith.Add(1);

axis.AddKeys(Key.W, Key.D, Key.S, Key.A);

movement.Axis = axis;
}

void refreshSize() {
RemoveCollider(hitbox);
RemoveGraphic(img);
img = Image.CreateRectangle(size);
hitbox = new BoxCollider(size, size, 0);
AddCollider(hitbox);
SetGraphic(img);
movement.Collider = hitbox;
}

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

img.Color = Color.White;
if (Collide(X, Y, 1) != null) {
img.Color = Color.Red;
}

if (Input.Instance.KeyPressed(Key.Period)) {
size -= 10;
refreshSize();
}
if (Input.Instance.KeyPressed(Key.Comma)) {
size += 10;
refreshSize();
}
}
}
}

Dev Log: Tile Collisions!

Image


Finally after weeks of putting off the task I got around to implementing the tile based collision system in my C# SFML framework. Right there in that animation above is a simple movement that is actively colliding with the tiles, stopping the movement. I can scale up and down the hit box and sometimes it does get caught on an overlap as a result which is why it turns red.

I used a couple of references to get this working including Flashpunk's own tile collision which can be found in the source code, and I also took a peek at C# Punk to see how it was implemented there as well. My solution is similar, and maybe worse, but for now it works and that's all that matters.

With the tile based collision in, I have all the power in the world to make a platformer if I wanted... well, as long as it didn't have any slopes.