Question: 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

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

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.

Create some interfaces:

Create an interface for any and all controllers, IController.

Create an interface for sprites, ISprite.

Optionally, using the Command Design Pattern (http://www.dofactory.com/Patterns/PatternCommand.aspx), 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.

Finally, in the main game class, use the interfaces to animate/update the current sprite. If you are not using commands you will also need logic to switch 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)

In the Game (main) class, only use the interfaces in the Update and Draw methods.

Resources:

You can find spritesheets for Super Mario Bros. off of links on the mario resources page (http://www.c-sharp.com/CSE3902/AU17/2D%20game%20resources.html). Many spritesheets do not have uniform spacing between sprites, so if you want to directly apply the programming logic from 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).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!