6-space-game/1-introduction/assignment.md
Put your newfound knowledge of design patterns to work by creating a simple game prototype! This assignment will help you practice both architectural patterns (inheritance or composition) and the pub/sub communication system you learned about in the lesson.
Create a simple game representation that demonstrates the design patterns from this lesson. Your game should be functional but doesn't need complex graphics \u2013 focus on the underlying architecture and communication patterns.
Choose Your Architecture Pattern:
GameObject → Movable → Hero example)Implement Communication:
EventEmitter class for pub/sub messagingPLAYER_MOVE, ENEMY_SPAWN, SCORE_UPDATE)Game Elements to Include:
Simple Games to Consider:
// Example starting structure
const Messages = {
// Define your game messages here
};
class EventEmitter {
// Your event system implementation
}
// Choose either class-based OR composition approach
// Class-based example:
class GameObject { /* base properties */ }
class Player extends GameObject { /* player-specific behavior */ }
// OR Composition example:
const gameObject = { /* base properties */ };
const movable = { /* movement behavior */ };
function createPlayer() { /* combine behaviors */ }
Verify your code works by:
Your submission should include:
| Criteria | Exemplary (3 points) | Adequate (2 points) | Needs Improvement (1 point) |
|---|---|---|---|
| Architecture Pattern | Correctly implements either inheritance OR composition with clear class/object hierarchy | Uses chosen pattern with minor issues or inconsistencies | Attempts to use pattern but implementation has significant problems |
| Pub/Sub Implementation | EventEmitter works correctly with multiple message types and proper event flow | Basic pub/sub system works with some event handling | Event system present but doesn't work reliably |
| Game Functionality | Three or more interactive elements that communicate through events | Two interactive elements with basic event communication | One element responds to events or basic interaction |
| Code Quality | Clean, well-commented code with logical organization and modern JavaScript | Generally well-organized code with adequate comments | Code works but lacks organization or clear commenting |
Bonus Points: