I moved to a new URL! Check it out!

posts tagged with: gamedev

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.

Dev Log: Code Sample

Dev Log: Code Sample
I'm slowly getting back into the groove of programming again after a long hiatus. In case you're just tuning in, I'm working on a C# SFML framework for 2d games. Right now I'm calling the framework Otter, and eventually when I get it to a more presentable state I'll be open sourcing it on BitBucket somewhere so other people can use it, and contribute to it.

For now here's a small teaser of how some code looks when using the framework. This is for the entity that the player controls with mouse and keyboard or a PC game controller. It flies around in a top down view in the scene. It's a big chunk of code, so I'm putting it behind the "read more" link!

Local Game Dev Community Tips

Local Game Dev Community Tips
This past week IGDA Phoenix held another one of its monthly meetings. We had about 60 something people turn up for the meeting to check out a presentation from one of our local game developers, which is pretty awesome. I'm the co-chair of IGDA Phoenix along with Corey, so we are responsible for putting together each of these meetings.

Our meeting turn out is pretty impressive, especially when new people show up and they tell me that they had no idea that Phoenix even had a game development scene. We're one of the few IGDA chapters (from what I hear) that has consistent monthly meetings, and I believe that we've only actually missed 3 monthly meetings in the past 3 or 4 years that we've been running it.

Since we've been running this thing for a couple years now and it feels pretty successful, I thought it would be neato to share some tips that I think are important to maintaining an active community of any kind!

I'm in a Movie

I'm in a Movie


The Special Edition of Indie Game The Movie just came out, and it includes a bunch of extra stuff not in the original release. One of those special things in the special edition is a piece put together about game jams. It was shot at TIGJam in 2010, and I managed to sneak my way into the footage.

Image

They even used me as the thumbnail for the segment, yay! I unfortunately don't have the capacity to listen to or watch myself on screen, so I have no idea what I say or do in the segment, but I hear it's not terrible.

You should definitely check out Indie Game The Movie if you haven't seen it yet. It's one of the best looks into the wild world of independent game development in my opinion.

Dev Log: Game Loops

Dev Log: Game Loops
I pretty much spent the whole day learning that certain video cards, or hardware configurations, seem to really hate rendering large textures.

Image


I've been messing around with some early versions of the background for my new game. I'm composing it from a number of images -- there's the ground, a couple of gradients for water and haze, and a couple of cloud layers. All of my desktop machines seem to have no issue running this (the render time is 1 to 2 ms) but my laptop seems to get very upset about this with a render time of nearly 15ms.

I also discovered that using the SetFramerateLimit() function in SFML is bad news, at least in C# land. I sent my current build to a friend who ran it on his Macbook (running parallels to boot into Windows) and it ran at about 30 frames per second (short of the desired 60.) His Macbook has no problem playing any other Windows games, so this was a bit odd. After messing around in the game for about 5 minutes the framerate jumped to 60 for no reason that we could see. Super weird.

After these weird results I went back to my code and ripped out the SetFramerateLimit() in favor for my own timing code that would limit the framerate. Not only does this seem to just work better than SetFramerateLimit(), but it also fixed the framerate on my friend's Macbook.

Image


Eventually I will be releasing the full source of my framework for people to laugh at, or possibly use and contribute to. I haven't yet reached the point where I think I can do that comfortably, but I would imagine that sometime this month I'll be ready to show it off. It's very similar to Flashpunk, and is basically a big mash up of a lot of the engines and frameworks I've seen or used. In the mean time, you can also check out #Punk by Jacob Albano which is more of a faithful port of Flashpunk to C# using SFML as the core.