This is a game that was made for a school assignment in 2015. It was a group project consisting of 2 people. I was in charge of basic programming like movement, collision, the battle system, etc. I also made some of the art.
We chose to create this in C# using the MonoGame framework.
Gameplay
When you begin the game you get greeted by Professor Koak. After chatting for a bit you get to choose your first monster.
After getting your own monster you’re free to roam the world and fight to your hearts content.
You can also be challenged by trainers who spot you.
When all your monsters happen to faint, you get teleported back to the healing centre.
Once the player has progressed through enough new areas, a champion trainer will challenge the player for a final fight.
If the player manages to beat this champion trainer, the game is won.
Code
We had some trouble getting the collision the way we wanted it. Eventually we found a solution which checks for blocks around the player to see if the player can move there. This solution is what we eventually went with.
Collision Code
public void GetCollision(Character player) {
CollisionColliders.Clear();
var collisionLayers = Map.TileLayers.Where(layer => layer.Properties.ContainsKey("Collision") && layer.Properties.ContainsValue("true")).ToList();
foreach (var layer in collisionLayers) {
foreach (var tile in layer.Tiles) {
if (tile.Id != 0) {
collisionHitbox = new Rectangle((tile.X * tileWidth), (tile.Y * tileHeight), tileWidth, tileHeight);
CollisionColliders.Add(collisionHitbox);
}
}
}
var boxLayer = Map.TileLayers.Where(layer => layer.Properties.ContainsKey("Box") && layer.Properties.ContainsValue("true")).ToList();
foreach (var tile in boxLayer.SelectMany(layer => layer.Tiles.Where(x => x.Id != 0))) {
collisionHitbox = new Rectangle((tile.X * tileWidth), (tile.Y * tileHeight), tileWidth, tileHeight);
CollisionColliders.Add(collisionHitbox);
}
if (CollisionColliders.Count != 0) {
foreach (var collision in CollisionColliders) {
if (player.Hitbox.Intersects(collision)) {
var moduloX = player.Position.X % 32;
var moduloY = player.Position.Y % 32;
var vector = new Vector2(collision.X, collision.Y);
//If right of it
if (vector.X >= player.Position.X) {
if (player.RightCollide(collision)) {
if (moduloX >= 16) moduloX -= 32;
player.Position.X -= moduloX;
}
}
//if left of it
if (vector.X <= player.Position.X) {
if (player.LeftCollide(collision)) {
if (moduloX >= 16) moduloX -= 32;
player.Position.X -= moduloX;
}
}
//if above it
if (player.UpperCollide(collision))
if (vector.Y >= player.Position.Y - 32) {
if (moduloY >= 16) moduloY -= 32;
player.Position.Y -= moduloY;
}
//}
//if below it
if (player.LowerCollide(collision))
if (vector.Y <= player.Position.Y + 32) {
if (moduloY >= 16) moduloY -= 32;
player.Position.Y -= moduloY;
}
}
}
}
}