Today's project is simple project, yet provides a nice view into what you can do with TypeScript.
This is a browser-based game similar to the old Space Invaders video game written in TypeScript.
The code is written entirely in TypeScript. It provides examples of object orientation in TypeScript such as classes, constructors, and
Using the Code
The code consists entirely of four separate classes encased in a TypeScript module. The four classes are named
Gameclass is the primary class used to control the game itself and is the one instantiated outside of the
Gamesmodule as follows where 'viewPort' is the id of a
<div>element where the game is displayed.
The rest of the code is relatively straight forward. Each of the
Alienclasses encapsulates its own image and position within the
viewportand provide a
SetYPosfunctions that control the movement of each object.
Here's a snap from Visual Studio;
This conversation has been locked by the site admins. No new comments can be made.