brandonyuen / prg01-8_game Goto Github PK
View Code? Open in Web Editor NEWTypescript game made for a school project.
License: MIT License
Typescript game made for a school project.
License: MIT License
Strictly seen, you could improve your code by using getters and setters to access instances of libraries (like PIXI) defined in class Game. In your case, only a getter would be appropriate since other classes are not allowed to overwrite these libraries.
The singleton pattern has been implemented in the Game class but you forgot to make the constructor private.
When implementing the singleton pattern the constructor should be private. If the constructor is not private, anyone can make an instance of Game and it would no longer be a singleton. For a singleton by definition there can exist only one instance.
Currently you are using polymorphism in one place in your code. Inheritance is used since class Player extends from GameObject. For the final assessment you will need to have 2 implementations of polymorphism. Do remember that polymorphism used in the strategy or observer pattern does not count as an implementation of polymorphism.
It looks like you made a start with the strategy pattern, though your implementation does not seem to be finished. You have an interface for different types of movement, but there is only one type of movement: walking. In the player class you define the type of movement at:
private movement:Movement = new Walking(this)
The strategy pattern is correctly implemented, you just need to add another type of movement that you can switch between.
Oberver pattern has not been implemented yet.
Your game is looking good so far! Keep up the good work.
Je hebt heel goed nagedacht over wat je in je game wilt hebben en maakt goed gebruik van tools die beschikbaar zijn. Met de combinatie van PIXI, Howler & Tiled heb je een hele toffe combinatie aan Game Aesthetics!
Je hebt de meeste patterns volledig verwerkt in je game:
Game
is een singleton waardoor er maar één game aan te kunnen maken. (Voor Player
geldt hetzelfde!) Entity
implementeert een Subject
en Gun
implementeert de observer. Wanneer een Entity
zich update doen de observers van die Entity
dat ook.Entity
een Movement
heeft (die bijvoorbeeld van het type Walking
is maar ook een ander type zou kunnen hebben) en aangepast zou kunnen worden. Hiermee pas je de Strategy pattern correct toe. Zorg er in ieder geval voor dat je uiteindelijk in runtime van Movement
kan wisselen.Player
is een Entity
en een Pistol
is een Gun
.Je mist nog twee dingen: Type Assertion en Type Guards. Op dit moment ben je nog een is stage van development dat dit niet optimaal is toe te passen. Maar denk bijvoorbeeld aan mogelijkheden voor
type guards wanneer je Enemies gaat toevoegen. Als je ook nog van plan bent om menuschermen te implementeren kan type Assertion bij clickEvents ook erg van pas komen.
Ik ben heel benieuwd naar het eind resultaat van je game, zeker met de kwaliteit van je animaties van nu! Success met het laatste stuk 😸
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.