The purpose of this exercise is to allow the student to demonstrate their understanding of application development, the creation and use of classes and objects in Python, and using the other tools (selection, iterations, functions, etc.) we have learned this term. We will make a simple game called 'Stray Cat Strut' - Using the grid class discussed in Chapter 9, create a 20 x 20 cell game board - This game board represents a backyard - Create a class called animal with two attributes: -- an attribute called 'location' which is a grid coordinate (e.g., B3) -- an attribute called 'lives' which is an integer. - The animal class has the standard methods (init, str, etc.) plus one additional method: -- a method called 'move' that changes the animal's location one cell up (N), one cell right (E), one cell down (S), or one cell left (W).
The purpose of this exercise is to allow the student to demonstrate their understanding of application development, the creation and use of classes and objects in Python, and using the other tools (selection, iterations, functions, etc.) we have learned this term. We will make a simple game called 'Stray Cat Strut'
- Using the grid class discussed in Chapter 9, create a 20 x 20 cell game board
- This game board represents a backyard
- Create a class called animal with two attributes:
-- an attribute called 'location' which is a grid coordinate (e.g., B3)
-- an attribute called 'lives' which is an integer.
- The animal class has the standard methods (init, str, etc.) plus one additional method:
-- a method called 'move' that changes the animal's location one cell up (N), one cell right (E), one cell down (S), or one cell left (W).
- Extend the animal class to a subclass called cat, and another subclass called dog
- cat inherits the animal attributes and methods, but also has the following attributes and methods:
-- an attribute called 'attitude' which can have values of 'calm', 'strut' or 'panic'
-- an attribute called 'response' which can have values of 'meow', 'hiss', or 'claw'
-- a method called 'loseLife' which decreases the animal attribute 'lives' by one
- dog inherits the animal class attributes and methods, but also has the following attributes:
-- an attribute called 'demeanor' which can have values of 'happy' or 'angry'
-- an attribute called 'action' which can have values of 'sleeping', 'walking', 'barking', 'growling', or 'attacking'
-- a method called 'makePuppies' which resets the current dog to the default state at a random location on the game board and creates another dog object at a random position on the game board with the default state
- Create a tree object that can have a grid position (use an asterisk character to represent a tree.)
-- The number of trees = two per level with random positions on the game board. Tree do not move within the level.
- Create a catNip object that can have a grid position (use 'N' to represent the catNip on the game board)
-- One catNip object per level at a random position on the game board
- Create a player object that can have a name and score
- Create a games object that has a list of names and scores
- Welcome the player
- Display the top five players and their scores
- Ask if the player needs instructions
- Display the game board with the positions of the tokens (e.g., C for cat, 0 for dog 1, 1 for dog 2, N for catNip, asterisk for trees)
- Get the players move (N, E, S, W, M, H, C, S, X)
- Be able to save the game with the players name as the data file name
- Be able to load saved games
- You can play with the interaction between the cat and dog (what does barking cause the cat to do?) but here are some rough game rules:
-
Game rules:
- Objective: The player makes points by moving the cat toward the catNip, and getting the catNip while avoiding any dogs.
- Game Board Setup:
-- Place trees (2 X Level) at random grid positions. Dogs and Cats cannot go through trees.
-- Place catNip. catNip cannot be in the same grid position as a tree.
-- Place dogs (initially the number of dogs is the same as the level) at random positions. Dogs cannot be in the same grid position as a tree or catNip. Dogs are numbered 0 through 9. The maximum number of dogs at any one time is 10.
-- Place the cat in a random, empty grid position. The cat's initial attitude is calm and is indicated by depicting the cat with a capital 'C'.- Actions:
-- Player can move: N, E, S, W
-- Player can Meow (M): Makes dogs go to sleep for two turns, cat goes from Panic to Calm.
-- Player can Hiss (H): Makes dogs within one grid unit back off one space, token goes from 'C' for calm to 'P' for panic, can now claw.
-- Player can Claw (C): Makes dogs within one grid reset at a random position, but creates another dog. The cat must have an attitude of panic to enable the claw action.
Here is an example opening screen:
Trending now
This is a popular solution!
Step by step
Solved in 2 steps