https://github.com/lioncat2002/seasonsplatformer
A simple platformer using monogame
https://github.com/lioncat2002/seasonsplatformer
monogame monogame-community monogame-extended monogame-framework tiledmap
Last synced: about 1 month ago
JSON representation
A simple platformer using monogame
- Host: GitHub
- URL: https://github.com/lioncat2002/seasonsplatformer
- Owner: Lioncat2002
- License: mit
- Created: 2021-04-24T15:51:48.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-04-27T12:20:08.000Z (about 4 years ago)
- Last Synced: 2025-02-09T20:16:10.560Z (3 months ago)
- Topics: monogame, monogame-community, monogame-extended, monogame-framework, tiledmap
- Language: C#
- Homepage:
- Size: 4.3 MB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# A monogame platformer using Monogame Extended and TiledSharp
I just made this code public coz I was just too lazy to make a video.
Also I am getting busier by day so maybe there won't be any video for a while.
The code is messy coz I wrote it in a hurry
The main part is the collision check in the update method which enables the platform movement
```cs
var initpos = player.pos;
var Ypos = player.pos.Y;
player.Update(gameTime);
foreach (var rect in collisionObjects)
{
if (rect.Intersects(new Rectangle(player.playerBounds.X+2,player.playerBounds.Y-1,4,4)))//This one checks for x axis collision
{
player.pos.X = initpos.X;
player.isIdle = true;
player.isFalling = false;
}
if(rect.Contains(new Point(player.playerBounds.X+4,player.playerBounds.Y+9)))//The y axis collision
{
player.isFalling = false;
player.pos.Y = initpos.Y;
}
else
{
player.isFalling = true;
}
}
```
You can code out the jump part very easily after this ;)## A video showing the platformer at work by Oyyou
https://www.youtube.com/watch?v=8fr2Z086p5U