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

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

Rate This
  • Comments 10

 

Overview

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 https://bitbucket.org/teicher/shootertutorial. 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;
  8.  
  9. _positions[index].X = _positions[prevTexture].X + _texture.Width;
  10. }
  11.  
  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.
  16.  
  17. int nextTexture = index + 1;
  18. if (nextTexture == _positions.Length)
  19. nextTexture = 0;
  20.  
  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

 

Leave a Comment
  • Please add 5 and 1 and type the answer here:
  • Post
  • great

  • 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?

  • 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!

  • 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

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

  • 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.

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

  • 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.

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

  • 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.

    Thanks.

Page 1 of 1 (10 items)