Skip to content

Commit bac8e9f

Browse files
Chapter 6 changes
1 parent 31c7a84 commit bac8e9f

File tree

6 files changed

+189
-146
lines changed

6 files changed

+189
-146
lines changed

articles/tutorials/advanced/2d_shaders/06_color_swap_effect/index.md

Lines changed: 166 additions & 121 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
private Texture2D _colorMap;

articles/tutorials/advanced/2d_shaders/06_color_swap_effect/snippets/snippet-6-09-2.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ public override void LoadContent()
66
_colorSwapMaterial = Core.SharedContent.WatchMaterial("effects/colorSwapEffect");
77
_colorSwapMaterial.IsDebugVisible = true;
88

9-
var colorMap = Content.Load<Texture2D>("images/color-map-1");
10-
_colorSwapMaterial.SetParameter("ColorMap", colorMap);
9+
_colorMap = Core.SharedContent.Load<Texture2D>("images/color-map-1");
10+
_colorSwapMaterial.SetParameter("ColorMap", _colorMap);
1111
}
Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
public override void Draw(GameTime gameTime)
2-
{
3-
// ...
4-
5-
Core.SpriteBatch.Begin(
6-
samplerState: SamplerState.PointClamp,
7-
sortMode: SpriteSortMode.Immediate,
8-
effect: _colorSwapMaterial.Effect);
9-
10-
// ...
11-
}
1+
Core.SpriteBatch.Begin(
2+
samplerState: SamplerState.PointClamp,
3+
sortMode: SpriteSortMode.Immediate,
4+
effect: _colorSwapMaterial.Effect);

articles/tutorials/advanced/2d_shaders/06_color_swap_effect/snippets/snippet-6-17.cs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,20 @@
11
public override void Draw(GameTime gameTime)
22
{
3-
// Clear the back buffer.
4-
Core.GraphicsDevice.Clear(Color.CornflowerBlue);
5-
6-
Core.SpriteBatch.Begin(
7-
samplerState: SamplerState.PointClamp,
8-
sortMode: SpriteSortMode.Immediate,
9-
effect: _colorSwapMaterial.Effect);
3+
// ...
104

115
// Update the colorMap
126
_colorSwapMaterial.SetParameter("ColorMap", _colorMap);
13-
7+
148
// Draw the tilemap
159
_tilemap.Draw(Core.SpriteBatch);
16-
10+
1711
// Draw the bat.
1812
_bat.Draw();
1913

2014
// Update the colorMap for the slime
21-
_colorSwapMaterial.SetParameter("ColorMap", _slimeColorMap.ColorMap);
22-
23-
// Draw the slime.
15+
_colorSwapMaterial.SetParameter("ColorMap", _slimeColorMap.ColorMap);
16+
17+
// Draw the slime.
2418
_slime.Draw();
2519

2620
// Always end the sprite batch when finished.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
public override void Update(GameTime gameTime)
2+
{
3+
// ...
4+
5+
// Update the bat;
6+
_bat.Update(gameTime);
7+
8+
// Perform collision checks
9+
CollisionChecks(gameTime);
10+
}

0 commit comments

Comments
 (0)