diff options
| author | BoredGuy <osome3717@gmail.com> | 2026-01-13 11:01:46 +0300 |
|---|---|---|
| committer | BoredGuy <osome3717@gmail.com> | 2026-01-13 11:01:46 +0300 |
| commit | 3149303926e7c56fb9508f0b60d26fe8c675d6aa (patch) | |
| tree | 07d85ccd86b401947c7670db9388b78cc0a4fd25 | |
| parent | 37328f9325aa5175239c513a6a4363400a0dada4 (diff) | |
Learned Texture Rendering
| -rw-r--r-- | DungeonSlime/Content/Content.mgcb | 6 | ||||
| -rwxr-xr-x | DungeonSlime/Content/Music.fx | 35 | ||||
| -rw-r--r-- | DungeonSlime/Game1.cs | 55 |
3 files changed, 92 insertions, 4 deletions
diff --git a/DungeonSlime/Content/Content.mgcb b/DungeonSlime/Content/Content.mgcb index 08a7c33..0c3469d 100644 --- a/DungeonSlime/Content/Content.mgcb +++ b/DungeonSlime/Content/Content.mgcb @@ -13,6 +13,12 @@ #---------------------------------- Content ---------------------------------# +#begin ../../../../Music/output/learning.wav +/importer:WavImporter +/processor:SongProcessor +/processorParam:Quality=Best +/build:../../../../Music/output/learning.wav;Music/learning.wav + #begin Images/logo.png /importer:TextureImporter /processor:TextureProcessor diff --git a/DungeonSlime/Content/Music.fx b/DungeonSlime/Content/Music.fx new file mode 100755 index 0000000..2eb340a --- /dev/null +++ b/DungeonSlime/Content/Music.fx @@ -0,0 +1,35 @@ +#if OPENGL + #define SV_POSITION POSITION + #define VS_SHADERMODEL vs_3_0 + #define PS_SHADERMODEL ps_3_0 +#else + #define VS_SHADERMODEL vs_4_0_level_9_1 + #define PS_SHADERMODEL ps_4_0_level_9_1 +#endif + +Texture2D SpriteTexture; + +sampler2D SpriteTextureSampler = sampler_state +{ + Texture = <SpriteTexture>; +}; + +struct VertexShaderOutput +{ + float4 Position : SV_POSITION; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +float4 MainPS(VertexShaderOutput input) : COLOR +{ + return tex2D(SpriteTextureSampler,input.TextureCoordinates) * input.Color; +} + +technique SpriteDrawing +{ + pass P0 + { + PixelShader = compile PS_SHADERMODEL MainPS(); + } +};
\ No newline at end of file diff --git a/DungeonSlime/Game1.cs b/DungeonSlime/Game1.cs index 1594151..879b96a 100644 --- a/DungeonSlime/Game1.cs +++ b/DungeonSlime/Game1.cs @@ -1,12 +1,15 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; + using MonoGameLibrary; namespace DungeonSlime; public class Game1 : Core { + private Texture2D _logo; + public Game1(): base("Dungeon Slime", 1280, 720, false) { @@ -14,14 +17,12 @@ public class Game1 : Core protected override void Initialize() { - // TODO: Add your initialization logic here - base.Initialize(); } protected override void LoadContent() { - // TODO: use this.Content to load your game content here + _logo = Content.Load<Texture2D>("Images/logo"); } protected override void Update(GameTime gameTime) @@ -38,7 +39,53 @@ public class Game1 : Core { GraphicsDevice.Clear(Color.CornflowerBlue); - // TODO: Add your drawing code here + Rectangle iconSourceRect = new Rectangle(0, 0,128, 128); + Rectangle wordmarkSourceRect = new Rectangle(150, 34, 458, 58); + + SpriteBatch.Begin( + sortMode: SpriteSortMode.BackToFront, + samplerState: SamplerState.LinearWrap + ); + + //Draw only icon portion + SpriteBatch.Draw( + _logo, + new Vector2( + Window.ClientBounds.Width, + Window.ClientBounds.Height + ) * 0.5f, + iconSourceRect, + Color.White, + 0.0f, + new Vector2( + iconSourceRect.Width, + iconSourceRect.Height + ) * 0.5f, + 1.0f, + SpriteEffects.None, + 1.0f + ); + + //Draw only rectangle portion + SpriteBatch.Draw( + _logo, + new Vector2( + Window.ClientBounds.Width, + Window.ClientBounds.Height + ) * 0.5f, + wordmarkSourceRect, + Color.White, + 0.0f, + new Vector2( + wordmarkSourceRect.Width, + wordmarkSourceRect.Height + ) * 0.5f, + 1.0f, + SpriteEffects.None, + 0.0f + ); + + SpriteBatch.End(); base.Draw(gameTime); } |
