King in the Castle
King in the Castle King in the Castle
The Video
The Idea
Imagine Super Smash Bros., but more straightforward. It's a game where you can jump in, challenge a friend, and enjoy a fun five minutes together. There's just one character, so the matchups are fair and entirely based on skill. Since this was my first game made with a custom engine, I limited myself to something I was confident I could achieve. I'm pretty happy with the end result because the core loop is bug free and it's actually quite fun for 5 - 10 minutes. Download Link
The Code
So, for my first game, I created a basic 'Super Smash Bros.-style' game. The code here isn't anything special, except for a simple AABB collider that handles collisions for my players with the world and with each other. The only library I used was SFML for loading audio and textures.
The code for the collider basically comes down to this:
private void CollisionResolve(Player player)
{
//Bottom Collision
if (playerBottom <= intersectionRect.Top)
{
player.isGrounded = true;
player.playerSprite.Position += new Vector2f(0f, -player.playerInput.Y);
}
// Top Collision
if (playerTop >= intersectionBottom)
{
player.playerSprite.Position += new Vector2f(0f,intersectionRect.Height);
player.playerInput.Y = 0f;
return;
}
//Right Collision
if (rightBoundry > 0 && playerBottom > intersectionRect.Top)
{
player.playerSprite.Position += new Vector2f(intersectionRect.Width, 0f);
}
//Left Collision
if (rightBoundry < 0 && playerBottom > intersectionRect.Top)
{
player.playerSprite.Position += new Vector2f(-intersectionRect.Width, 0f);
}
}