Sprint 0 - Getting Started with MonoGame

Due: BEFORE Sep. 07, 11:59:59 pm

This is an individual assignment to get everyone accustomed to using Visual Studio, C#, MonoGame, and designing objects and interfaces. Advanced students may also make use of the Command design pattern. The core requirements for this Sprint are input handling, content loading, sprite drawing, and the MonoGame basic game loop

**Important Note** You must pass this assignment (i.e. score at least 60%) in order to pass the course. Should your graded submission score less than 60%, you will not be allowed on a team until you demonstrate that you can contribute code as an individual.

Step 1) Software setup:

It is strongly recommended to set up a device with Windows for this course. There is a native option for Macs, but we can't help with troubleshooting them as much. Virtual machines are an option but tend to be slow for how fast we want our applications to run, so using a second partition for Windows is recommended if you don't have a Windows PC already. Machines in CL112 may or may not have the most up to date versions of the software we are using. We'll be using Visual Studio 2019 and Monogame version 3.8.

As of around 2018, OSU's liscening no longer includes the Enterprise version of Visual Studio for installing on personal machines, so you can proceed right to Monogame's Getting Started page as it includes steps on installing Visual Studio with suitable plug-ins. Also do the [Optional] step as it is easier to start this assignment from an instance of a template project. You might be able to get a 90-day trial of the Pro/Enterprise version of VS, but this is slightly too short for the whole semester. If you want to use the more robust version (comparing versions) this semester then you can use the Community version for Sprint0 and wait until the start of Sprint2 to install a temporary trial. In any case, start early as installation and setup may take several hours due to file sizes and configuration time.

Legacy link to OSU's Microsoft academic services (link) as it has other software you may find useful for other courses

Miscellaneous troubleshooting:

  • To use the MGCB Editor tool for building of content projects, you may need to install some recent C++ redistributables. If your development machine is one you also use for gaming you may already have some of these installed without realizing it. Based on setup in previous semesters, we recommend downloading and running the 2012, 2013, and 2019 packages. The most common error message that should cue you that you need to do these steps is "Unable to build content - Cannot load FreeImage"; more info on this error can be found here and here
  • For students working out of Caldwell labs, the project templates may not be showing up (we had this issue with MonoGame 3.7.1 but might not with 3.8) If that is the case, contact me and I'll create and post an instance of an empty starter project for you to use to get started.
  • Also for students working out of Caldwell labs, note that Visual Studio is used, not Visual Studio Blend.
  • The MonoGame community isn't incredibly large, but you might find additional install and setup help on their forums
  • For those running Windows as a virtual machine or for those with older laptops, you may need to change some settings if you get an error "no suitable graphics card found" when trying to run your executable. Instructions on that can be found here under the heading Handling the HiDef Profile Error (HiDef Profile vs. Reach Profile).

Step 2) Working with Monogame - tutorials

After setting up the development environment, go through the following Monogame tutorials

  • Monogame - Introduction To 2D Graphics (5 minutes)
  • Creating Your First MonoGame Project (10 minutes; note that working with VS2019 will look slightly different but the process is the same; also note that students have reported problems running the content building tool with 32-bit versions of operating systems)
  • Managing Content (5 minutes)
  • Monogame Spritebatch Basics (10 minutes); here Spritebatch.Draw is used to draw the entire contents of an image file for non-animated sprites
  • Texture Atlases - Part 1(note this has 3 parts - 20 minutes); here Spritebatch.Draw is used to draw sub-rectangles of content in an image file for animated sprites. While not the simplest example of how to animate sprites this has everything you'll need. Please read through the details carefully as you'll need to modify the code to work with other sprite sheets.

Older XNA tutorials (for your reference)

Step 3) Programming Activities

Your assignment is to implement a very simple interactive program. At run-time, the user should be able to interactively select between display of a motionless and non-animated sprite (ex: mario standing still), a motionless and animated sprite (ex: mario running in place), a moving and non-animated sprite (ex: dead mario floating up and down), and a moving animated sprite (ex: mario running right and left). The user should also be able to quit the program with a key press. Supported Inputs (keys and buttons) will be enumerated in an on-screen legend. One significant purpose of this assignment is to gain experience using interfaces (designing them, implementing them, and using them). Carefully read and follow these requirements:

  • Create some interfaces:
    • Create an interface for any and all controllers, IController.
    • Create an interface for sprites, ISprite.
    • Optionally, using the Command Design Pattern, create a ICommand interface.
  • Then make some concrete classes that implement the interfaces:
    • Implement a concrete class for a Keyboard controller.
    • Implement a concrete class for a GamePad controller.
    • Implement a concrete class for the non-moving non-animated sprite.
    • Implement a concrete class for the non-moving animated sprite.
    • Implement a concrete class for the moving but non-animated sprite.
    • Implement a concrete class for the moving and animated sprite.
    • If you made an ICommand interface, implement a concrete class for each Command the user can trigger: one for each different sprite that can be set and one to quit the game.
  • For input keys/buttons, use:
    • Have a key (q) and gamepad button (start) that quits.
    • Have a key (w) and a gamepad button (A) that has the program display a sprite with only one frame of animation and fixed in its (x,y) position on screen.
    • Have a key (e) and a gamepad button (B) that has the program display an animated sprite, but fixed in its (x,y) position on screen.
    • Have a key (r) and a gamepad button (X) that has the program display a sprite with only one frame of animation, but moves the sprite up and down on screen.
    • Have a key (t) and a gamepad button (Y) that has the program display an animated sprite, moving to the left and right on screen.
    • Note on input: you may not be able to physically test the GamePad code, but you still have to write the code for one. I'll keep in mind the lack of testing capability when grading.
  • Finally, In the Game class, use the interfaces in the Update/Animate and Draw the sprite(s). If you are not using commands you will also need logic to select between sprites and quit in the main game class (or in the concrete controllers).

  • Design suggestions:
    • Include a Dictionary in the Keyboard (and GamePad) controller class that maps keys (buttons) to concrete instances of ICommands (based on the input keys/buttons listed above).
    • In the Update method of the controllers, for each input key/button that is pressed, create and execute its corresponding Command.
    • Alternatively, for the controller code if you are not using Commands, consider splitting up input logic into multiple classes (in this case QuittingController and SpriteSettingController)

Resources:

  • You can find spritesheets for Super Mario Bros. off of links on the mario resources page. Many spritesheets do not have uniform spacing between sprites, so if you want to directly apply the programming logic from the tutorials above, you will need to modify (using Paint, GIMP, Paint.NET, Photoshop, etc.) a spritesheet OR alter the logic for setting coordinates for sprite drawing (this will be discussed in class).
  • You are free to use other spritesheets, but do not use a spritesheet that is already in the format of a texture atlas - the learning objective here is in figuring out how to work with any spritesheet, not just 'convenient' ones. You may use a spritesheet formatted as a texture atlas if you edit the image to have this format yourself - include a before and after image in your submission if you do this.

Work to turn in:

  • Do a Build->Clean Solution in Visual Studio and without rebuilding, create a .zip of your Entire project directory (Make absolutely certain your .zip contains the .sln and the Content hierarchy).
  • It is recommended that you unzip the file elsewhere, then build and run it to see if it is working correctly.
  • Next perform a Build in Visual Studio; you will now add the bin directory (Debug or Release) and its contents to the zip file. Make SURE you independently verify the bin folder is complete and your submission will RUN!
  • Upload the .zip using Canvas under the dropbox for Sprint 0.
  • The dropbox is set up to accept multiple submissions, only the latest submission before the deadline will be graded.
  • Start early and do not wait until the last minute to submit work!
  • Please let the instructor know if you have any difficulties submitting your work.

Grading Criteria:

  • Correctness (does it work) - 40%
    • Non-Moving Non-Animated Sprite -- 5%
    • Non-Moving Animated Sprite -- 5%
    • Moving Non-Animated Sprite -- 5%
    • Moving Animated Sprite -- 5%
    • Input keys/buttons Legend (Sprite Text) -- 3%
    • Keyboard Input -- 10%
    • Gamepad Input -- 7%
    • Additional Features Bonus -- 0
  • Code quality (are the interfaces designed and used correctly and is the code readable, maintainable, reusable, and can it be modified easily) - 60%
    • IController – 5%
    • Controllers -- 15%
    • ISprite – 5%
    • Sprite Classes – 15%
    • Overall – 20%
      • Readability: Follow C# capitalization conventions, as shown here
          To summarize:
        • Most names will be in PascalCase where the first letter is capitalized along with the start of each word concatenated to it.
        • The exceptions where camelCase (first letter lowercase then capitalize the start of concatenated words) is used for parameterNames and classMembers
        • You do not need to use '_' for private members.
      • Readability: Use meaningful names for interfaces, classes, and variables and do not have any comments explaining them
        If you are unsure on how to do this, see: Chapter 2 from Clean Code
      • Maintainability: The interfaces should be complete, but as simple as possible
      • Maintainability: Using interfaces in the Game class instead of the concrete types
      • Simplicity and Reusability: Following the design suggestions in the list of objects and interfaces above (if you want to come up with your own design talk to the instructor first)

**Important Note** You must pass this assignment (i.e. score at least 60%) in order to pass the course. Should your graded submission score less than 60%, you will not be allowed on a team until you demonstrate that you can contribute code as an individual.

top