diff --git a/GreatSpringGameJam/Content/Content.mgcb b/GreatSpringGameJam/Content/Content.mgcb index ae90384..d4a4b5b 100644 --- a/GreatSpringGameJam/Content/Content.mgcb +++ b/GreatSpringGameJam/Content/Content.mgcb @@ -55,3 +55,8 @@ /processor:TiledMapTilesetProcessor /build:Tilesets/World.tsx +#begin Textures/Backgrounds.png +/importer:TextureImporter +/processor:TextureProcessor +/build:Textures/Backgrounds.png + diff --git a/GreatSpringGameJam/Content/Maps/Level1.tmx b/GreatSpringGameJam/Content/Maps/Level1.tmx index b84632f..f9f7467 100644 --- a/GreatSpringGameJam/Content/Maps/Level1.tmx +++ b/GreatSpringGameJam/Content/Maps/Level1.tmx @@ -1,5 +1,9 @@ + + + + @@ -95,8 +99,8 @@ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,7,7,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,15,16,0,6,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,8,6,8,0,0,0,0,0,0,0,0,0,0,14,15,15,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,16,14,16,0,6,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,6,7,7,8,0,0,0,0,0,0,0,0,0,0,0,0,0,6,8,0,6,7,7,7,8,0,0,0,0,0,0,0,0,0,0,0,0,0, -7,8,6,7,8,0,6,7,8,0,0,0,0,0,0,0,0,0,0,0,0,0,14,16,0,0,0,0,0,6,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,15,15,16,0,0,0,0,0,0,0,0,0,0,0,0,0,14,16,0,14,15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,0,0,0,0,0, diff --git a/GreatSpringGameJam/Content/Textures/Backgrounds.aseprite b/GreatSpringGameJam/Content/Textures/Backgrounds.aseprite new file mode 100644 index 0000000..96e97eb Binary files /dev/null and b/GreatSpringGameJam/Content/Textures/Backgrounds.aseprite differ diff --git a/GreatSpringGameJam/Content/Textures/Backgrounds.png b/GreatSpringGameJam/Content/Textures/Backgrounds.png new file mode 100644 index 0000000..0ff2821 Binary files /dev/null and b/GreatSpringGameJam/Content/Textures/Backgrounds.png differ diff --git a/GreatSpringGameJam/GameImpl.cs b/GreatSpringGameJam/GameImpl.cs index 876363d..47469e1 100644 --- a/GreatSpringGameJam/GameImpl.cs +++ b/GreatSpringGameJam/GameImpl.cs @@ -35,11 +35,10 @@ namespace GreatSpringGameJam { this.Camera = new Camera(this.GraphicsDevice) { AutoScaleWithScreen = true, - Scale = 4, - Position = new Vector2(0, float.MaxValue) + Scale = 4 }; this.Map = new Map("Level1"); - this.Player = new Player(this.Map, new Vector2(70, 20)); + this.Player = new Player(this.Map, this.Map.SpawnPoint.ToVector2()); this.Map.AddEntity(this.Player); } @@ -88,7 +87,7 @@ namespace GreatSpringGameJam { while (completionCounter < completion * 100) { completionCounter++; score.Text = string.Format(scoreText, completionCounter); - yield return new Wait(0.05F); + yield return new Wait(0.03F); } } diff --git a/GreatSpringGameJam/GreatSpringGameJam.csproj b/GreatSpringGameJam/GreatSpringGameJam.csproj index 9cf0eaf..222bb3a 100644 --- a/GreatSpringGameJam/GreatSpringGameJam.csproj +++ b/GreatSpringGameJam/GreatSpringGameJam.csproj @@ -9,9 +9,9 @@ - - - + + + @@ -31,7 +31,6 @@ - \ No newline at end of file diff --git a/GreatSpringGameJam/Map.cs b/GreatSpringGameJam/Map.cs index ca15107..d65bd9b 100644 --- a/GreatSpringGameJam/Map.cs +++ b/GreatSpringGameJam/Map.cs @@ -4,14 +4,19 @@ using Microsoft.Xna.Framework.Graphics; using MLEM.Cameras; using MLEM.Extended.Extensions; using MLEM.Extended.Tiled; +using MLEM.Extensions; using MLEM.Misc; using MLEM.Startup; +using MLEM.Textures; +using MonoGame.Extended; using MonoGame.Extended.Tiled; namespace GreatSpringGameJam { public class Map { + private static readonly UniformTextureAtlas BackgroundTexture = new(MlemGame.LoadContent("Textures/Backgrounds"), 8, 8); public Point SizeInPixels => new(this.map.WidthInPixels, this.map.HeightInPixels); + public Point SpawnPoint => new(this.map.Properties.GetInt("StartX"), this.map.Properties.GetInt("StartY")); public Vector2 TileSize => this.map.GetTileSize(); public readonly TiledMapCollisions Collisions; public readonly int TotalSnow; @@ -60,6 +65,16 @@ namespace GreatSpringGameJam { public void Draw(GameTime time, SpriteBatch batch, Camera camera) { batch.Begin(SpriteSortMode.Deferred, null, SamplerState.PointClamp, transformMatrix: camera.ViewMatrix); + // render background + const float parallaxFactor = 0.5F; + var parallax = camera.Position * parallaxFactor; + var (parW, parH) = this.SizeInPixels.ToVector2() * (1 - parallaxFactor) + camera.ScaledViewport * parallaxFactor; + var mountains = BackgroundTexture[0, 0, 8, 4]; + for (var x = 0; x < parW; x += mountains.Width * 2) { + batch.Draw(mountains, parallax + new Vector2(x, parH - mountains.Height * 2), Color.White * 0.5F, 0, Vector2.Zero, 2, SpriteEffects.None, 0); + } + + // render map etc. this.DrawLayer(batch, "Ground", camera); foreach (var entity in this.entities) entity.Draw(time, batch); diff --git a/GreatSpringGameJam/Player.cs b/GreatSpringGameJam/Player.cs index 4221a6f..1e8e977 100644 --- a/GreatSpringGameJam/Player.cs +++ b/GreatSpringGameJam/Player.cs @@ -34,6 +34,7 @@ namespace GreatSpringGameJam { this.animations = new SpriteAnimationGroup(); this.animations.Add(new SpriteAnimation(0.15F, PlayerTexture[1], PlayerTexture[2], PlayerTexture[3], PlayerTexture[0]), () => this.walking); this.animations.Add(new SpriteAnimation(1, PlayerTexture[0]), () => !this.walking); + this.facingRight = true; } public override void Update(GameTime time) {