Windows 8 Game Development using C#, XNA and MonoGame 3.0: Building a Shooter Game Walkthrough – Part 6: Creating Enemies and Detecting Collisions



Last time we met in Part 5 of this blog series, we created an animation to bring the ship to life by simulation of movement and propulsion. We also created and added a more realistic background to the game by the creation of a parallaxing background by layering three distinct images and moving them in and/or of the game screen's view by simulate the sky with clouds moving as the ship flies through the background. In the comments of Part 5, we got some great feedback on the variations of how people handled the Parallaxing background screen refresh on various machines and would not have a smooth jitter. One such comment and example was well throughout and I want to share it with you all so that you can update your game accordingly if desired. Tim Eicher ( teicher) updated the Shooter parallaxing background by creating a function WrapTextureToLeft and WrapTextureToRight (shown below) and changing the position and scale variables (see full code at Thanks Tim for sharing this Excellent code update with us all!

  1. private void WrapTextureToLeft(int index)
  2. {
  3. // If the textures are scrolling to the left, when the tile wraps, it should be put at the
  4. // one pixel to the right of the tile before it.
  5. int prevTexture = index - 1;
  6. if (prevTexture < 0)
  7. prevTexture = _positions.Length - 1;
  9. _positions[index].X = _positions[prevTexture].X + _texture.Width;
  10. }
  12. private void WrapTextureToRight(int index)
  13. {
  14. // If the textures are scrolling to the right, when the tile wraps, it should be
  15. //placed to the left of the tile that comes after it.
  17. int nextTexture = index + 1;
  18. if (nextTexture == _positions.Length)
  19. nextTexture = 0;
  21. _positions[index].X = _positions[nextTexture].X - _texture.Width;
  22. }


Now on with the tutorial. Let's just into how to create enemies for the game and animate the enemy graphic.

See the Complete Post Here


Comments (13)
  1. sanya says:

    hey,can u give me a rough idea as to when will u be able to post the complete tutorial?how much time will it take to finish the game tutorial?

  2. T E W says:

    Wow!! Sanya: I just posted this one days ago, got to do the day job in building reference apps and conducting technical workshops.  At least let a week pass first, please 🙂

    Working on!

  3. Mario says:

    Hey Tara,

    Looks like your WP blog is kinda messed up right now, any of your blog entries there go to a page that simply says, "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."  I'm starting to work through creating stuff myself for Menus, and such, but would love to see this tutorial, as it covers the collision detection, which is pretty much the core of the game here. lol

  4. T E W says:

    Mario: Try it now, I just tested everything out and it should be fine.  

  5. Mario says:

    Yep, looks like everything is working.  I've already pushed beyond what is currently in the tutorials, adding the firing, explosions, music, sound effects and Main Menu / Game Over menu (Decided to use the same for both), as well as re-working the Input handling a bit into it's own Class.  All I have left now, is to add the HUD to display Health and Score, as well as tracking the score. lol

    Thanks for these tutorials, they're very helpful.  Still will read the rest, just to see what we do differently.

  6. DDD says:

    What about XNA 5 though, did you guys fire the incompetent manager who tried to kill it?

  7. Synkhan says:

    Love the series, wondering if and when you might post part 7 up, its been a great help in terms of getting to know how things work, would love to see it through to the end.

  8. Harry says:

    This has been immensely helpful! Where's part 7? Unfortunate it seems to have ended here.

  9. Derek says:

    Hi. I know this is not related, and being in Australia, your OHours meeting slots are around 4am here, I thought I'd try ask on your blog instead.

    Is there a way to get the available disk space in WinJS?  Similar to what's in  System.IO.DriveInfo?   I'd like to check before installing and launching my WinJS app.  My Google-fu seems lacking as I cannot find information anywhere.  I'm not even sure it's possible.

    I apologise for derailing your comment thread here.


  10. Froggles says:

    Is there a part 7 out there somewhere? The documentation in github claims to have a link to part 7, but it just leads here to part 6.

  11. Estefunny says:

    @Froggles, @Harry, @Synkhan

    From this page ( I was directed to this page (…/windows-8-game-development-using-c-xna.html) as part 7 of this series

  12. Chris says:

    I recently added part nine (9).  My intent is to finish out the game using the media (images, sounds) that was provided in the original blog entry.

Comments are closed.

Skip to main content