次の方法で共有


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

 

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

Comments

  • Anonymous
    August 25, 2013
    great

  • Anonymous
    August 29, 2013
    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?

  • Anonymous
    August 29, 2013
    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!

  • Anonymous
    September 03, 2013
    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

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

  • Anonymous
    September 03, 2013
    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.

  • Anonymous
    October 15, 2013
    The comment has been removed

  • Anonymous
    January 04, 2014
    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.

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

  • Anonymous
    July 21, 2014
    The comment has been removed

  • Anonymous
    December 17, 2014
    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.

  • Anonymous
    February 03, 2015
    @Froggles, @Harry, @Synkhan From this page (www.monogame.net/documentation) I was directed to this page (chrisongames.blogspot.de/.../windows-8-game-development-using-c-xna.html) as part 7 of this series

  • Anonymous
    December 29, 2015
    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.