├── _config.yml ├── javascript ├── src │ ├── ship │ │ ├── shipStatus.js │ │ ├── passiveReading.js │ │ ├── passiveSensorReading.js │ │ ├── EMSReading.js │ │ ├── mapData.js │ │ ├── torpedo.js │ │ └── passiveSensors.js │ ├── helpers │ │ ├── response.js │ │ ├── Angles.js │ │ ├── pos.js │ │ └── Matrix2.js │ ├── subsystems │ │ ├── propulsionController.js │ │ ├── sensorsController.js │ │ ├── navigationController.js │ │ └── defenceController.js │ ├── galaxies │ │ ├── noob.js │ │ ├── solarSystem.js │ │ ├── galaxy.js │ │ └── compiles.js │ ├── spaceObjects │ │ ├── blackhole.js │ │ ├── meteor.js │ │ ├── warpGate.js │ │ ├── star.js │ │ ├── planetComposition.js │ │ ├── asteroid.js │ │ └── asteroidLauncher.js │ ├── renderedObject.js │ ├── sprite.js │ ├── images.js │ └── controller.js └── students │ ├── types.js │ ├── helpers.js │ ├── Bebop │ ├── SensorsController.js │ ├── PropulsionController.js │ ├── DefenseController.js │ └── NavigationController.js │ ├── Rama │ ├── SensorsController.js │ ├── PropulsionController.js │ ├── DefenseController.js │ └── NavigationController.js │ ├── Bismark │ ├── SensorsController.js │ ├── PropulsionController.js │ ├── DefenseController.js │ └── NavigationController.js │ ├── Enterprise │ ├── SensorsController.js │ ├── PropulsionController.js │ ├── DefenseController.js │ └── NavigationController.js │ ├── Galactica │ ├── SensorsController.js │ ├── PropulsionController.js │ ├── DefenseController.js │ └── NavigationController.js │ ├── Milano │ ├── SensorsController.js │ ├── PropulsionController.js │ ├── DefenseController.js │ └── NavigationController.js │ ├── Normandy │ ├── SensorsController.js │ ├── PropulsionController.js │ ├── DefenseController.js │ └── NavigationController.js │ ├── Nostromo │ ├── SensorsController.js │ ├── PropulsionController.js │ ├── DefenseController.js │ └── NavigationController.js │ ├── RedDwarf │ ├── SensorsController.js │ ├── PropulsionController.js │ ├── DefenseController.js │ └── NavigationController.js │ ├── SSAnne │ ├── SensorsController.js │ ├── PropulsionController.js │ ├── DefenseController.js │ └── NavigationController.js │ ├── Serenity │ ├── SensorsController.js │ ├── PropulsionController.js │ ├── DefenseController.js │ └── NavigationController.js │ ├── Yamato │ ├── SensorsController.js │ ├── PropulsionController.js │ ├── DefenseController.js │ └── NavigationController.js │ ├── EventHorizon │ ├── SensorsController.js │ ├── PropulsionController.js │ ├── DefenseController.js │ └── NavigationController.js │ ├── FlyingDutchman │ ├── SensorsController.js │ ├── PropulsionController.js │ ├── DefenseController.js │ └── NavigationController.js │ ├── PillarOfAutumn │ ├── SensorsController.js │ ├── PropulsionController.js │ ├── DefenseController.js │ └── NavigationController.js │ ├── PlanetExpress │ ├── SensorsController.js │ ├── PropulsionController.js │ ├── DefenseController.js │ └── NavigationController.js │ └── Thunderbird3 │ ├── SensorsController.js │ ├── PropulsionController.js │ ├── DefenseController.js │ └── NavigationController.js ├── favicon.ico ├── manual ├── Zac.png ├── Follow.png ├── Fork.png ├── GoLive.png ├── Josiah.png ├── Open.png ├── Spacer.png ├── Star.png ├── MainMenu.png ├── Preview1.png ├── Preview2.png ├── Preview3.png ├── Preview4.png ├── Preview5.png ├── Preview6.png ├── Coordinates.png ├── CoverImage.png ├── Extensions.png ├── LiveServer.png └── codeBlocks.md ├── .vscode └── settings.json ├── assets ├── fonts │ ├── Montserrat-Bold.ttf │ ├── NotoSans-Black.ttf │ ├── Montserrat-Light.ttf │ ├── NotoSans-Regular.ttf │ ├── Montserrat-Regular.ttf │ ├── Montserrat-SemiBold.ttf │ └── Montserrat-ExtraLight.ttf └── images │ ├── explosions │ ├── 0.png │ ├── 1.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ ├── 6.png │ ├── 7.png │ └── 8.png │ ├── planets │ ├── Cheese.png │ ├── Mars.png │ ├── Saturn.png │ ├── DarkLava.png │ ├── DeadGrey.png │ ├── IceCube.png │ ├── IceWater.png │ ├── LavaRing.png │ ├── Neptune.png │ ├── BlueStorm.png │ ├── DarkNeptune.png │ ├── GreyLines.png │ ├── LightLava.png │ ├── PinkSaturn.png │ ├── SandyCheeks.png │ ├── PurplePlanet.png │ ├── PurpleStripes.png │ └── EarthLookinAss.png │ ├── ship │ ├── ColonyShip.png │ ├── ThrusterFlame.png │ ├── ThrusterNozzle.png │ └── TurretSprite.png │ ├── SpaceObjects │ ├── Galaxy.png │ ├── Meteor.png │ ├── Space.png │ ├── Star.png │ ├── Torpedo.png │ ├── WarpGate.png │ └── BlackHole.png │ └── UIImages │ ├── TitleBackground.png │ └── TitleBackground2.png ├── .gitignore ├── typescript ├── students │ ├── helpers.ts │ ├── types.ts │ ├── Bebop │ │ ├── DefenseController.ts │ │ ├── PropulsionController.ts │ │ ├── NavigationController.ts │ │ └── SensorsController.ts │ ├── Bismark │ │ ├── PropulsionController.ts │ │ ├── DefenseController.ts │ │ ├── NavigationController.ts │ │ └── SensorsController.ts │ ├── Milano │ │ ├── PropulsionController.ts │ │ ├── DefenseController.ts │ │ ├── NavigationController.ts │ │ └── SensorsController.ts │ ├── Rama │ │ ├── PropulsionController.ts │ │ ├── DefenseController.ts │ │ ├── NavigationController.ts │ │ └── SensorsController.ts │ ├── SSAnne │ │ ├── PropulsionController.ts │ │ ├── DefenseController.ts │ │ ├── NavigationController.ts │ │ └── SensorsController.ts │ ├── Yamato │ │ ├── PropulsionController.ts │ │ ├── DefenseController.ts │ │ ├── NavigationController.ts │ │ └── SensorsController.ts │ ├── Enterprise │ │ ├── PropulsionController.ts │ │ ├── DefenseController.ts │ │ ├── NavigationController.ts │ │ └── SensorsController.ts │ ├── EventHorizon │ │ ├── PropulsionController.ts │ │ ├── DefenseController.ts │ │ ├── NavigationController.ts │ │ └── SensorsController.ts │ ├── Galactica │ │ ├── PropulsionController.ts │ │ ├── DefenseController.ts │ │ ├── NavigationController.ts │ │ └── SensorsController.ts │ ├── Normandy │ │ ├── PropulsionController.ts │ │ ├── DefenseController.ts │ │ ├── NavigationController.ts │ │ └── SensorsController.ts │ ├── Nostromo │ │ ├── PropulsionController.ts │ │ ├── DefenseController.ts │ │ ├── NavigationController.ts │ │ └── SensorsController.ts │ ├── RedDwarf │ │ ├── PropulsionController.ts │ │ ├── DefenseController.ts │ │ ├── NavigationController.ts │ │ └── SensorsController.ts │ ├── Serenity │ │ ├── PropulsionController.ts │ │ ├── DefenseController.ts │ │ ├── NavigationController.ts │ │ └── SensorsController.ts │ ├── Thunderbird3 │ │ ├── PropulsionController.ts │ │ ├── DefenseController.ts │ │ ├── NavigationController.ts │ │ └── SensorsController.ts │ ├── FlyingDutchman │ │ ├── PropulsionController.ts │ │ ├── DefenseController.ts │ │ ├── NavigationController.ts │ │ └── SensorsController.ts │ ├── PillarOfAutumn │ │ ├── PropulsionController.ts │ │ ├── DefenseController.ts │ │ ├── NavigationController.ts │ │ └── SensorsController.ts │ └── PlanetExpress │ │ ├── PropulsionController.ts │ │ ├── DefenseController.ts │ │ ├── NavigationController.ts │ │ └── SensorsController.ts └── src │ ├── ship │ ├── passiveReading.ts │ ├── shipStatus.ts │ ├── EMSReading.ts │ ├── mapData.ts │ ├── torpedo.ts │ ├── passiveSensors.ts │ └── turretControls.ts │ ├── helpers │ ├── Angles.ts │ ├── pos.ts │ ├── Matrix2.ts │ └── Vector2.ts │ ├── galaxies │ ├── noob.ts │ ├── solarSystem.ts │ ├── galaxy.ts │ └── compiles.ts │ ├── subsystems │ ├── propulsionController.ts │ ├── defenceController.ts │ ├── navigationController.ts │ └── sensorsController.ts │ ├── spaceObjects │ ├── blackhole.ts │ ├── meteor.ts │ ├── star.ts │ ├── warpGate.ts │ ├── planetComposition.ts │ ├── asteroid.ts │ └── asteroidLauncher.ts │ ├── sprite.ts │ ├── renderedObject.ts │ ├── controller.ts │ └── images.ts ├── package.json ├── LICENSE └── .github └── workflows └── codeql-analysis.yml /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /javascript/src/ship/shipStatus.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | -------------------------------------------------------------------------------- /favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/favicon.ico -------------------------------------------------------------------------------- /manual/Zac.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/manual/Zac.png -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.exclude": { 3 | "javascript": true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /manual/Follow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/manual/Follow.png -------------------------------------------------------------------------------- /manual/Fork.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/manual/Fork.png -------------------------------------------------------------------------------- /manual/GoLive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/manual/GoLive.png -------------------------------------------------------------------------------- /manual/Josiah.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/manual/Josiah.png -------------------------------------------------------------------------------- /manual/Open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/manual/Open.png -------------------------------------------------------------------------------- /manual/Spacer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/manual/Spacer.png -------------------------------------------------------------------------------- /manual/Star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/manual/Star.png -------------------------------------------------------------------------------- /manual/MainMenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/manual/MainMenu.png -------------------------------------------------------------------------------- /manual/Preview1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/manual/Preview1.png -------------------------------------------------------------------------------- /manual/Preview2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/manual/Preview2.png -------------------------------------------------------------------------------- /manual/Preview3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/manual/Preview3.png -------------------------------------------------------------------------------- /manual/Preview4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/manual/Preview4.png -------------------------------------------------------------------------------- /manual/Preview5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/manual/Preview5.png -------------------------------------------------------------------------------- /manual/Preview6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/manual/Preview6.png -------------------------------------------------------------------------------- /manual/Coordinates.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/manual/Coordinates.png -------------------------------------------------------------------------------- /manual/CoverImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/manual/CoverImage.png -------------------------------------------------------------------------------- /manual/Extensions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/manual/Extensions.png -------------------------------------------------------------------------------- /manual/LiveServer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/manual/LiveServer.png -------------------------------------------------------------------------------- /assets/fonts/Montserrat-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/fonts/Montserrat-Bold.ttf -------------------------------------------------------------------------------- /assets/fonts/NotoSans-Black.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/fonts/NotoSans-Black.ttf -------------------------------------------------------------------------------- /assets/images/explosions/0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/explosions/0.png -------------------------------------------------------------------------------- /assets/images/explosions/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/explosions/1.png -------------------------------------------------------------------------------- /assets/images/explosions/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/explosions/2.png -------------------------------------------------------------------------------- /assets/images/explosions/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/explosions/3.png -------------------------------------------------------------------------------- /assets/images/explosions/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/explosions/4.png -------------------------------------------------------------------------------- /assets/images/explosions/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/explosions/5.png -------------------------------------------------------------------------------- /assets/images/explosions/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/explosions/6.png -------------------------------------------------------------------------------- /assets/images/explosions/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/explosions/7.png -------------------------------------------------------------------------------- /assets/images/explosions/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/explosions/8.png -------------------------------------------------------------------------------- /assets/images/planets/Cheese.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/planets/Cheese.png -------------------------------------------------------------------------------- /assets/images/planets/Mars.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/planets/Mars.png -------------------------------------------------------------------------------- /assets/images/planets/Saturn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/planets/Saturn.png -------------------------------------------------------------------------------- /assets/fonts/Montserrat-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/fonts/Montserrat-Light.ttf -------------------------------------------------------------------------------- /assets/fonts/NotoSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/fonts/NotoSans-Regular.ttf -------------------------------------------------------------------------------- /assets/images/planets/DarkLava.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/planets/DarkLava.png -------------------------------------------------------------------------------- /assets/images/planets/DeadGrey.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/planets/DeadGrey.png -------------------------------------------------------------------------------- /assets/images/planets/IceCube.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/planets/IceCube.png -------------------------------------------------------------------------------- /assets/images/planets/IceWater.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/planets/IceWater.png -------------------------------------------------------------------------------- /assets/images/planets/LavaRing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/planets/LavaRing.png -------------------------------------------------------------------------------- /assets/images/planets/Neptune.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/planets/Neptune.png -------------------------------------------------------------------------------- /assets/images/ship/ColonyShip.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/ship/ColonyShip.png -------------------------------------------------------------------------------- /assets/fonts/Montserrat-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/fonts/Montserrat-Regular.ttf -------------------------------------------------------------------------------- /assets/fonts/Montserrat-SemiBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/fonts/Montserrat-SemiBold.ttf -------------------------------------------------------------------------------- /assets/images/SpaceObjects/Galaxy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/SpaceObjects/Galaxy.png -------------------------------------------------------------------------------- /assets/images/SpaceObjects/Meteor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/SpaceObjects/Meteor.png -------------------------------------------------------------------------------- /assets/images/SpaceObjects/Space.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/SpaceObjects/Space.png -------------------------------------------------------------------------------- /assets/images/SpaceObjects/Star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/SpaceObjects/Star.png -------------------------------------------------------------------------------- /assets/images/planets/BlueStorm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/planets/BlueStorm.png -------------------------------------------------------------------------------- /assets/images/planets/DarkNeptune.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/planets/DarkNeptune.png -------------------------------------------------------------------------------- /assets/images/planets/GreyLines.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/planets/GreyLines.png -------------------------------------------------------------------------------- /assets/images/planets/LightLava.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/planets/LightLava.png -------------------------------------------------------------------------------- /assets/images/planets/PinkSaturn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/planets/PinkSaturn.png -------------------------------------------------------------------------------- /assets/images/planets/SandyCheeks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/planets/SandyCheeks.png -------------------------------------------------------------------------------- /assets/images/ship/ThrusterFlame.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/ship/ThrusterFlame.png -------------------------------------------------------------------------------- /assets/images/ship/ThrusterNozzle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/ship/ThrusterNozzle.png -------------------------------------------------------------------------------- /assets/images/ship/TurretSprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/ship/TurretSprite.png -------------------------------------------------------------------------------- /assets/fonts/Montserrat-ExtraLight.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/fonts/Montserrat-ExtraLight.ttf -------------------------------------------------------------------------------- /assets/images/SpaceObjects/Torpedo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/SpaceObjects/Torpedo.png -------------------------------------------------------------------------------- /assets/images/SpaceObjects/WarpGate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/SpaceObjects/WarpGate.png -------------------------------------------------------------------------------- /assets/images/planets/PurplePlanet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/planets/PurplePlanet.png -------------------------------------------------------------------------------- /assets/images/planets/PurpleStripes.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/planets/PurpleStripes.png -------------------------------------------------------------------------------- /assets/images/SpaceObjects/BlackHole.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/SpaceObjects/BlackHole.png -------------------------------------------------------------------------------- /assets/images/UIImages/TitleBackground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/UIImages/TitleBackground.png -------------------------------------------------------------------------------- /assets/images/planets/EarthLookinAss.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/planets/EarthLookinAss.png -------------------------------------------------------------------------------- /assets/images/UIImages/TitleBackground2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zrwaite/se101-spaceship/HEAD/assets/images/UIImages/TitleBackground2.png -------------------------------------------------------------------------------- /javascript/students/types.js: -------------------------------------------------------------------------------- 1 | export { EMSReading } from '../src/ship/EMSReading.js'; 2 | export { PassiveReading } from '../src/ship/passiveReading.js'; 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | 4 | # MacOS 5 | .DS_Store 6 | 7 | #Wiki edits 8 | SpaceshipJavasript.wiki 9 | 10 | #JetBrains 11 | .idea 12 | 13 | #Node modules 14 | node_modules -------------------------------------------------------------------------------- /javascript/src/ship/passiveReading.js: -------------------------------------------------------------------------------- 1 | export class PassiveReading { 2 | constructor(angle, gravity) { 3 | this.heading = angle; //number 4 | this.gravity = gravity; // mass/distance; 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /javascript/src/ship/passiveSensorReading.js: -------------------------------------------------------------------------------- 1 | export class PassiveSensorReading { 2 | constructor(angle, gravity) { 3 | this.heading = angle; //number 4 | this.gravity = gravity; // mass/distance; 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /typescript/students/helpers.ts: -------------------------------------------------------------------------------- 1 | export { default as Vector2 } from '../src/helpers/Vector2.js' 2 | export { withinPiRange, angleDiff } from '../src/helpers/Angles.js' 3 | export { default as Matrix2 } from '../src/helpers/Matrix2.js' 4 | -------------------------------------------------------------------------------- /javascript/students/helpers.js: -------------------------------------------------------------------------------- 1 | export { default as Vector2 } from '../src/helpers/Vector2.js'; 2 | export { withinPiRange, angleDiff } from '../src/helpers/Angles.js'; 3 | export { default as Matrix2 } from '../src/helpers/Matrix2.js'; 4 | -------------------------------------------------------------------------------- /typescript/src/ship/passiveReading.ts: -------------------------------------------------------------------------------- 1 | export class PassiveReading { 2 | heading 3 | gravity 4 | constructor(angle: number, gravity: number) { 5 | this.heading = angle //number 6 | this.gravity = gravity // mass/distance; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /typescript/students/types.ts: -------------------------------------------------------------------------------- 1 | export { ThrusterName } from '../src/ship/thrusterController.js' 2 | export { ShipStatus } from '../src/ship/shipStatus.js' 3 | export { MapData } from '../src/ship/mapData.js' 4 | export { EMSReading } from '../src/ship/EMSReading.js' 5 | export { PassiveReading } from '../src/ship/passiveReading.js' 6 | -------------------------------------------------------------------------------- /javascript/students/Bebop/SensorsController.js: -------------------------------------------------------------------------------- 1 | import SensorsController from '../../src/subsystems/sensorsController.js'; 2 | export default class YourSensorsController extends SensorsController { 3 | //Add additional attributes here 4 | sensorsUpdate(activeScan, passiveScan) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Rama/SensorsController.js: -------------------------------------------------------------------------------- 1 | import SensorsController from '../../src/subsystems/sensorsController.js'; 2 | export default class YourSensorsController extends SensorsController { 3 | //Add additional attributes here 4 | sensorsUpdate(activeScan, passiveScan) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Bismark/SensorsController.js: -------------------------------------------------------------------------------- 1 | import SensorsController from '../../src/subsystems/sensorsController.js'; 2 | export default class YourSensorsController extends SensorsController { 3 | //Add additional attributes here 4 | sensorsUpdate(activeScan, passiveScan) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Enterprise/SensorsController.js: -------------------------------------------------------------------------------- 1 | import SensorsController from '../../src/subsystems/sensorsController.js'; 2 | export default class YourSensorsController extends SensorsController { 3 | //Add additional attributes here 4 | sensorsUpdate(activeScan, passiveScan) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Galactica/SensorsController.js: -------------------------------------------------------------------------------- 1 | import SensorsController from '../../src/subsystems/sensorsController.js'; 2 | export default class YourSensorsController extends SensorsController { 3 | //Add additional attributes here 4 | sensorsUpdate(activeScan, passiveScan) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Milano/SensorsController.js: -------------------------------------------------------------------------------- 1 | import SensorsController from '../../src/subsystems/sensorsController.js'; 2 | export default class YourSensorsController extends SensorsController { 3 | //Add additional attributes here 4 | sensorsUpdate(activeScan, passiveScan) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Normandy/SensorsController.js: -------------------------------------------------------------------------------- 1 | import SensorsController from '../../src/subsystems/sensorsController.js'; 2 | export default class YourSensorsController extends SensorsController { 3 | //Add additional attributes here 4 | sensorsUpdate(activeScan, passiveScan) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Nostromo/SensorsController.js: -------------------------------------------------------------------------------- 1 | import SensorsController from '../../src/subsystems/sensorsController.js'; 2 | export default class YourSensorsController extends SensorsController { 3 | //Add additional attributes here 4 | sensorsUpdate(activeScan, passiveScan) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Rama/PropulsionController.js: -------------------------------------------------------------------------------- 1 | import PropulsionController from '../../src/subsystems/propulsionController.js'; 2 | export default class YourPropulsionController extends PropulsionController { 3 | //Add additional attributes here 4 | propulsionUpdate(setThruster) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/RedDwarf/SensorsController.js: -------------------------------------------------------------------------------- 1 | import SensorsController from '../../src/subsystems/sensorsController.js'; 2 | export default class YourSensorsController extends SensorsController { 3 | //Add additional attributes here 4 | sensorsUpdate(activeScan, passiveScan) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/SSAnne/SensorsController.js: -------------------------------------------------------------------------------- 1 | import SensorsController from '../../src/subsystems/sensorsController.js'; 2 | export default class YourSensorsController extends SensorsController { 3 | //Add additional attributes here 4 | sensorsUpdate(activeScan, passiveScan) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Serenity/SensorsController.js: -------------------------------------------------------------------------------- 1 | import SensorsController from '../../src/subsystems/sensorsController.js'; 2 | export default class YourSensorsController extends SensorsController { 3 | //Add additional attributes here 4 | sensorsUpdate(activeScan, passiveScan) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Yamato/SensorsController.js: -------------------------------------------------------------------------------- 1 | import SensorsController from '../../src/subsystems/sensorsController.js'; 2 | export default class YourSensorsController extends SensorsController { 3 | //Add additional attributes here 4 | sensorsUpdate(activeScan, passiveScan) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Bebop/PropulsionController.js: -------------------------------------------------------------------------------- 1 | import PropulsionController from '../../src/subsystems/propulsionController.js'; 2 | export default class YourPropulsionController extends PropulsionController { 3 | //Add additional attributes here 4 | propulsionUpdate(setThruster) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Bismark/PropulsionController.js: -------------------------------------------------------------------------------- 1 | import PropulsionController from '../../src/subsystems/propulsionController.js'; 2 | export default class YourPropulsionController extends PropulsionController { 3 | //Add additional attributes here 4 | propulsionUpdate(setThruster) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/EventHorizon/SensorsController.js: -------------------------------------------------------------------------------- 1 | import SensorsController from '../../src/subsystems/sensorsController.js'; 2 | export default class YourSensorsController extends SensorsController { 3 | //Add additional attributes here 4 | sensorsUpdate(activeScan, passiveScan) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/FlyingDutchman/SensorsController.js: -------------------------------------------------------------------------------- 1 | import SensorsController from '../../src/subsystems/sensorsController.js'; 2 | export default class YourSensorsController extends SensorsController { 3 | //Add additional attributes here 4 | sensorsUpdate(activeScan, passiveScan) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Galactica/PropulsionController.js: -------------------------------------------------------------------------------- 1 | import PropulsionController from '../../src/subsystems/propulsionController.js'; 2 | export default class YourPropulsionController extends PropulsionController { 3 | //Add additional attributes here 4 | propulsionUpdate(setThruster) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Milano/PropulsionController.js: -------------------------------------------------------------------------------- 1 | import PropulsionController from '../../src/subsystems/propulsionController.js'; 2 | export default class YourPropulsionController extends PropulsionController { 3 | //Add additional attributes here 4 | propulsionUpdate(setThruster) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Normandy/PropulsionController.js: -------------------------------------------------------------------------------- 1 | import PropulsionController from '../../src/subsystems/propulsionController.js'; 2 | export default class YourPropulsionController extends PropulsionController { 3 | //Add additional attributes here 4 | propulsionUpdate(setThruster) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Nostromo/PropulsionController.js: -------------------------------------------------------------------------------- 1 | import PropulsionController from '../../src/subsystems/propulsionController.js'; 2 | export default class YourPropulsionController extends PropulsionController { 3 | //Add additional attributes here 4 | propulsionUpdate(setThruster) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/PillarOfAutumn/SensorsController.js: -------------------------------------------------------------------------------- 1 | import SensorsController from '../../src/subsystems/sensorsController.js'; 2 | export default class YourSensorsController extends SensorsController { 3 | //Add additional attributes here 4 | sensorsUpdate(activeScan, passiveScan) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/PlanetExpress/SensorsController.js: -------------------------------------------------------------------------------- 1 | import SensorsController from '../../src/subsystems/sensorsController.js'; 2 | export default class YourSensorsController extends SensorsController { 3 | //Add additional attributes here 4 | sensorsUpdate(activeScan, passiveScan) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/RedDwarf/PropulsionController.js: -------------------------------------------------------------------------------- 1 | import PropulsionController from '../../src/subsystems/propulsionController.js'; 2 | export default class YourPropulsionController extends PropulsionController { 3 | //Add additional attributes here 4 | propulsionUpdate(setThruster) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/SSAnne/PropulsionController.js: -------------------------------------------------------------------------------- 1 | import PropulsionController from '../../src/subsystems/propulsionController.js'; 2 | export default class YourPropulsionController extends PropulsionController { 3 | //Add additional attributes here 4 | propulsionUpdate(setThruster) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Serenity/PropulsionController.js: -------------------------------------------------------------------------------- 1 | import PropulsionController from '../../src/subsystems/propulsionController.js'; 2 | export default class YourPropulsionController extends PropulsionController { 3 | //Add additional attributes here 4 | propulsionUpdate(setThruster) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Thunderbird3/SensorsController.js: -------------------------------------------------------------------------------- 1 | import SensorsController from '../../src/subsystems/sensorsController.js'; 2 | export default class YourSensorsController extends SensorsController { 3 | //Add additional attributes here 4 | sensorsUpdate(activeScan, passiveScan) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Yamato/PropulsionController.js: -------------------------------------------------------------------------------- 1 | import PropulsionController from '../../src/subsystems/propulsionController.js'; 2 | export default class YourPropulsionController extends PropulsionController { 3 | //Add additional attributes here 4 | propulsionUpdate(setThruster) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Enterprise/PropulsionController.js: -------------------------------------------------------------------------------- 1 | import PropulsionController from '../../src/subsystems/propulsionController.js'; 2 | export default class YourPropulsionController extends PropulsionController { 3 | //Add additional attributes here 4 | propulsionUpdate(setThruster) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/EventHorizon/PropulsionController.js: -------------------------------------------------------------------------------- 1 | import PropulsionController from '../../src/subsystems/propulsionController.js'; 2 | export default class YourPropulsionController extends PropulsionController { 3 | //Add additional attributes here 4 | propulsionUpdate(setThruster) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/FlyingDutchman/PropulsionController.js: -------------------------------------------------------------------------------- 1 | import PropulsionController from '../../src/subsystems/propulsionController.js'; 2 | export default class YourPropulsionController extends PropulsionController { 3 | //Add additional attributes here 4 | propulsionUpdate(setThruster) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/PillarOfAutumn/PropulsionController.js: -------------------------------------------------------------------------------- 1 | import PropulsionController from '../../src/subsystems/propulsionController.js'; 2 | export default class YourPropulsionController extends PropulsionController { 3 | //Add additional attributes here 4 | propulsionUpdate(setThruster) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/PlanetExpress/PropulsionController.js: -------------------------------------------------------------------------------- 1 | import PropulsionController from '../../src/subsystems/propulsionController.js'; 2 | export default class YourPropulsionController extends PropulsionController { 3 | //Add additional attributes here 4 | propulsionUpdate(setThruster) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Rama/DefenseController.js: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js'; 2 | export default class YourDefenceController extends DefenceController { 3 | //Add additional attributes here 4 | defenceUpdate(aimTurret, getTubeCooldown, fireTorpedo) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Thunderbird3/PropulsionController.js: -------------------------------------------------------------------------------- 1 | import PropulsionController from '../../src/subsystems/propulsionController.js'; 2 | export default class YourPropulsionController extends PropulsionController { 3 | //Add additional attributes here 4 | propulsionUpdate(setThruster) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/src/helpers/response.js: -------------------------------------------------------------------------------- 1 | export default class APIResponse { 2 | constructor(status = 400, errors = [], response = {}, success = false) { 3 | this.success = success; 4 | this.status = status; 5 | this.errors = []; 6 | this.errors.push(...errors); 7 | this.response = response; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /javascript/students/Bebop/DefenseController.js: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js'; 2 | export default class YourDefenceController extends DefenceController { 3 | //Add additional attributes here 4 | defenceUpdate(aimTurret, getTubeCooldown, fireTorpedo) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Bismark/DefenseController.js: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js'; 2 | export default class YourDefenceController extends DefenceController { 3 | //Add additional attributes here 4 | defenceUpdate(aimTurret, getTubeCooldown, fireTorpedo) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Galactica/DefenseController.js: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js'; 2 | export default class YourDefenceController extends DefenceController { 3 | //Add additional attributes here 4 | defenceUpdate(aimTurret, getTubeCooldown, fireTorpedo) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Milano/DefenseController.js: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js'; 2 | export default class YourDefenceController extends DefenceController { 3 | //Add additional attributes here 4 | defenceUpdate(aimTurret, getTubeCooldown, fireTorpedo) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Normandy/DefenseController.js: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js'; 2 | export default class YourDefenceController extends DefenceController { 3 | //Add additional attributes here 4 | defenceUpdate(aimTurret, getTubeCooldown, fireTorpedo) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Nostromo/DefenseController.js: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js'; 2 | export default class YourDefenceController extends DefenceController { 3 | //Add additional attributes here 4 | defenceUpdate(aimTurret, getTubeCooldown, fireTorpedo) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/RedDwarf/DefenseController.js: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js'; 2 | export default class YourDefenceController extends DefenceController { 3 | //Add additional attributes here 4 | defenceUpdate(aimTurret, getTubeCooldown, fireTorpedo) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/SSAnne/DefenseController.js: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js'; 2 | export default class YourDefenceController extends DefenceController { 3 | //Add additional attributes here 4 | defenceUpdate(aimTurret, getTubeCooldown, fireTorpedo) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Serenity/DefenseController.js: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js'; 2 | export default class YourDefenceController extends DefenceController { 3 | //Add additional attributes here 4 | defenceUpdate(aimTurret, getTubeCooldown, fireTorpedo) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Yamato/DefenseController.js: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js'; 2 | export default class YourDefenceController extends DefenceController { 3 | //Add additional attributes here 4 | defenceUpdate(aimTurret, getTubeCooldown, fireTorpedo) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Enterprise/DefenseController.js: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js'; 2 | export default class YourDefenceController extends DefenceController { 3 | //Add additional attributes here 4 | defenceUpdate(aimTurret, getTubeCooldown, fireTorpedo) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/EventHorizon/DefenseController.js: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js'; 2 | export default class YourDefenceController extends DefenceController { 3 | //Add additional attributes here 4 | defenceUpdate(aimTurret, getTubeCooldown, fireTorpedo) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/FlyingDutchman/DefenseController.js: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js'; 2 | export default class YourDefenceController extends DefenceController { 3 | //Add additional attributes here 4 | defenceUpdate(aimTurret, getTubeCooldown, fireTorpedo) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/PillarOfAutumn/DefenseController.js: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js'; 2 | export default class YourDefenceController extends DefenceController { 3 | //Add additional attributes here 4 | defenceUpdate(aimTurret, getTubeCooldown, fireTorpedo) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/PlanetExpress/DefenseController.js: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js'; 2 | export default class YourDefenceController extends DefenceController { 3 | //Add additional attributes here 4 | defenceUpdate(aimTurret, getTubeCooldown, fireTorpedo) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Thunderbird3/DefenseController.js: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js'; 2 | export default class YourDefenceController extends DefenceController { 3 | //Add additional attributes here 4 | defenceUpdate(aimTurret, getTubeCooldown, fireTorpedo) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Bebop/NavigationController.js: -------------------------------------------------------------------------------- 1 | import NavigationController from '../../src/subsystems/navigationController.js'; 2 | export default class YourNavigationController extends NavigationController { 3 | //Add additional attributes here 4 | navigationUpdate(getShipStatus, warp, land, getMapData) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Bismark/NavigationController.js: -------------------------------------------------------------------------------- 1 | import NavigationController from '../../src/subsystems/navigationController.js'; 2 | export default class YourNavigationController extends NavigationController { 3 | //Add additional attributes here 4 | navigationUpdate(getShipStatus, warp, land, getMapData) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Milano/NavigationController.js: -------------------------------------------------------------------------------- 1 | import NavigationController from '../../src/subsystems/navigationController.js'; 2 | export default class YourNavigationController extends NavigationController { 3 | //Add additional attributes here 4 | navigationUpdate(getShipStatus, warp, land, getMapData) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Normandy/NavigationController.js: -------------------------------------------------------------------------------- 1 | import NavigationController from '../../src/subsystems/navigationController.js'; 2 | export default class YourNavigationController extends NavigationController { 3 | //Add additional attributes here 4 | navigationUpdate(getShipStatus, warp, land, getMapData) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Nostromo/NavigationController.js: -------------------------------------------------------------------------------- 1 | import NavigationController from '../../src/subsystems/navigationController.js'; 2 | export default class YourNavigationController extends NavigationController { 3 | //Add additional attributes here 4 | navigationUpdate(getShipStatus, warp, land, getMapData) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Rama/NavigationController.js: -------------------------------------------------------------------------------- 1 | import NavigationController from '../../src/subsystems/navigationController.js'; 2 | export default class YourNavigationController extends NavigationController { 3 | //Add additional attributes here 4 | navigationUpdate(getShipStatus, warp, land, getMapData) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/RedDwarf/NavigationController.js: -------------------------------------------------------------------------------- 1 | import NavigationController from '../../src/subsystems/navigationController.js'; 2 | export default class YourNavigationController extends NavigationController { 3 | //Add additional attributes here 4 | navigationUpdate(getShipStatus, warp, land, getMapData) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/SSAnne/NavigationController.js: -------------------------------------------------------------------------------- 1 | import NavigationController from '../../src/subsystems/navigationController.js'; 2 | export default class YourNavigationController extends NavigationController { 3 | //Add additional attributes here 4 | navigationUpdate(getShipStatus, warp, land, getMapData) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Serenity/NavigationController.js: -------------------------------------------------------------------------------- 1 | import NavigationController from '../../src/subsystems/navigationController.js'; 2 | export default class YourNavigationController extends NavigationController { 3 | //Add additional attributes here 4 | navigationUpdate(getShipStatus, warp, land, getMapData) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Yamato/NavigationController.js: -------------------------------------------------------------------------------- 1 | import NavigationController from '../../src/subsystems/navigationController.js'; 2 | export default class YourNavigationController extends NavigationController { 3 | //Add additional attributes here 4 | navigationUpdate(getShipStatus, warp, land, getMapData) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Enterprise/NavigationController.js: -------------------------------------------------------------------------------- 1 | import NavigationController from '../../src/subsystems/navigationController.js'; 2 | export default class YourNavigationController extends NavigationController { 3 | //Add additional attributes here 4 | navigationUpdate(getShipStatus, warp, land, getMapData) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/EventHorizon/NavigationController.js: -------------------------------------------------------------------------------- 1 | import NavigationController from '../../src/subsystems/navigationController.js'; 2 | export default class YourNavigationController extends NavigationController { 3 | //Add additional attributes here 4 | navigationUpdate(getShipStatus, warp, land, getMapData) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Galactica/NavigationController.js: -------------------------------------------------------------------------------- 1 | import NavigationController from '../../src/subsystems/navigationController.js'; 2 | export default class YourNavigationController extends NavigationController { 3 | //Add additional attributes here 4 | navigationUpdate(getShipStatus, warp, land, getMapData) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/PlanetExpress/NavigationController.js: -------------------------------------------------------------------------------- 1 | import NavigationController from '../../src/subsystems/navigationController.js'; 2 | export default class YourNavigationController extends NavigationController { 3 | //Add additional attributes here 4 | navigationUpdate(getShipStatus, warp, land, getMapData) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/Thunderbird3/NavigationController.js: -------------------------------------------------------------------------------- 1 | import NavigationController from '../../src/subsystems/navigationController.js'; 2 | export default class YourNavigationController extends NavigationController { 3 | //Add additional attributes here 4 | navigationUpdate(getShipStatus, warp, land, getMapData) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/FlyingDutchman/NavigationController.js: -------------------------------------------------------------------------------- 1 | import NavigationController from '../../src/subsystems/navigationController.js'; 2 | export default class YourNavigationController extends NavigationController { 3 | //Add additional attributes here 4 | navigationUpdate(getShipStatus, warp, land, getMapData) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /javascript/students/PillarOfAutumn/NavigationController.js: -------------------------------------------------------------------------------- 1 | import NavigationController from '../../src/subsystems/navigationController.js'; 2 | export default class YourNavigationController extends NavigationController { 3 | //Add additional attributes here 4 | navigationUpdate(getShipStatus, warp, land, getMapData) { 5 | //Student code goes here 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /typescript/src/helpers/Angles.ts: -------------------------------------------------------------------------------- 1 | export const withinPiRange = (angle: number) => { 2 | if (angle > Math.PI) angle += - 2 * Math.PI 3 | if (angle < -Math.PI) angle += 2 * Math.PI 4 | return angle 5 | } 6 | 7 | export const angleDiff = (a:number, b: number) => { 8 | a = withinPiRange(a) 9 | b = withinPiRange(b) 10 | if (a < b) return withinPiRange(2 * Math.PI - (b - a)) 11 | return withinPiRange(a - b) 12 | } -------------------------------------------------------------------------------- /typescript/src/ship/shipStatus.ts: -------------------------------------------------------------------------------- 1 | interface ShipStatus { 2 | radius: number 3 | angularVelocity: number 4 | angle: number 5 | positionX: number 6 | positionY: number 7 | linearVelocityX: number 8 | linearVelocityY: number 9 | thrusterPowerMain: number 10 | thrusterPowerBow: number 11 | thrusterPowerClockwise: number 12 | thrusterPowerCounterClockwise: number 13 | } 14 | 15 | export type { ShipStatus } 16 | -------------------------------------------------------------------------------- /javascript/src/helpers/Angles.js: -------------------------------------------------------------------------------- 1 | export const withinPiRange = (angle) => { 2 | if (angle > Math.PI) 3 | angle += -2 * Math.PI; 4 | if (angle < -Math.PI) 5 | angle += 2 * Math.PI; 6 | return angle; 7 | }; 8 | export const angleDiff = (a, b) => { 9 | a = withinPiRange(a); 10 | b = withinPiRange(b); 11 | if (a < b) 12 | return withinPiRange(2 * Math.PI - (b - a)); 13 | return withinPiRange(a - b); 14 | }; 15 | -------------------------------------------------------------------------------- /javascript/src/subsystems/propulsionController.js: -------------------------------------------------------------------------------- 1 | export default class PropulsionController { 2 | constructor() { 3 | this.initializeConnection = (defence, navigation, sensors) => { 4 | this.defence = defence; 5 | this.navigation = navigation; 6 | this.sensors = sensors; 7 | }; 8 | // @ts-ignore 9 | this.navigation = null; 10 | // @ts-ignore 11 | this.defence = null; 12 | // @ts-ignore 13 | this.sensors = null; 14 | } 15 | propulsionUpdate(setThruster) { } 16 | } 17 | -------------------------------------------------------------------------------- /javascript/src/subsystems/sensorsController.js: -------------------------------------------------------------------------------- 1 | export default class SensorsController { 2 | constructor() { 3 | this.initializeConnection = (defence, navigation, propulsion) => { 4 | this.defence = defence; 5 | this.propulsion = propulsion; 6 | this.navigation = navigation; 7 | }; 8 | // @ts-ignore 9 | this.navigation = null; 10 | // @ts-ignore 11 | this.defence = null; 12 | // @ts-ignore 13 | this.propulsion = null; 14 | } 15 | sensorsUpdate(activeScan, passiveScan) { } 16 | } 17 | -------------------------------------------------------------------------------- /javascript/src/subsystems/navigationController.js: -------------------------------------------------------------------------------- 1 | export default class NavigationController { 2 | constructor() { 3 | this.initializeConnection = (defence, propulsion, sensors) => { 4 | this.defence = defence; 5 | this.propulsion = propulsion; 6 | this.sensors = sensors; 7 | }; 8 | // @ts-ignore 9 | this.defence = null; 10 | // @ts-ignore 11 | this.propulsion = null; 12 | // @ts-ignore 13 | this.sensors = null; 14 | } 15 | navigationUpdate(getShipStatus, warp, land, getMapData) { } 16 | } 17 | -------------------------------------------------------------------------------- /javascript/src/subsystems/defenceController.js: -------------------------------------------------------------------------------- 1 | export default class DefenceController { 2 | constructor() { 3 | this.initializeConnection = (navigation, propulsion, sensors) => { 4 | this.navigation = navigation; 5 | this.propulsion = propulsion; 6 | this.sensors = sensors; 7 | }; 8 | // @ts-ignore 9 | this.navigation = null; 10 | // @ts-ignore 11 | this.propulsion = null; 12 | // @ts-ignore 13 | this.sensors = null; 14 | } 15 | defenceUpdate(aimTurret, getTubeCooldown, fireTorpedo) { } 16 | } 17 | -------------------------------------------------------------------------------- /javascript/src/ship/EMSReading.js: -------------------------------------------------------------------------------- 1 | export class EMSReading { 2 | constructor(angle, velocity, radius, distance, closeRangeData = undefined) { 3 | this.angle = angle; // The angle of the reading (relative to global X axis) //number 4 | this.velocity = velocity; // The velocity of the detected object relative to current solar system coordinate frame //Vector 5 | this.distance = distance; 6 | this.radius = radius; // The collision radius of the detected object //number 7 | if (distance < 100) { 8 | this.closeRange = closeRangeData; 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /typescript/src/helpers/pos.ts: -------------------------------------------------------------------------------- 1 | import Vector2 from "./Vector2"; 2 | 3 | const MapX = 720 4 | const MapY = 540 5 | 6 | export const outOfMap = (pos: Vector2): boolean => { 7 | return (pos.x < 0 || pos.x > MapX || pos.y < 0 || pos.y > MapY) 8 | } 9 | 10 | export const keepInMap = (pos: Vector2): boolean => { 11 | let inMap = true 12 | if (pos.y > MapY) { 13 | //y pos bounds 14 | pos.y = MapY 15 | inMap = false 16 | } else if (pos.y < 0) { 17 | pos.y = 0 18 | inMap = false 19 | } 20 | if (pos.x > MapX) { 21 | // x pos bounds 22 | pos.x = MapX 23 | inMap = false 24 | } else if (pos.x < 0) { 25 | pos.x = 0 26 | inMap = false 27 | } 28 | return !inMap 29 | } -------------------------------------------------------------------------------- /javascript/src/ship/mapData.js: -------------------------------------------------------------------------------- 1 | export const getMapData = (ship) => { 2 | ship.energyUsed += 10; 3 | const galaxy = ship.game.galaxy; 4 | if (galaxy === null) 5 | throw Error("No galaxy loaded"); 6 | return { 7 | solarSystemName: ship.solarSystem.name, 8 | galaxy: { 9 | name: galaxy.name, 10 | solarSystems: galaxy.solarSystems.map((solarSystem) => ({ 11 | name: solarSystem.name, 12 | warpGates: solarSystem.warpGates.map((warpGate) => warpGate.destinationSolarSystem), 13 | planets: solarSystem.planets.map((planet) => planet.name) 14 | })) 15 | } 16 | }; 17 | }; 18 | -------------------------------------------------------------------------------- /javascript/src/helpers/pos.js: -------------------------------------------------------------------------------- 1 | const MapX = 720; 2 | const MapY = 540; 3 | export const outOfMap = (pos) => { 4 | return (pos.x < 0 || pos.x > MapX || pos.y < 0 || pos.y > MapY); 5 | }; 6 | export const keepInMap = (pos) => { 7 | let inMap = true; 8 | if (pos.y > MapY) { 9 | //y pos bounds 10 | pos.y = MapY; 11 | inMap = false; 12 | } 13 | else if (pos.y < 0) { 14 | pos.y = 0; 15 | inMap = false; 16 | } 17 | if (pos.x > MapX) { 18 | // x pos bounds 19 | pos.x = MapX; 20 | inMap = false; 21 | } 22 | else if (pos.x < 0) { 23 | pos.x = 0; 24 | inMap = false; 25 | } 26 | return !inMap; 27 | }; 28 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "se101spaceship", 3 | "version": "1.0.0", 4 | "description": "Replacement for the SE101 Godot Spaceship System", 5 | "main": "src/index.js", 6 | "scripts": { 7 | "dev": "tsc --watch", 8 | "compile": "tsc;" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/zrwaite/SE101-Spaceship.git" 13 | }, 14 | "keywords": [], 15 | "author": "Zac Waite, Josiah Plett", 16 | "license": "ISC", 17 | "dependencies": { 18 | "typescript": "^4.6.4" 19 | }, 20 | "bugs": { 21 | "url": "https://github.com/zrwaite/SE101-Spaceship/issues" 22 | }, 23 | "homepage": "https://github.com/zrwaite/SE101-Spaceship#readme", 24 | "exclude": [ 25 | "node_modules" 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /javascript/src/helpers/Matrix2.js: -------------------------------------------------------------------------------- 1 | export default class Matrix2 { 2 | // constructs matrix based on 4 points 3 | constructor(x11, x12, x21, x22) { 4 | this.m = [[x11, x12], [x21, x22]]; 5 | } 6 | // construct matrix based on 2 vectors 7 | // used for basis vector calculations 8 | static MakeBasisMatrix(v1, v2) { 9 | return new Matrix2(v1.x, v2.x, v1.y, v2.y); 10 | } 11 | // computes the inverse of a matrix 12 | inverse() { 13 | const determinant = 1 / (this.m[0][0] * this.m[1][1] - this.m[0][1] * this.m[1][0]); 14 | return new Matrix2(this.m[1][1] * determinant, this.m[0][1] * determinant * -1, this.m[1][0] * determinant * -1, this.m[0][0] * determinant); 15 | } 16 | } 17 | Matrix2.Rotate90CCW = new Matrix2(0, -1, 1, 0); 18 | -------------------------------------------------------------------------------- /javascript/src/galaxies/noob.js: -------------------------------------------------------------------------------- 1 | import { V2 } from '../helpers/Vector2.js'; 2 | import Asteroid from '../spaceObjects/asteroid.js'; 3 | import Planet from '../spaceObjects/planet.js'; 4 | import Galaxy from './galaxy.js'; 5 | import SolarSystem from './solarSystem.js'; 6 | export const BuildNoob = (game) => { 7 | const Tutorial = new SolarSystem('Tutorial', 'Noob', game, { 8 | asteroids: [ 9 | new Asteroid(V2(-0.5, -0.15), V2(300, 90), game), 10 | new Asteroid(V2(0, 0), V2(526, 392), game) 11 | ], 12 | planets: [new Planet('Big Bird', 35, V2(576, 432), game)], 13 | }); 14 | console.log(`Welcome to the tutorial - your goal is to find the planet and land on it. 15 | Avoid any asteroids that get in the way if you can. 16 | Good luck!`); 17 | return new Galaxy('Noob', game, [Tutorial]); 18 | }; 19 | -------------------------------------------------------------------------------- /javascript/src/spaceObjects/blackhole.js: -------------------------------------------------------------------------------- 1 | import Vector2 from '../helpers/Vector2.js'; 2 | import Sprite from '../sprite.js'; 3 | export default class BlackHole extends Sprite { 4 | constructor(...args) { 5 | super(...args); 6 | this.ctx = 'planets'; 7 | this.radius = 40 + (Math.random() - 0.5) * 5; 8 | this.orbitingPlanets = []; 9 | /* Other attributes */ 10 | this.process = null; 11 | this.image = this.game.images['blackhole']; 12 | this.mass = Infinity; 13 | this.calcSize(); 14 | } 15 | initialize(process) { 16 | this.process = process; 17 | } 18 | calcSize() { 19 | this.size = new Vector2(this.radius * 3, this.radius * 3); 20 | } 21 | addPlanet(planet) { 22 | this.orbitingPlanets.push(planet); 23 | } 24 | update() { 25 | if (!this.process) 26 | return; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /typescript/src/galaxies/noob.ts: -------------------------------------------------------------------------------- 1 | import Game from '../game.js' 2 | import { V2 } from '../helpers/Vector2.js' 3 | import Asteroid from '../spaceObjects/asteroid.js' 4 | import AsteroidLauncher from '../spaceObjects/asteroidLauncher.js' 5 | import Planet from '../spaceObjects/planet.js' 6 | import Galaxy from './galaxy.js' 7 | import SolarSystem from './solarSystem.js' 8 | 9 | export const BuildNoob = (game: Game): Galaxy => { 10 | const Tutorial = new SolarSystem('Tutorial', 'Noob', game, { 11 | asteroids: [ 12 | new Asteroid(V2(-0.5, -0.15), V2(300, 90), game), 13 | new Asteroid(V2(0, 0), V2(526, 392), game) 14 | ], 15 | planets: [new Planet('Big Bird', 35, V2(576, 432), game)], 16 | }) 17 | console.log(`Welcome to the tutorial - your goal is to find the planet and land on it. 18 | Avoid any asteroids that get in the way if you can. 19 | Good luck!`) 20 | return new Galaxy('Noob', game, [Tutorial]) 21 | } 22 | -------------------------------------------------------------------------------- /typescript/students/Bebop/DefenseController.ts: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js' 2 | import { Vector2, withinPiRange, angleDiff } from '../helpers.js' 3 | import YourNavigationController from './NavigationController.js' 4 | import YourPropulsionController from './PropulsionController.js' 5 | import YourSensorsController from './SensorsController.js' 6 | export default class YourDefenceController extends DefenceController { 7 | // To get other subsystem information, use the attributes below. 8 | // @ts-ignore 9 | navigation: YourNavigationController // @ts-ignore 10 | sensors: YourSensorsController // @ts-ignore 11 | propulsion: YourPropulsionController 12 | //Add additional attributes here 13 | defenceUpdate(aimTurret: (angle: number) => void, getTubeCooldown: (i: number) => number | Error, fireTorpedo: (i: number) => Error | null) { 14 | //Student code goes here 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /typescript/students/Bebop/PropulsionController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2, withinPiRange } from '../helpers.js' 2 | import { ThrusterName } from '../types.js' 3 | import PropulsionController from '../../src/subsystems/propulsionController.js' 4 | import YourDefenceController from './DefenseController.js' 5 | import YourNavigationController from './NavigationController.js' 6 | import YourSensorsController from './SensorsController.js' 7 | export default class YourPropulsionController extends PropulsionController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | sensors: YourSensorsController // @ts-ignore 12 | navigation: YourNavigationController 13 | 14 | //Add additional attributes here 15 | 16 | propulsionUpdate(setThruster: (thruster: ThrusterName, power: number) => Error | null) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/Bismark/PropulsionController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2, withinPiRange } from '../helpers.js' 2 | import { ThrusterName } from '../types.js' 3 | import PropulsionController from '../../src/subsystems/propulsionController.js' 4 | import YourDefenceController from './DefenseController.js' 5 | import YourNavigationController from './NavigationController.js' 6 | import YourSensorsController from './SensorsController.js' 7 | export default class YourPropulsionController extends PropulsionController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | sensors: YourSensorsController // @ts-ignore 12 | navigation: YourNavigationController 13 | 14 | //Add additional attributes here 15 | 16 | propulsionUpdate(setThruster: (thruster: ThrusterName, power: number) => Error | null) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/Milano/PropulsionController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2, withinPiRange } from '../helpers.js' 2 | import { ThrusterName } from '../types.js' 3 | import PropulsionController from '../../src/subsystems/propulsionController.js' 4 | import YourDefenceController from './DefenseController.js' 5 | import YourNavigationController from './NavigationController.js' 6 | import YourSensorsController from './SensorsController.js' 7 | export default class YourPropulsionController extends PropulsionController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | sensors: YourSensorsController // @ts-ignore 12 | navigation: YourNavigationController 13 | 14 | //Add additional attributes here 15 | 16 | propulsionUpdate(setThruster: (thruster: ThrusterName, power: number) => Error | null) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/Rama/PropulsionController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2, withinPiRange } from '../helpers.js' 2 | import { ThrusterName } from '../types.js' 3 | import PropulsionController from '../../src/subsystems/propulsionController.js' 4 | import YourDefenceController from './DefenseController.js' 5 | import YourNavigationController from './NavigationController.js' 6 | import YourSensorsController from './SensorsController.js' 7 | export default class YourPropulsionController extends PropulsionController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | sensors: YourSensorsController // @ts-ignore 12 | navigation: YourNavigationController 13 | 14 | //Add additional attributes here 15 | 16 | propulsionUpdate(setThruster: (thruster: ThrusterName, power: number) => Error | null) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/SSAnne/PropulsionController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2, withinPiRange } from '../helpers.js' 2 | import { ThrusterName } from '../types.js' 3 | import PropulsionController from '../../src/subsystems/propulsionController.js' 4 | import YourDefenceController from './DefenseController.js' 5 | import YourNavigationController from './NavigationController.js' 6 | import YourSensorsController from './SensorsController.js' 7 | export default class YourPropulsionController extends PropulsionController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | sensors: YourSensorsController // @ts-ignore 12 | navigation: YourNavigationController 13 | 14 | //Add additional attributes here 15 | 16 | propulsionUpdate(setThruster: (thruster: ThrusterName, power: number) => Error | null) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/Yamato/PropulsionController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2, withinPiRange } from '../helpers.js' 2 | import { ThrusterName } from '../types.js' 3 | import PropulsionController from '../../src/subsystems/propulsionController.js' 4 | import YourDefenceController from './DefenseController.js' 5 | import YourNavigationController from './NavigationController.js' 6 | import YourSensorsController from './SensorsController.js' 7 | export default class YourPropulsionController extends PropulsionController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | sensors: YourSensorsController // @ts-ignore 12 | navigation: YourNavigationController 13 | 14 | //Add additional attributes here 15 | 16 | propulsionUpdate(setThruster: (thruster: ThrusterName, power: number) => Error | null) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/Enterprise/PropulsionController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2, withinPiRange } from '../helpers.js' 2 | import { ThrusterName } from '../types.js' 3 | import PropulsionController from '../../src/subsystems/propulsionController.js' 4 | import YourDefenceController from './DefenseController.js' 5 | import YourNavigationController from './NavigationController.js' 6 | import YourSensorsController from './SensorsController.js' 7 | export default class YourPropulsionController extends PropulsionController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | sensors: YourSensorsController // @ts-ignore 12 | navigation: YourNavigationController 13 | 14 | //Add additional attributes here 15 | 16 | propulsionUpdate(setThruster: (thruster: ThrusterName, power: number) => Error | null) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/EventHorizon/PropulsionController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2, withinPiRange } from '../helpers.js' 2 | import { ThrusterName } from '../types.js' 3 | import PropulsionController from '../../src/subsystems/propulsionController.js' 4 | import YourDefenceController from './DefenseController.js' 5 | import YourNavigationController from './NavigationController.js' 6 | import YourSensorsController from './SensorsController.js' 7 | export default class YourPropulsionController extends PropulsionController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | sensors: YourSensorsController // @ts-ignore 12 | navigation: YourNavigationController 13 | 14 | //Add additional attributes here 15 | 16 | propulsionUpdate(setThruster: (thruster: ThrusterName, power: number) => Error | null) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/Galactica/PropulsionController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2, withinPiRange } from '../helpers.js' 2 | import { ThrusterName } from '../types.js' 3 | import PropulsionController from '../../src/subsystems/propulsionController.js' 4 | import YourDefenceController from './DefenseController.js' 5 | import YourNavigationController from './NavigationController.js' 6 | import YourSensorsController from './SensorsController.js' 7 | export default class YourPropulsionController extends PropulsionController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | sensors: YourSensorsController // @ts-ignore 12 | navigation: YourNavigationController 13 | 14 | //Add additional attributes here 15 | 16 | propulsionUpdate(setThruster: (thruster: ThrusterName, power: number) => Error | null) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/Normandy/PropulsionController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2, withinPiRange } from '../helpers.js' 2 | import { ThrusterName } from '../types.js' 3 | import PropulsionController from '../../src/subsystems/propulsionController.js' 4 | import YourDefenceController from './DefenseController.js' 5 | import YourNavigationController from './NavigationController.js' 6 | import YourSensorsController from './SensorsController.js' 7 | export default class YourPropulsionController extends PropulsionController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | sensors: YourSensorsController // @ts-ignore 12 | navigation: YourNavigationController 13 | 14 | //Add additional attributes here 15 | 16 | propulsionUpdate(setThruster: (thruster: ThrusterName, power: number) => Error | null) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/Nostromo/PropulsionController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2, withinPiRange } from '../helpers.js' 2 | import { ThrusterName } from '../types.js' 3 | import PropulsionController from '../../src/subsystems/propulsionController.js' 4 | import YourDefenceController from './DefenseController.js' 5 | import YourNavigationController from './NavigationController.js' 6 | import YourSensorsController from './SensorsController.js' 7 | export default class YourPropulsionController extends PropulsionController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | sensors: YourSensorsController // @ts-ignore 12 | navigation: YourNavigationController 13 | 14 | //Add additional attributes here 15 | 16 | propulsionUpdate(setThruster: (thruster: ThrusterName, power: number) => Error | null) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/RedDwarf/PropulsionController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2, withinPiRange } from '../helpers.js' 2 | import { ThrusterName } from '../types.js' 3 | import PropulsionController from '../../src/subsystems/propulsionController.js' 4 | import YourDefenceController from './DefenseController.js' 5 | import YourNavigationController from './NavigationController.js' 6 | import YourSensorsController from './SensorsController.js' 7 | export default class YourPropulsionController extends PropulsionController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | sensors: YourSensorsController // @ts-ignore 12 | navigation: YourNavigationController 13 | 14 | //Add additional attributes here 15 | 16 | propulsionUpdate(setThruster: (thruster: ThrusterName, power: number) => Error | null) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/Serenity/PropulsionController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2, withinPiRange } from '../helpers.js' 2 | import { ThrusterName } from '../types.js' 3 | import PropulsionController from '../../src/subsystems/propulsionController.js' 4 | import YourDefenceController from './DefenseController.js' 5 | import YourNavigationController from './NavigationController.js' 6 | import YourSensorsController from './SensorsController.js' 7 | export default class YourPropulsionController extends PropulsionController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | sensors: YourSensorsController // @ts-ignore 12 | navigation: YourNavigationController 13 | 14 | //Add additional attributes here 15 | 16 | propulsionUpdate(setThruster: (thruster: ThrusterName, power: number) => Error | null) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/Thunderbird3/PropulsionController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2, withinPiRange } from '../helpers.js' 2 | import { ThrusterName } from '../types.js' 3 | import PropulsionController from '../../src/subsystems/propulsionController.js' 4 | import YourDefenceController from './DefenseController.js' 5 | import YourNavigationController from './NavigationController.js' 6 | import YourSensorsController from './SensorsController.js' 7 | export default class YourPropulsionController extends PropulsionController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | sensors: YourSensorsController // @ts-ignore 12 | navigation: YourNavigationController 13 | 14 | //Add additional attributes here 15 | 16 | propulsionUpdate(setThruster: (thruster: ThrusterName, power: number) => Error | null) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/FlyingDutchman/PropulsionController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2, withinPiRange } from '../helpers.js' 2 | import { ThrusterName } from '../types.js' 3 | import PropulsionController from '../../src/subsystems/propulsionController.js' 4 | import YourDefenceController from './DefenseController.js' 5 | import YourNavigationController from './NavigationController.js' 6 | import YourSensorsController from './SensorsController.js' 7 | export default class YourPropulsionController extends PropulsionController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | sensors: YourSensorsController // @ts-ignore 12 | navigation: YourNavigationController 13 | 14 | //Add additional attributes here 15 | 16 | propulsionUpdate(setThruster: (thruster: ThrusterName, power: number) => Error | null) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/PillarOfAutumn/PropulsionController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2, withinPiRange } from '../helpers.js' 2 | import { ThrusterName } from '../types.js' 3 | import PropulsionController from '../../src/subsystems/propulsionController.js' 4 | import YourDefenceController from './DefenseController.js' 5 | import YourNavigationController from './NavigationController.js' 6 | import YourSensorsController from './SensorsController.js' 7 | export default class YourPropulsionController extends PropulsionController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | sensors: YourSensorsController // @ts-ignore 12 | navigation: YourNavigationController 13 | 14 | //Add additional attributes here 15 | 16 | propulsionUpdate(setThruster: (thruster: ThrusterName, power: number) => Error | null) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/PlanetExpress/PropulsionController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2, withinPiRange } from '../helpers.js' 2 | import { ThrusterName } from '../types.js' 3 | import PropulsionController from '../../src/subsystems/propulsionController.js' 4 | import YourDefenceController from './DefenseController.js' 5 | import YourNavigationController from './NavigationController.js' 6 | import YourSensorsController from './SensorsController.js' 7 | export default class YourPropulsionController extends PropulsionController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | sensors: YourSensorsController // @ts-ignore 12 | navigation: YourNavigationController 13 | 14 | //Add additional attributes here 15 | 16 | propulsionUpdate(setThruster: (thruster: ThrusterName, power: number) => Error | null) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/Bismark/DefenseController.ts: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js' 2 | import { Vector2, withinPiRange, angleDiff } from '../helpers.js' 3 | import YourNavigationController from './NavigationController.js' 4 | import YourPropulsionController from './PropulsionController.js' 5 | import YourSensorsController from './SensorsController.js' 6 | export default class YourDefenceController extends DefenceController { 7 | // To get other subsystem information, use the attributes below. 8 | // @ts-ignore 9 | navigation: YourNavigationController // @ts-ignore 10 | sensors: YourSensorsController // @ts-ignore 11 | propulsion: YourPropulsionController 12 | //Add additional attributes here 13 | 14 | defenceUpdate(aimTurret: (angle: number) => void, getTubeCooldown: (i: number) => number | Error, fireTorpedo: (i: number) => Error | null) { 15 | 16 | //Student code goes here 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /typescript/students/Milano/DefenseController.ts: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js' 2 | import { Vector2, withinPiRange, angleDiff } from '../helpers.js' 3 | import YourNavigationController from './NavigationController.js' 4 | import YourPropulsionController from './PropulsionController.js' 5 | import YourSensorsController from './SensorsController.js' 6 | export default class YourDefenceController extends DefenceController { 7 | // To get other subsystem information, use the attributes below. 8 | // @ts-ignore 9 | navigation: YourNavigationController // @ts-ignore 10 | sensors: YourSensorsController // @ts-ignore 11 | propulsion: YourPropulsionController 12 | //Add additional attributes here 13 | 14 | defenceUpdate(aimTurret: (angle: number) => void, getTubeCooldown: (i: number) => number | Error, fireTorpedo: (i: number) => Error | null) { 15 | 16 | //Student code goes here 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /typescript/students/Normandy/DefenseController.ts: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js' 2 | import { Vector2, withinPiRange, angleDiff } from '../helpers.js' 3 | import YourNavigationController from './NavigationController.js' 4 | import YourPropulsionController from './PropulsionController.js' 5 | import YourSensorsController from './SensorsController.js' 6 | export default class YourDefenceController extends DefenceController { 7 | // To get other subsystem information, use the attributes below. 8 | // @ts-ignore 9 | navigation: YourNavigationController // @ts-ignore 10 | sensors: YourSensorsController // @ts-ignore 11 | propulsion: YourPropulsionController 12 | //Add additional attributes here 13 | 14 | defenceUpdate(aimTurret: (angle: number) => void, getTubeCooldown: (i: number) => number | Error, fireTorpedo: (i: number) => Error | null) { 15 | 16 | //Student code goes here 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /typescript/students/Nostromo/DefenseController.ts: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js' 2 | import { Vector2, withinPiRange, angleDiff } from '../helpers.js' 3 | import YourNavigationController from './NavigationController.js' 4 | import YourPropulsionController from './PropulsionController.js' 5 | import YourSensorsController from './SensorsController.js' 6 | export default class YourDefenceController extends DefenceController { 7 | // To get other subsystem information, use the attributes below. 8 | // @ts-ignore 9 | navigation: YourNavigationController // @ts-ignore 10 | sensors: YourSensorsController // @ts-ignore 11 | propulsion: YourPropulsionController 12 | //Add additional attributes here 13 | 14 | defenceUpdate(aimTurret: (angle: number) => void, getTubeCooldown: (i: number) => number | Error, fireTorpedo: (i: number) => Error | null) { 15 | 16 | //Student code goes here 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /typescript/students/Rama/DefenseController.ts: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js' 2 | import { Vector2, withinPiRange, angleDiff } from '../helpers.js' 3 | import YourNavigationController from './NavigationController.js' 4 | import YourPropulsionController from './PropulsionController.js' 5 | import YourSensorsController from './SensorsController.js' 6 | export default class YourDefenceController extends DefenceController { 7 | // To get other subsystem information, use the attributes below. 8 | // @ts-ignore 9 | navigation: YourNavigationController // @ts-ignore 10 | sensors: YourSensorsController // @ts-ignore 11 | propulsion: YourPropulsionController 12 | //Add additional attributes here 13 | 14 | defenceUpdate(aimTurret: (angle: number) => void, getTubeCooldown: (i: number) => number | Error, fireTorpedo: (i: number) => Error | null) { 15 | 16 | //Student code goes here 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /typescript/students/RedDwarf/DefenseController.ts: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js' 2 | import { Vector2, withinPiRange, angleDiff } from '../helpers.js' 3 | import YourNavigationController from './NavigationController.js' 4 | import YourPropulsionController from './PropulsionController.js' 5 | import YourSensorsController from './SensorsController.js' 6 | export default class YourDefenceController extends DefenceController { 7 | // To get other subsystem information, use the attributes below. 8 | // @ts-ignore 9 | navigation: YourNavigationController // @ts-ignore 10 | sensors: YourSensorsController // @ts-ignore 11 | propulsion: YourPropulsionController 12 | //Add additional attributes here 13 | 14 | defenceUpdate(aimTurret: (angle: number) => void, getTubeCooldown: (i: number) => number | Error, fireTorpedo: (i: number) => Error | null) { 15 | 16 | //Student code goes here 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /typescript/students/SSAnne/DefenseController.ts: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js' 2 | import { Vector2, withinPiRange, angleDiff } from '../helpers.js' 3 | import YourNavigationController from './NavigationController.js' 4 | import YourPropulsionController from './PropulsionController.js' 5 | import YourSensorsController from './SensorsController.js' 6 | export default class YourDefenceController extends DefenceController { 7 | // To get other subsystem information, use the attributes below. 8 | // @ts-ignore 9 | navigation: YourNavigationController // @ts-ignore 10 | sensors: YourSensorsController // @ts-ignore 11 | propulsion: YourPropulsionController 12 | //Add additional attributes here 13 | 14 | defenceUpdate(aimTurret: (angle: number) => void, getTubeCooldown: (i: number) => number | Error, fireTorpedo: (i: number) => Error | null) { 15 | 16 | //Student code goes here 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /typescript/students/Serenity/DefenseController.ts: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js' 2 | import { Vector2, withinPiRange, angleDiff } from '../helpers.js' 3 | import YourNavigationController from './NavigationController.js' 4 | import YourPropulsionController from './PropulsionController.js' 5 | import YourSensorsController from './SensorsController.js' 6 | export default class YourDefenceController extends DefenceController { 7 | // To get other subsystem information, use the attributes below. 8 | // @ts-ignore 9 | navigation: YourNavigationController // @ts-ignore 10 | sensors: YourSensorsController // @ts-ignore 11 | propulsion: YourPropulsionController 12 | //Add additional attributes here 13 | 14 | defenceUpdate(aimTurret: (angle: number) => void, getTubeCooldown: (i: number) => number | Error, fireTorpedo: (i: number) => Error | null) { 15 | 16 | //Student code goes here 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /typescript/students/Yamato/DefenseController.ts: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js' 2 | import { Vector2, withinPiRange, angleDiff } from '../helpers.js' 3 | import YourNavigationController from './NavigationController.js' 4 | import YourPropulsionController from './PropulsionController.js' 5 | import YourSensorsController from './SensorsController.js' 6 | export default class YourDefenceController extends DefenceController { 7 | // To get other subsystem information, use the attributes below. 8 | // @ts-ignore 9 | navigation: YourNavigationController // @ts-ignore 10 | sensors: YourSensorsController // @ts-ignore 11 | propulsion: YourPropulsionController 12 | //Add additional attributes here 13 | 14 | defenceUpdate(aimTurret: (angle: number) => void, getTubeCooldown: (i: number) => number | Error, fireTorpedo: (i: number) => Error | null) { 15 | 16 | //Student code goes here 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /typescript/students/Enterprise/DefenseController.ts: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js' 2 | import { Vector2, withinPiRange, angleDiff } from '../helpers.js' 3 | import YourNavigationController from './NavigationController.js' 4 | import YourPropulsionController from './PropulsionController.js' 5 | import YourSensorsController from './SensorsController.js' 6 | export default class YourDefenceController extends DefenceController { 7 | // To get other subsystem information, use the attributes below. 8 | // @ts-ignore 9 | navigation: YourNavigationController // @ts-ignore 10 | sensors: YourSensorsController // @ts-ignore 11 | propulsion: YourPropulsionController 12 | //Add additional attributes here 13 | 14 | defenceUpdate(aimTurret: (angle: number) => void, getTubeCooldown: (i: number) => number | Error, fireTorpedo: (i: number) => Error | null) { 15 | 16 | //Student code goes here 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /typescript/students/EventHorizon/DefenseController.ts: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js' 2 | import { Vector2, withinPiRange, angleDiff } from '../helpers.js' 3 | import YourNavigationController from './NavigationController.js' 4 | import YourPropulsionController from './PropulsionController.js' 5 | import YourSensorsController from './SensorsController.js' 6 | export default class YourDefenceController extends DefenceController { 7 | // To get other subsystem information, use the attributes below. 8 | // @ts-ignore 9 | navigation: YourNavigationController // @ts-ignore 10 | sensors: YourSensorsController // @ts-ignore 11 | propulsion: YourPropulsionController 12 | //Add additional attributes here 13 | 14 | defenceUpdate(aimTurret: (angle: number) => void, getTubeCooldown: (i: number) => number | Error, fireTorpedo: (i: number) => Error | null) { 15 | 16 | //Student code goes here 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /typescript/students/Galactica/DefenseController.ts: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js' 2 | import { Vector2, withinPiRange, angleDiff } from '../helpers.js' 3 | import YourNavigationController from './NavigationController.js' 4 | import YourPropulsionController from './PropulsionController.js' 5 | import YourSensorsController from './SensorsController.js' 6 | export default class YourDefenceController extends DefenceController { 7 | // To get other subsystem information, use the attributes below. 8 | // @ts-ignore 9 | navigation: YourNavigationController // @ts-ignore 10 | sensors: YourSensorsController // @ts-ignore 11 | propulsion: YourPropulsionController 12 | //Add additional attributes here 13 | 14 | defenceUpdate(aimTurret: (angle: number) => void, getTubeCooldown: (i: number) => number | Error, fireTorpedo: (i: number) => Error | null) { 15 | 16 | //Student code goes here 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /typescript/students/PlanetExpress/DefenseController.ts: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js' 2 | import { Vector2, withinPiRange, angleDiff } from '../helpers.js' 3 | import YourNavigationController from './NavigationController.js' 4 | import YourPropulsionController from './PropulsionController.js' 5 | import YourSensorsController from './SensorsController.js' 6 | export default class YourDefenceController extends DefenceController { 7 | // To get other subsystem information, use the attributes below. 8 | // @ts-ignore 9 | navigation: YourNavigationController // @ts-ignore 10 | sensors: YourSensorsController // @ts-ignore 11 | propulsion: YourPropulsionController 12 | //Add additional attributes here 13 | 14 | defenceUpdate(aimTurret: (angle: number) => void, getTubeCooldown: (i: number) => number | Error, fireTorpedo: (i: number) => Error | null) { 15 | 16 | //Student code goes here 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /typescript/students/Thunderbird3/DefenseController.ts: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js' 2 | import { Vector2, withinPiRange, angleDiff } from '../helpers.js' 3 | import YourNavigationController from './NavigationController.js' 4 | import YourPropulsionController from './PropulsionController.js' 5 | import YourSensorsController from './SensorsController.js' 6 | export default class YourDefenceController extends DefenceController { 7 | // To get other subsystem information, use the attributes below. 8 | // @ts-ignore 9 | navigation: YourNavigationController // @ts-ignore 10 | sensors: YourSensorsController // @ts-ignore 11 | propulsion: YourPropulsionController 12 | //Add additional attributes here 13 | 14 | defenceUpdate(aimTurret: (angle: number) => void, getTubeCooldown: (i: number) => number | Error, fireTorpedo: (i: number) => Error | null) { 15 | 16 | //Student code goes here 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /typescript/students/FlyingDutchman/DefenseController.ts: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js' 2 | import { Vector2, withinPiRange, angleDiff } from '../helpers.js' 3 | import YourNavigationController from './NavigationController.js' 4 | import YourPropulsionController from './PropulsionController.js' 5 | import YourSensorsController from './SensorsController.js' 6 | export default class YourDefenceController extends DefenceController { 7 | // To get other subsystem information, use the attributes below. 8 | // @ts-ignore 9 | navigation: YourNavigationController // @ts-ignore 10 | sensors: YourSensorsController // @ts-ignore 11 | propulsion: YourPropulsionController 12 | //Add additional attributes here 13 | 14 | defenceUpdate(aimTurret: (angle: number) => void, getTubeCooldown: (i: number) => number | Error, fireTorpedo: (i: number) => Error | null) { 15 | 16 | //Student code goes here 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /typescript/students/PillarOfAutumn/DefenseController.ts: -------------------------------------------------------------------------------- 1 | import DefenceController from '../../src/subsystems/defenceController.js' 2 | import { Vector2, withinPiRange, angleDiff } from '../helpers.js' 3 | import YourNavigationController from './NavigationController.js' 4 | import YourPropulsionController from './PropulsionController.js' 5 | import YourSensorsController from './SensorsController.js' 6 | export default class YourDefenceController extends DefenceController { 7 | // To get other subsystem information, use the attributes below. 8 | // @ts-ignore 9 | navigation: YourNavigationController // @ts-ignore 10 | sensors: YourSensorsController // @ts-ignore 11 | propulsion: YourPropulsionController 12 | //Add additional attributes here 13 | 14 | defenceUpdate(aimTurret: (angle: number) => void, getTubeCooldown: (i: number) => number | Error, fireTorpedo: (i: number) => Error | null) { 15 | 16 | //Student code goes here 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /typescript/src/helpers/Matrix2.ts: -------------------------------------------------------------------------------- 1 | import Vector2 from "./Vector2"; 2 | 3 | export default class Matrix2 { 4 | m: [[number, number], [number, number]]; 5 | // constructs matrix based on 4 points 6 | constructor(x11:number, x12:number, x21:number, x22:number) { 7 | this.m = [[x11, x12],[x21, x22]]; 8 | } 9 | 10 | // construct matrix based on 2 vectors 11 | // used for basis vector calculations 12 | static MakeBasisMatrix(v1:Vector2, v2:Vector2) { 13 | return new Matrix2(v1.x, v2.x, v1.y, v2.y); 14 | } 15 | 16 | static Rotate90CCW = new Matrix2(0, -1, 1, 0); 17 | 18 | // computes the inverse of a matrix 19 | inverse() { 20 | const determinant = 1/(this.m[0][0]*this.m[1][1]-this.m[0][1]*this.m[1][0]) 21 | return new Matrix2( 22 | this.m[1][1]*determinant, 23 | this.m[0][1]*determinant*-1, 24 | this.m[1][0]*determinant*-1, 25 | this.m[0][0]*determinant, 26 | ); 27 | } 28 | } -------------------------------------------------------------------------------- /typescript/students/Bebop/NavigationController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2 } from '../helpers.js' 2 | import { MapData, ShipStatus} from '../types.js' 3 | 4 | import NavigationController from '../../src/subsystems/navigationController.js' 5 | import YourDefenceController from './DefenseController.js' 6 | import YourPropulsionController from './PropulsionController.js' 7 | import YourSensorsController from './SensorsController.js' 8 | 9 | export default class YourNavigationController extends NavigationController { 10 | // To get other subsystem information, use the attributes below. 11 | // @ts-ignore 12 | defence: YourDefenceController // @ts-ignore 13 | sensors: YourSensorsController // @ts-ignore 14 | propulsion: YourPropulsionController 15 | 16 | //Add additional attributes here 17 | 18 | navigationUpdate(getShipStatus: (key: keyof ShipStatus) => number, warp: () => Error|null, land: () => Error|null, getMapData: () => MapData) { 19 | //Student code goes here 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /typescript/students/Bismark/NavigationController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2 } from '../helpers.js' 2 | import { MapData, ShipStatus} from '../types.js' 3 | 4 | import NavigationController from '../../src/subsystems/navigationController.js' 5 | import YourDefenceController from './DefenseController.js' 6 | import YourPropulsionController from './PropulsionController.js' 7 | import YourSensorsController from './SensorsController.js' 8 | 9 | export default class YourNavigationController extends NavigationController { 10 | // To get other subsystem information, use the attributes below. 11 | // @ts-ignore 12 | defence: YourDefenceController // @ts-ignore 13 | sensors: YourSensorsController // @ts-ignore 14 | propulsion: YourPropulsionController 15 | 16 | //Add additional attributes here 17 | 18 | navigationUpdate(getShipStatus: (key: keyof ShipStatus) => number, warp: () => Error|null, land: () => Error|null, getMapData: () => MapData) { 19 | //Student code goes here 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /typescript/students/Milano/NavigationController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2 } from '../helpers.js' 2 | import { MapData, ShipStatus} from '../types.js' 3 | 4 | import NavigationController from '../../src/subsystems/navigationController.js' 5 | import YourDefenceController from './DefenseController.js' 6 | import YourPropulsionController from './PropulsionController.js' 7 | import YourSensorsController from './SensorsController.js' 8 | 9 | export default class YourNavigationController extends NavigationController { 10 | // To get other subsystem information, use the attributes below. 11 | // @ts-ignore 12 | defence: YourDefenceController // @ts-ignore 13 | sensors: YourSensorsController // @ts-ignore 14 | propulsion: YourPropulsionController 15 | 16 | //Add additional attributes here 17 | 18 | navigationUpdate(getShipStatus: (key: keyof ShipStatus) => number, warp: () => Error|null, land: () => Error|null, getMapData: () => MapData) { 19 | //Student code goes here 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /typescript/students/Rama/NavigationController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2 } from '../helpers.js' 2 | import { MapData, ShipStatus} from '../types.js' 3 | 4 | import NavigationController from '../../src/subsystems/navigationController.js' 5 | import YourDefenceController from './DefenseController.js' 6 | import YourPropulsionController from './PropulsionController.js' 7 | import YourSensorsController from './SensorsController.js' 8 | 9 | export default class YourNavigationController extends NavigationController { 10 | // To get other subsystem information, use the attributes below. 11 | // @ts-ignore 12 | defence: YourDefenceController // @ts-ignore 13 | sensors: YourSensorsController // @ts-ignore 14 | propulsion: YourPropulsionController 15 | 16 | //Add additional attributes here 17 | 18 | navigationUpdate(getShipStatus: (key: keyof ShipStatus) => number, warp: () => Error|null, land: () => Error|null, getMapData: () => MapData) { 19 | //Student code goes here 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /typescript/students/SSAnne/NavigationController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2 } from '../helpers.js' 2 | import { MapData, ShipStatus} from '../types.js' 3 | 4 | import NavigationController from '../../src/subsystems/navigationController.js' 5 | import YourDefenceController from './DefenseController.js' 6 | import YourPropulsionController from './PropulsionController.js' 7 | import YourSensorsController from './SensorsController.js' 8 | 9 | export default class YourNavigationController extends NavigationController { 10 | // To get other subsystem information, use the attributes below. 11 | // @ts-ignore 12 | defence: YourDefenceController // @ts-ignore 13 | sensors: YourSensorsController // @ts-ignore 14 | propulsion: YourPropulsionController 15 | 16 | //Add additional attributes here 17 | 18 | navigationUpdate(getShipStatus: (key: keyof ShipStatus) => number, warp: () => Error|null, land: () => Error|null, getMapData: () => MapData) { 19 | //Student code goes here 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /typescript/students/Yamato/NavigationController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2 } from '../helpers.js' 2 | import { MapData, ShipStatus} from '../types.js' 3 | 4 | import NavigationController from '../../src/subsystems/navigationController.js' 5 | import YourDefenceController from './DefenseController.js' 6 | import YourPropulsionController from './PropulsionController.js' 7 | import YourSensorsController from './SensorsController.js' 8 | 9 | export default class YourNavigationController extends NavigationController { 10 | // To get other subsystem information, use the attributes below. 11 | // @ts-ignore 12 | defence: YourDefenceController // @ts-ignore 13 | sensors: YourSensorsController // @ts-ignore 14 | propulsion: YourPropulsionController 15 | 16 | //Add additional attributes here 17 | 18 | navigationUpdate(getShipStatus: (key: keyof ShipStatus) => number, warp: () => Error|null, land: () => Error|null, getMapData: () => MapData) { 19 | //Student code goes here 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /typescript/students/Bebop/SensorsController.ts: -------------------------------------------------------------------------------- 1 | import { withinPiRange, Vector2 } from '../helpers.js' 2 | import SensorsController from '../../src/subsystems/sensorsController.js' 3 | import YourDefenceController from './DefenseController.js' 4 | import YourNavigationController from './NavigationController.js' 5 | import YourPropulsionController from './PropulsionController.js' 6 | import { EMSReading, PassiveReading } from '../types.js' 7 | export default class YourSensorsController extends SensorsController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | navigation: YourNavigationController // @ts-ignore 12 | propulsion: YourPropulsionController 13 | 14 | //Add additional attributes here 15 | 16 | sensorsUpdate(activeScan: (heading: number, arc: number, range: number) => EMSReading[] | Error, passiveScan: () => PassiveReading[] | Error) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/Enterprise/NavigationController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2 } from '../helpers.js' 2 | import { MapData, ShipStatus} from '../types.js' 3 | 4 | import NavigationController from '../../src/subsystems/navigationController.js' 5 | import YourDefenceController from './DefenseController.js' 6 | import YourPropulsionController from './PropulsionController.js' 7 | import YourSensorsController from './SensorsController.js' 8 | 9 | export default class YourNavigationController extends NavigationController { 10 | // To get other subsystem information, use the attributes below. 11 | // @ts-ignore 12 | defence: YourDefenceController // @ts-ignore 13 | sensors: YourSensorsController // @ts-ignore 14 | propulsion: YourPropulsionController 15 | 16 | //Add additional attributes here 17 | 18 | navigationUpdate(getShipStatus: (key: keyof ShipStatus) => number, warp: () => Error|null, land: () => Error|null, getMapData: () => MapData) { 19 | //Student code goes here 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /typescript/students/EventHorizon/NavigationController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2 } from '../helpers.js' 2 | import { MapData, ShipStatus} from '../types.js' 3 | 4 | import NavigationController from '../../src/subsystems/navigationController.js' 5 | import YourDefenceController from './DefenseController.js' 6 | import YourPropulsionController from './PropulsionController.js' 7 | import YourSensorsController from './SensorsController.js' 8 | 9 | export default class YourNavigationController extends NavigationController { 10 | // To get other subsystem information, use the attributes below. 11 | // @ts-ignore 12 | defence: YourDefenceController // @ts-ignore 13 | sensors: YourSensorsController // @ts-ignore 14 | propulsion: YourPropulsionController 15 | 16 | //Add additional attributes here 17 | 18 | navigationUpdate(getShipStatus: (key: keyof ShipStatus) => number, warp: () => Error|null, land: () => Error|null, getMapData: () => MapData) { 19 | //Student code goes here 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /typescript/students/Galactica/NavigationController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2 } from '../helpers.js' 2 | import { MapData, ShipStatus} from '../types.js' 3 | 4 | import NavigationController from '../../src/subsystems/navigationController.js' 5 | import YourDefenceController from './DefenseController.js' 6 | import YourPropulsionController from './PropulsionController.js' 7 | import YourSensorsController from './SensorsController.js' 8 | 9 | export default class YourNavigationController extends NavigationController { 10 | // To get other subsystem information, use the attributes below. 11 | // @ts-ignore 12 | defence: YourDefenceController // @ts-ignore 13 | sensors: YourSensorsController // @ts-ignore 14 | propulsion: YourPropulsionController 15 | 16 | //Add additional attributes here 17 | 18 | navigationUpdate(getShipStatus: (key: keyof ShipStatus) => number, warp: () => Error|null, land: () => Error|null, getMapData: () => MapData) { 19 | //Student code goes here 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /typescript/students/Normandy/NavigationController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2 } from '../helpers.js' 2 | import { MapData, ShipStatus} from '../types.js' 3 | 4 | import NavigationController from '../../src/subsystems/navigationController.js' 5 | import YourDefenceController from './DefenseController.js' 6 | import YourPropulsionController from './PropulsionController.js' 7 | import YourSensorsController from './SensorsController.js' 8 | 9 | export default class YourNavigationController extends NavigationController { 10 | // To get other subsystem information, use the attributes below. 11 | // @ts-ignore 12 | defence: YourDefenceController // @ts-ignore 13 | sensors: YourSensorsController // @ts-ignore 14 | propulsion: YourPropulsionController 15 | 16 | //Add additional attributes here 17 | 18 | navigationUpdate(getShipStatus: (key: keyof ShipStatus) => number, warp: () => Error|null, land: () => Error|null, getMapData: () => MapData) { 19 | //Student code goes here 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /typescript/students/Nostromo/NavigationController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2 } from '../helpers.js' 2 | import { MapData, ShipStatus} from '../types.js' 3 | 4 | import NavigationController from '../../src/subsystems/navigationController.js' 5 | import YourDefenceController from './DefenseController.js' 6 | import YourPropulsionController from './PropulsionController.js' 7 | import YourSensorsController from './SensorsController.js' 8 | 9 | export default class YourNavigationController extends NavigationController { 10 | // To get other subsystem information, use the attributes below. 11 | // @ts-ignore 12 | defence: YourDefenceController // @ts-ignore 13 | sensors: YourSensorsController // @ts-ignore 14 | propulsion: YourPropulsionController 15 | 16 | //Add additional attributes here 17 | 18 | navigationUpdate(getShipStatus: (key: keyof ShipStatus) => number, warp: () => Error|null, land: () => Error|null, getMapData: () => MapData) { 19 | //Student code goes here 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /typescript/students/Rama/SensorsController.ts: -------------------------------------------------------------------------------- 1 | import { withinPiRange, Vector2 } from '../helpers.js' 2 | import SensorsController from '../../src/subsystems/sensorsController.js' 3 | import YourDefenceController from './DefenseController.js' 4 | import YourNavigationController from './NavigationController.js' 5 | import YourPropulsionController from './PropulsionController.js' 6 | import { EMSReading, PassiveReading } from '../types.js' 7 | export default class YourSensorsController extends SensorsController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | navigation: YourNavigationController // @ts-ignore 12 | propulsion: YourPropulsionController 13 | 14 | //Add additional attributes here 15 | 16 | sensorsUpdate(activeScan: (heading: number, arc: number, range: number) => EMSReading[] | Error, passiveScan: () => PassiveReading[] | Error) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/RedDwarf/NavigationController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2 } from '../helpers.js' 2 | import { MapData, ShipStatus} from '../types.js' 3 | 4 | import NavigationController from '../../src/subsystems/navigationController.js' 5 | import YourDefenceController from './DefenseController.js' 6 | import YourPropulsionController from './PropulsionController.js' 7 | import YourSensorsController from './SensorsController.js' 8 | 9 | export default class YourNavigationController extends NavigationController { 10 | // To get other subsystem information, use the attributes below. 11 | // @ts-ignore 12 | defence: YourDefenceController // @ts-ignore 13 | sensors: YourSensorsController // @ts-ignore 14 | propulsion: YourPropulsionController 15 | 16 | //Add additional attributes here 17 | 18 | navigationUpdate(getShipStatus: (key: keyof ShipStatus) => number, warp: () => Error|null, land: () => Error|null, getMapData: () => MapData) { 19 | //Student code goes here 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /typescript/students/Serenity/NavigationController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2 } from '../helpers.js' 2 | import { MapData, ShipStatus} from '../types.js' 3 | 4 | import NavigationController from '../../src/subsystems/navigationController.js' 5 | import YourDefenceController from './DefenseController.js' 6 | import YourPropulsionController from './PropulsionController.js' 7 | import YourSensorsController from './SensorsController.js' 8 | 9 | export default class YourNavigationController extends NavigationController { 10 | // To get other subsystem information, use the attributes below. 11 | // @ts-ignore 12 | defence: YourDefenceController // @ts-ignore 13 | sensors: YourSensorsController // @ts-ignore 14 | propulsion: YourPropulsionController 15 | 16 | //Add additional attributes here 17 | 18 | navigationUpdate(getShipStatus: (key: keyof ShipStatus) => number, warp: () => Error|null, land: () => Error|null, getMapData: () => MapData) { 19 | //Student code goes here 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /typescript/students/Thunderbird3/NavigationController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2 } from '../helpers.js' 2 | import { MapData, ShipStatus} from '../types.js' 3 | 4 | import NavigationController from '../../src/subsystems/navigationController.js' 5 | import YourDefenceController from './DefenseController.js' 6 | import YourPropulsionController from './PropulsionController.js' 7 | import YourSensorsController from './SensorsController.js' 8 | 9 | export default class YourNavigationController extends NavigationController { 10 | // To get other subsystem information, use the attributes below. 11 | // @ts-ignore 12 | defence: YourDefenceController // @ts-ignore 13 | sensors: YourSensorsController // @ts-ignore 14 | propulsion: YourPropulsionController 15 | 16 | //Add additional attributes here 17 | 18 | navigationUpdate(getShipStatus: (key: keyof ShipStatus) => number, warp: () => Error|null, land: () => Error|null, getMapData: () => MapData) { 19 | //Student code goes here 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /typescript/students/Bismark/SensorsController.ts: -------------------------------------------------------------------------------- 1 | import { withinPiRange, Vector2 } from '../helpers.js' 2 | import SensorsController from '../../src/subsystems/sensorsController.js' 3 | import YourDefenceController from './DefenseController.js' 4 | import YourNavigationController from './NavigationController.js' 5 | import YourPropulsionController from './PropulsionController.js' 6 | import { EMSReading, PassiveReading } from '../types.js' 7 | export default class YourSensorsController extends SensorsController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | navigation: YourNavigationController // @ts-ignore 12 | propulsion: YourPropulsionController 13 | 14 | //Add additional attributes here 15 | 16 | sensorsUpdate(activeScan: (heading: number, arc: number, range: number) => EMSReading[] | Error, passiveScan: () => PassiveReading[] | Error) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/Enterprise/SensorsController.ts: -------------------------------------------------------------------------------- 1 | import { withinPiRange, Vector2 } from '../helpers.js' 2 | import SensorsController from '../../src/subsystems/sensorsController.js' 3 | import YourDefenceController from './DefenseController.js' 4 | import YourNavigationController from './NavigationController.js' 5 | import YourPropulsionController from './PropulsionController.js' 6 | import { EMSReading, PassiveReading } from '../types.js' 7 | export default class YourSensorsController extends SensorsController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | navigation: YourNavigationController // @ts-ignore 12 | propulsion: YourPropulsionController 13 | 14 | //Add additional attributes here 15 | 16 | sensorsUpdate(activeScan: (heading: number, arc: number, range: number) => EMSReading[] | Error, passiveScan: () => PassiveReading[] | Error) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/FlyingDutchman/NavigationController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2 } from '../helpers.js' 2 | import { MapData, ShipStatus} from '../types.js' 3 | 4 | import NavigationController from '../../src/subsystems/navigationController.js' 5 | import YourDefenceController from './DefenseController.js' 6 | import YourPropulsionController from './PropulsionController.js' 7 | import YourSensorsController from './SensorsController.js' 8 | 9 | export default class YourNavigationController extends NavigationController { 10 | // To get other subsystem information, use the attributes below. 11 | // @ts-ignore 12 | defence: YourDefenceController // @ts-ignore 13 | sensors: YourSensorsController // @ts-ignore 14 | propulsion: YourPropulsionController 15 | 16 | //Add additional attributes here 17 | 18 | navigationUpdate(getShipStatus: (key: keyof ShipStatus) => number, warp: () => Error|null, land: () => Error|null, getMapData: () => MapData) { 19 | //Student code goes here 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /typescript/students/Galactica/SensorsController.ts: -------------------------------------------------------------------------------- 1 | import { withinPiRange, Vector2 } from '../helpers.js' 2 | import SensorsController from '../../src/subsystems/sensorsController.js' 3 | import YourDefenceController from './DefenseController.js' 4 | import YourNavigationController from './NavigationController.js' 5 | import YourPropulsionController from './PropulsionController.js' 6 | import { EMSReading, PassiveReading } from '../types.js' 7 | export default class YourSensorsController extends SensorsController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | navigation: YourNavigationController // @ts-ignore 12 | propulsion: YourPropulsionController 13 | 14 | //Add additional attributes here 15 | 16 | sensorsUpdate(activeScan: (heading: number, arc: number, range: number) => EMSReading[] | Error, passiveScan: () => PassiveReading[] | Error) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/Milano/SensorsController.ts: -------------------------------------------------------------------------------- 1 | import { withinPiRange, Vector2 } from '../helpers.js' 2 | import SensorsController from '../../src/subsystems/sensorsController.js' 3 | import YourDefenceController from './DefenseController.js' 4 | import YourNavigationController from './NavigationController.js' 5 | import YourPropulsionController from './PropulsionController.js' 6 | import { EMSReading, PassiveReading } from '../types.js' 7 | export default class YourSensorsController extends SensorsController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | navigation: YourNavigationController // @ts-ignore 12 | propulsion: YourPropulsionController 13 | 14 | //Add additional attributes here 15 | 16 | sensorsUpdate(activeScan: (heading: number, arc: number, range: number) => EMSReading[] | Error, passiveScan: () => PassiveReading[] | Error) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/Normandy/SensorsController.ts: -------------------------------------------------------------------------------- 1 | import { withinPiRange, Vector2 } from '../helpers.js' 2 | import SensorsController from '../../src/subsystems/sensorsController.js' 3 | import YourDefenceController from './DefenseController.js' 4 | import YourNavigationController from './NavigationController.js' 5 | import YourPropulsionController from './PropulsionController.js' 6 | import { EMSReading, PassiveReading } from '../types.js' 7 | export default class YourSensorsController extends SensorsController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | navigation: YourNavigationController // @ts-ignore 12 | propulsion: YourPropulsionController 13 | 14 | //Add additional attributes here 15 | 16 | sensorsUpdate(activeScan: (heading: number, arc: number, range: number) => EMSReading[] | Error, passiveScan: () => PassiveReading[] | Error) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/Nostromo/SensorsController.ts: -------------------------------------------------------------------------------- 1 | import { withinPiRange, Vector2 } from '../helpers.js' 2 | import SensorsController from '../../src/subsystems/sensorsController.js' 3 | import YourDefenceController from './DefenseController.js' 4 | import YourNavigationController from './NavigationController.js' 5 | import YourPropulsionController from './PropulsionController.js' 6 | import { EMSReading, PassiveReading } from '../types.js' 7 | export default class YourSensorsController extends SensorsController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | navigation: YourNavigationController // @ts-ignore 12 | propulsion: YourPropulsionController 13 | 14 | //Add additional attributes here 15 | 16 | sensorsUpdate(activeScan: (heading: number, arc: number, range: number) => EMSReading[] | Error, passiveScan: () => PassiveReading[] | Error) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/PillarOfAutumn/NavigationController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2 } from '../helpers.js' 2 | import { MapData, ShipStatus} from '../types.js' 3 | 4 | import NavigationController from '../../src/subsystems/navigationController.js' 5 | import YourDefenceController from './DefenseController.js' 6 | import YourPropulsionController from './PropulsionController.js' 7 | import YourSensorsController from './SensorsController.js' 8 | 9 | export default class YourNavigationController extends NavigationController { 10 | // To get other subsystem information, use the attributes below. 11 | // @ts-ignore 12 | defence: YourDefenceController // @ts-ignore 13 | sensors: YourSensorsController // @ts-ignore 14 | propulsion: YourPropulsionController 15 | 16 | //Add additional attributes here 17 | 18 | navigationUpdate(getShipStatus: (key: keyof ShipStatus) => number, warp: () => Error|null, land: () => Error|null, getMapData: () => MapData) { 19 | //Student code goes here 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /typescript/students/PlanetExpress/NavigationController.ts: -------------------------------------------------------------------------------- 1 | import { Vector2 } from '../helpers.js' 2 | import { MapData, ShipStatus} from '../types.js' 3 | 4 | import NavigationController from '../../src/subsystems/navigationController.js' 5 | import YourDefenceController from './DefenseController.js' 6 | import YourPropulsionController from './PropulsionController.js' 7 | import YourSensorsController from './SensorsController.js' 8 | 9 | export default class YourNavigationController extends NavigationController { 10 | // To get other subsystem information, use the attributes below. 11 | // @ts-ignore 12 | defence: YourDefenceController // @ts-ignore 13 | sensors: YourSensorsController // @ts-ignore 14 | propulsion: YourPropulsionController 15 | 16 | //Add additional attributes here 17 | 18 | navigationUpdate(getShipStatus: (key: keyof ShipStatus) => number, warp: () => Error|null, land: () => Error|null, getMapData: () => MapData) { 19 | //Student code goes here 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /typescript/students/RedDwarf/SensorsController.ts: -------------------------------------------------------------------------------- 1 | import { withinPiRange, Vector2 } from '../helpers.js' 2 | import SensorsController from '../../src/subsystems/sensorsController.js' 3 | import YourDefenceController from './DefenseController.js' 4 | import YourNavigationController from './NavigationController.js' 5 | import YourPropulsionController from './PropulsionController.js' 6 | import { EMSReading, PassiveReading } from '../types.js' 7 | export default class YourSensorsController extends SensorsController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | navigation: YourNavigationController // @ts-ignore 12 | propulsion: YourPropulsionController 13 | 14 | //Add additional attributes here 15 | 16 | sensorsUpdate(activeScan: (heading: number, arc: number, range: number) => EMSReading[] | Error, passiveScan: () => PassiveReading[] | Error) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/SSAnne/SensorsController.ts: -------------------------------------------------------------------------------- 1 | import { withinPiRange, Vector2 } from '../helpers.js' 2 | import SensorsController from '../../src/subsystems/sensorsController.js' 3 | import YourDefenceController from './DefenseController.js' 4 | import YourNavigationController from './NavigationController.js' 5 | import YourPropulsionController from './PropulsionController.js' 6 | import { EMSReading, PassiveReading } from '../types.js' 7 | export default class YourSensorsController extends SensorsController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | navigation: YourNavigationController // @ts-ignore 12 | propulsion: YourPropulsionController 13 | 14 | //Add additional attributes here 15 | 16 | sensorsUpdate(activeScan: (heading: number, arc: number, range: number) => EMSReading[] | Error, passiveScan: () => PassiveReading[] | Error) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/Serenity/SensorsController.ts: -------------------------------------------------------------------------------- 1 | import { withinPiRange, Vector2 } from '../helpers.js' 2 | import SensorsController from '../../src/subsystems/sensorsController.js' 3 | import YourDefenceController from './DefenseController.js' 4 | import YourNavigationController from './NavigationController.js' 5 | import YourPropulsionController from './PropulsionController.js' 6 | import { EMSReading, PassiveReading } from '../types.js' 7 | export default class YourSensorsController extends SensorsController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | navigation: YourNavigationController // @ts-ignore 12 | propulsion: YourPropulsionController 13 | 14 | //Add additional attributes here 15 | 16 | sensorsUpdate(activeScan: (heading: number, arc: number, range: number) => EMSReading[] | Error, passiveScan: () => PassiveReading[] | Error) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/Yamato/SensorsController.ts: -------------------------------------------------------------------------------- 1 | import { withinPiRange, Vector2 } from '../helpers.js' 2 | import SensorsController from '../../src/subsystems/sensorsController.js' 3 | import YourDefenceController from './DefenseController.js' 4 | import YourNavigationController from './NavigationController.js' 5 | import YourPropulsionController from './PropulsionController.js' 6 | import { EMSReading, PassiveReading } from '../types.js' 7 | export default class YourSensorsController extends SensorsController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | navigation: YourNavigationController // @ts-ignore 12 | propulsion: YourPropulsionController 13 | 14 | //Add additional attributes here 15 | 16 | sensorsUpdate(activeScan: (heading: number, arc: number, range: number) => EMSReading[] | Error, passiveScan: () => PassiveReading[] | Error) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /manual/codeBlocks.md: -------------------------------------------------------------------------------- 1 | # Example Code Blocks 2 | 3 | ```typescript 4 | defenceUpdate() { 5 | if (!this.sensors.target) return 6 | aimTurret(this.sensors.target.heading) 7 | fireTorpedo(0) 8 | } 9 | ``` 10 | 11 | ```typescript 12 | navigationUpdate() { 13 | this.angle = getShipStatus('angle') 14 | land() 15 | } 16 | ``` 17 | 18 | ```typescript 19 | propulsionUpdate() { 20 | if (!this.sensors.target) return 21 | const headingDiff = angleDiff(this.navigation.angle, this.sensors.target.heading) 22 | const force = Math.min(Math.abs(500 * headingDiff), 100) 23 | if (headingDiff < 0) { 24 | setThruster('clockwise', force) 25 | setThruster('counterClockwise', 0) 26 | } else { 27 | setThruster('counterClockwise', force) 28 | setThruster('clockwise', 0) 29 | } 30 | setThruster('main', Math.abs(headingDiff) < 0.2 ? 30 : 0) 31 | } 32 | ``` 33 | 34 | ```typescript 35 | sensorsUpdate() { 36 | const scanResult = passiveScan() 37 | if (!(scanResult instanceof Error)) this.target = scanResult[0] 38 | } 39 | ``` 40 | -------------------------------------------------------------------------------- /typescript/students/EventHorizon/SensorsController.ts: -------------------------------------------------------------------------------- 1 | import { withinPiRange, Vector2 } from '../helpers.js' 2 | import SensorsController from '../../src/subsystems/sensorsController.js' 3 | import YourDefenceController from './DefenseController.js' 4 | import YourNavigationController from './NavigationController.js' 5 | import YourPropulsionController from './PropulsionController.js' 6 | import { EMSReading, PassiveReading } from '../types.js' 7 | export default class YourSensorsController extends SensorsController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | navigation: YourNavigationController // @ts-ignore 12 | propulsion: YourPropulsionController 13 | 14 | //Add additional attributes here 15 | 16 | sensorsUpdate(activeScan: (heading: number, arc: number, range: number) => EMSReading[] | Error, passiveScan: () => PassiveReading[] | Error) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/FlyingDutchman/SensorsController.ts: -------------------------------------------------------------------------------- 1 | import { withinPiRange, Vector2 } from '../helpers.js' 2 | import SensorsController from '../../src/subsystems/sensorsController.js' 3 | import YourDefenceController from './DefenseController.js' 4 | import YourNavigationController from './NavigationController.js' 5 | import YourPropulsionController from './PropulsionController.js' 6 | import { EMSReading, PassiveReading } from '../types.js' 7 | export default class YourSensorsController extends SensorsController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | navigation: YourNavigationController // @ts-ignore 12 | propulsion: YourPropulsionController 13 | 14 | //Add additional attributes here 15 | 16 | sensorsUpdate(activeScan: (heading: number, arc: number, range: number) => EMSReading[] | Error, passiveScan: () => PassiveReading[] | Error) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/PillarOfAutumn/SensorsController.ts: -------------------------------------------------------------------------------- 1 | import { withinPiRange, Vector2 } from '../helpers.js' 2 | import SensorsController from '../../src/subsystems/sensorsController.js' 3 | import YourDefenceController from './DefenseController.js' 4 | import YourNavigationController from './NavigationController.js' 5 | import YourPropulsionController from './PropulsionController.js' 6 | import { EMSReading, PassiveReading } from '../types.js' 7 | export default class YourSensorsController extends SensorsController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | navigation: YourNavigationController // @ts-ignore 12 | propulsion: YourPropulsionController 13 | 14 | //Add additional attributes here 15 | 16 | sensorsUpdate(activeScan: (heading: number, arc: number, range: number) => EMSReading[] | Error, passiveScan: () => PassiveReading[] | Error) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/PlanetExpress/SensorsController.ts: -------------------------------------------------------------------------------- 1 | import { withinPiRange, Vector2 } from '../helpers.js' 2 | import SensorsController from '../../src/subsystems/sensorsController.js' 3 | import YourDefenceController from './DefenseController.js' 4 | import YourNavigationController from './NavigationController.js' 5 | import YourPropulsionController from './PropulsionController.js' 6 | import { EMSReading, PassiveReading } from '../types.js' 7 | export default class YourSensorsController extends SensorsController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | navigation: YourNavigationController // @ts-ignore 12 | propulsion: YourPropulsionController 13 | 14 | //Add additional attributes here 15 | 16 | sensorsUpdate(activeScan: (heading: number, arc: number, range: number) => EMSReading[] | Error, passiveScan: () => PassiveReading[] | Error) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/students/Thunderbird3/SensorsController.ts: -------------------------------------------------------------------------------- 1 | import { withinPiRange, Vector2 } from '../helpers.js' 2 | import SensorsController from '../../src/subsystems/sensorsController.js' 3 | import YourDefenceController from './DefenseController.js' 4 | import YourNavigationController from './NavigationController.js' 5 | import YourPropulsionController from './PropulsionController.js' 6 | import { EMSReading, PassiveReading } from '../types.js' 7 | export default class YourSensorsController extends SensorsController { 8 | // To get other subsystem information, use the attributes below. 9 | // @ts-ignore 10 | defence: YourDefenceController // @ts-ignore 11 | navigation: YourNavigationController // @ts-ignore 12 | propulsion: YourPropulsionController 13 | 14 | //Add additional attributes here 15 | 16 | sensorsUpdate(activeScan: (heading: number, arc: number, range: number) => EMSReading[] | Error, passiveScan: () => PassiveReading[] | Error) { 17 | //Student code goes here 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /typescript/src/subsystems/propulsionController.ts: -------------------------------------------------------------------------------- 1 | import { ThrusterName } from '../ship/thrusterController.js' 2 | import DefenceController from './defenceController.js' 3 | import NavigationController from './navigationController.js' 4 | import SensorsController from './sensorsController.js' 5 | 6 | export default class PropulsionController { 7 | // @ts-ignore 8 | navigation: NavigationController 9 | // @ts-ignore 10 | defence: DefenceController 11 | // @ts-ignore 12 | sensors: SensorsController 13 | propulsionUpdate(setThruster: (thruster: ThrusterName, power: number) => Error | null) {} 14 | constructor() { 15 | // @ts-ignore 16 | this.navigation = null 17 | // @ts-ignore 18 | this.defence = null 19 | // @ts-ignore 20 | this.sensors = null 21 | } 22 | initializeConnection = ( 23 | defence: DefenceController, 24 | navigation: NavigationController, 25 | sensors: SensorsController 26 | ) => { 27 | this.defence = defence 28 | this.navigation = navigation 29 | this.sensors = sensors 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /typescript/src/subsystems/defenceController.ts: -------------------------------------------------------------------------------- 1 | import NavigationController from './navigationController.js' 2 | import PropulsionController from './propulsionController.js' 3 | import SensorsController from './sensorsController.js' 4 | 5 | export default class DefenceController { 6 | // @ts-ignore 7 | navigation: NavigationController 8 | // @ts-ignore 9 | propulsion: PropulsionController 10 | // @ts-ignore 11 | sensors: SensorsController 12 | defenceUpdate(aimTurret: (angle: number) => void, getTubeCooldown: (i: number) => number | Error, fireTorpedo: (i: number) => Error | null) {} 13 | constructor() { 14 | // @ts-ignore 15 | this.navigation = null 16 | // @ts-ignore 17 | this.propulsion = null 18 | // @ts-ignore 19 | this.sensors = null 20 | } 21 | initializeConnection = ( 22 | navigation: NavigationController, 23 | propulsion: PropulsionController, 24 | sensors: SensorsController 25 | ) => { 26 | this.navigation = navigation 27 | this.propulsion = propulsion 28 | this.sensors = sensors 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /typescript/src/spaceObjects/blackhole.ts: -------------------------------------------------------------------------------- 1 | import Vector2 from '../helpers/Vector2.js' 2 | import Process from '../gameProcess.js' 3 | import Game from '../game.js' 4 | import Sprite from '../sprite.js' 5 | import Planet from './planet.js' 6 | import Torpedo from '../ship/torpedo.js' 7 | 8 | export default class BlackHole extends Sprite { 9 | /* Default Params */ 10 | mass 11 | ctx = 'planets' 12 | radius = 40 + (Math.random() - 0.5) * 5 13 | orbitingPlanets:Planet[] = [] 14 | 15 | /* Other attributes */ 16 | process: Process | null = null 17 | constructor(...args: [pos: Vector2, game: Game]) { 18 | super(...args) 19 | this.image = this.game.images['blackhole'] 20 | this.mass = Infinity 21 | this.calcSize() 22 | } 23 | initialize(process: Process) { 24 | this.process = process 25 | } 26 | calcSize() { 27 | this.size = new Vector2(this.radius * 3, this.radius * 3) 28 | } 29 | addPlanet(planet: Planet) { 30 | this.orbitingPlanets.push(planet) 31 | } 32 | 33 | update() { 34 | if (!this.process) return 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /typescript/src/spaceObjects/meteor.ts: -------------------------------------------------------------------------------- 1 | import Sprite from '../sprite.js' 2 | import Vector2 from '../helpers/Vector2.js' 3 | import Process from '../gameProcess.js' 4 | import Game from '../game.js' 5 | //Mini asteroid from asteroid explosion 6 | export default class Meteor extends Sprite { 7 | /* Other attributes */ 8 | process: Process | null = null 9 | delete = false //Once an item needs to be deleted and stop rendering, set to true 10 | size = new Vector2(10, 10) 11 | radius = 5 12 | ctx: string = 'objects' 13 | mass = 1 14 | speed: Vector2 15 | hasExploded = false 16 | 17 | constructor(speed: Vector2, ...args: [pos: Vector2, game: Game]) { 18 | super(...args) 19 | this.speed = speed 20 | this.image = this.game.images['asteroid'] 21 | } 22 | initialize(process: Process) { 23 | this.process = process 24 | } 25 | update() { 26 | super.update() 27 | } 28 | receiveDamage() { 29 | // meteors have 1hp 30 | this.shatter() 31 | } 32 | shatter() { 33 | this.hasExploded = true 34 | this.delete = true 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /javascript/src/spaceObjects/meteor.js: -------------------------------------------------------------------------------- 1 | import Sprite from '../sprite.js'; 2 | import Vector2 from '../helpers/Vector2.js'; 3 | //Mini asteroid from asteroid explosion 4 | export default class Meteor extends Sprite { 5 | constructor(speed, ...args) { 6 | super(...args); 7 | /* Other attributes */ 8 | this.process = null; 9 | this.delete = false; //Once an item needs to be deleted and stop rendering, set to true 10 | this.size = new Vector2(10, 10); 11 | this.radius = 5; 12 | this.ctx = 'objects'; 13 | this.mass = 1; 14 | this.hasExploded = false; 15 | this.speed = speed; 16 | this.image = this.game.images['asteroid']; 17 | } 18 | initialize(process) { 19 | this.process = process; 20 | } 21 | update() { 22 | super.update(); 23 | } 24 | receiveDamage() { 25 | // meteors have 1hp 26 | this.shatter(); 27 | } 28 | shatter() { 29 | this.hasExploded = true; 30 | this.delete = true; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /typescript/src/ship/EMSReading.ts: -------------------------------------------------------------------------------- 1 | import Vector2 from '../helpers/Vector2' 2 | import PlanetComposition from '../spaceObjects/planetComposition' 3 | 4 | export type CloseRangeData = { 5 | type: 'Planet' 6 | planetComposition: PlanetComposition 7 | } | { 8 | type: 'Meteor' | 'Asteroid' | 'WarpGate' | 'Other' 9 | PlanetComposition?: undefined 10 | } 11 | export class EMSReading { 12 | angle: number 13 | distance: number 14 | velocity: Vector2 15 | radius: number 16 | closeRange?: CloseRangeData 17 | constructor(angle: number, velocity: Vector2, radius: number, distance: number, closeRangeData: CloseRangeData | undefined = undefined) { 18 | this.angle = angle // The angle of the reading (relative to global X axis) //number 19 | this.velocity = velocity // The velocity of the detected object relative to current solar system coordinate frame //Vector 20 | this.distance = distance 21 | this.radius = radius // The collision radius of the detected object //number 22 | if (distance < 100) { 23 | this.closeRange = closeRangeData 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /typescript/src/subsystems/navigationController.ts: -------------------------------------------------------------------------------- 1 | import { MapData } from '../ship/mapData.js' 2 | import { ShipStatus } from '../ship/shipStatus.js' 3 | import DefenceController from './defenceController.js' 4 | import PropulsionController from './propulsionController.js' 5 | import SensorsController from './sensorsController.js' 6 | 7 | export default class NavigationController { 8 | // @ts-ignore 9 | defence: DefenceController 10 | // @ts-ignore 11 | propulsion: PropulsionController 12 | // @ts-ignore 13 | sensors: SensorsController 14 | navigationUpdate(getShipStatus: (key: keyof ShipStatus) => number, warp: () => Error|null, land: () => Error|null, getMapData: () => MapData) {} 15 | constructor() { 16 | // @ts-ignore 17 | this.defence = null 18 | // @ts-ignore 19 | this.propulsion = null 20 | // @ts-ignore 21 | this.sensors = null 22 | } 23 | initializeConnection = ( 24 | defence: DefenceController, 25 | propulsion: PropulsionController, 26 | sensors: SensorsController 27 | ) => { 28 | this.defence = defence 29 | this.propulsion = propulsion 30 | this.sensors = sensors 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Zachary Waite 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /typescript/src/ship/mapData.ts: -------------------------------------------------------------------------------- 1 | import { GalaxyName } from "../galaxies/galaxy" 2 | import { SolarSystemName } from "../galaxies/solarSystem" 3 | import { PlanetName } from "../spaceObjects/planet" 4 | import ColonyShip from "./colonyShip" 5 | 6 | interface SolarSystemData { 7 | name: SolarSystemName 8 | warpGates: SolarSystemName[] 9 | planets: PlanetName[] 10 | } 11 | interface GalaxyData { 12 | name: GalaxyName 13 | solarSystems: SolarSystemData[] 14 | } 15 | 16 | export interface MapData { 17 | solarSystemName: SolarSystemName 18 | galaxy: GalaxyData 19 | } 20 | 21 | 22 | export const getMapData = (ship: ColonyShip): MapData => { 23 | ship.energyUsed += 10 24 | const galaxy = ship.game.galaxy 25 | if (galaxy === null) throw Error("No galaxy loaded") 26 | return { 27 | solarSystemName: ship.solarSystem.name, 28 | galaxy: { 29 | name: galaxy.name, 30 | solarSystems: galaxy.solarSystems.map((solarSystem) => ({ 31 | name: solarSystem.name, 32 | warpGates: solarSystem.warpGates.map((warpGate) => warpGate.destinationSolarSystem), 33 | planets: solarSystem.planets.map((planet) => planet.name) 34 | })) 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /typescript/src/subsystems/sensorsController.ts: -------------------------------------------------------------------------------- 1 | import { EMSReading } from '../ship/EMSReading.js' 2 | import { PassiveReading } from '../ship/passiveReading.js' 3 | import DefenceController from './defenceController.js' 4 | import NavigationController from './navigationController.js' 5 | import PropulsionController from './propulsionController.js' 6 | 7 | export default class SensorsController { 8 | // @ts-ignore 9 | navigation: NavigationController 10 | // @ts-ignore 11 | defence: DefenceController 12 | // @ts-ignore 13 | propulsion: PropulsionController 14 | constructor() { 15 | // @ts-ignore 16 | this.navigation = null 17 | // @ts-ignore 18 | this.defence = null 19 | // @ts-ignore 20 | this.propulsion = null 21 | } 22 | sensorsUpdate(activeScan: (heading: number, arc: number, range: number) => EMSReading[] | Error, passiveScan: () => PassiveReading[] | Error) {} 23 | initializeConnection = ( 24 | defence: DefenceController, 25 | navigation: NavigationController, 26 | propulsion: PropulsionController 27 | ) => { 28 | this.defence = defence 29 | this.propulsion = propulsion 30 | this.navigation = navigation 31 | } 32 | } 33 | 34 | 35 | -------------------------------------------------------------------------------- /javascript/src/galaxies/solarSystem.js: -------------------------------------------------------------------------------- 1 | import Vector2 from '../helpers/Vector2.js'; 2 | const SolarSystemNames = [ 3 | 'Tutorial', 4 | 'Goose', 5 | 'Waterloo', 6 | 'StackOverflow', 7 | 'Hargun', 8 | 'Olivia', 9 | 'Derek', 10 | 'Ali', 11 | 'ECE105', 12 | 'Torvalds', 13 | 'Zac', 14 | 'Josiah', 15 | 'Elon', 16 | 'Gates', 17 | 'Turing' 18 | ]; 19 | export default class SolarSystem { 20 | constructor(solarSystemName, galaxyName, game, objects) { 21 | var _a, _b, _c, _d; 22 | this.shipStartPosition = new Vector2(300, 300); 23 | this.game = game; 24 | this.galaxyName = galaxyName; 25 | this.name = solarSystemName; 26 | this.asteroids = (_a = objects.asteroids) !== null && _a !== void 0 ? _a : []; 27 | this.warpGates = (_b = objects.warpGates) !== null && _b !== void 0 ? _b : []; 28 | this.planets = (_c = objects.planets) !== null && _c !== void 0 ? _c : []; 29 | this.asteroidLaunchers = (_d = objects.asteroidLaunchers) !== null && _d !== void 0 ? _d : []; 30 | this.star = objects.star; 31 | this.blackhole = objects.blackhole; 32 | this.planetNames = this.planets.map((planet) => planet.name); 33 | this.warpGateNames = this.warpGates.map((warpGate) => warpGate.destinationSolarSystem); 34 | } 35 | activate() { } 36 | } 37 | -------------------------------------------------------------------------------- /javascript/src/renderedObject.js: -------------------------------------------------------------------------------- 1 | import Vector2 from './helpers/Vector2.js'; 2 | export default class RenderedObject { 3 | constructor(pos, game) { 4 | /* Default or Empty Attributes */ 5 | this.size = new Vector2(10, 10); 6 | this.angle = 0; 7 | this.radius = 10; 8 | this.ctx = ''; 9 | this.image = null; // Actual DOM image 10 | this.game = game; 11 | this.pos = pos; 12 | } 13 | draw(name = '') { 14 | if (!this.image) 15 | return; 16 | // Set the context's translation. 17 | let ctx = this.game.contexts[this.ctx]; 18 | ctx.setTransform(1, 0, 0, 1, ((this.pos.x / 10) * this.game.unit - this.game.camera.x) * this.game.zoom, ((this.pos.y / 10) * this.game.unit - this.game.camera.y) * this.game.zoom); 19 | if (this.angle !== 0) 20 | ctx.rotate(this.angle); 21 | // Draw the image with a half-size offset, so that rotating works properly and the coordinate represent the center. 22 | ctx.drawImage(this.image, ((-(this.size.x / 10) * this.game.unit) / 2) * this.game.zoom, ((-(this.size.y / 10) * this.game.unit) / 2) * this.game.zoom, (this.size.x / 10) * this.game.unit * this.game.zoom, (this.size.y / 10) * this.game.unit * this.game.zoom); 23 | if (name !== '') { 24 | ctx.fillStyle = 'white'; 25 | ctx.fillText(name, ((-(this.size.x / 10) * this.game.unit) / 2) * this.game.zoom, ((-(this.size.y / 10) * this.game.unit) / 2) * this.game.zoom); 26 | } 27 | } 28 | update() { } 29 | } 30 | -------------------------------------------------------------------------------- /javascript/src/galaxies/galaxy.js: -------------------------------------------------------------------------------- 1 | import { BuildCompiles } from './compiles.js'; 2 | import { BuildCracked } from './cracked.js'; 3 | import { BuildJoziac } from './joziac.js'; 4 | import { BuildNoob } from './noob.js'; 5 | export default class Galaxy { 6 | constructor(galaxyName, game, solarSystems) { 7 | /* Default Attributes */ 8 | this.solarSystems = []; 9 | this.solarSystemNames = []; 10 | this.name = galaxyName; 11 | this.game = game; 12 | this.solarSystems = solarSystems; 13 | // Create solar systems with associated galaxy 14 | for (const solarSystem of this.solarSystems) { 15 | this.solarSystemNames.push(solarSystem.name); 16 | } 17 | // Set starting solar system to the first system in the list 18 | this.startingSolarSystem = this.solarSystems[0]; 19 | this.startingSolarSystemName = this.solarSystemNames[0]; 20 | } 21 | getSolarSystem(solarSystemName) { 22 | let returnSolarSystem = false; 23 | this.solarSystems.forEach((solarSystem) => { 24 | if (solarSystem.name === solarSystemName) { 25 | returnSolarSystem = solarSystem; 26 | } 27 | }); 28 | return returnSolarSystem; 29 | } 30 | } 31 | export const BuildGalaxy = (galaxyName, game) => { 32 | switch (galaxyName) { 33 | case 'Noob': return BuildNoob(game); 34 | case 'Compiles': return BuildCompiles(game); 35 | case 'Cracked': return BuildCracked(game); 36 | case 'Joziac': return BuildJoziac(game); 37 | } 38 | }; 39 | -------------------------------------------------------------------------------- /typescript/src/sprite.ts: -------------------------------------------------------------------------------- 1 | import Game from './game.js' 2 | import { withinPiRange } from './helpers/Angles.js' 3 | import Vector2 from './helpers/Vector2.js' 4 | import RenderedObject from './renderedObject.js' 5 | export default class Sprite extends RenderedObject { 6 | /* Default Attributes */ 7 | speed = new Vector2(0, 0) //linear speed 8 | accel = new Vector2(0, 0) //linear acceleration 9 | maxSpeed = 1000 //Max linear speed 10 | aSpeed: number = 0 //angle speed 11 | aAccel: number = 0 //angle acceleration 12 | maxASpeed = 20 //Max angular speed 13 | radius = 10 // Object collision Radius 14 | mass = 1 //Object mass for collisions 15 | delete = false 16 | constructor(...args: [pos: Vector2, game: Game]) { 17 | super(...args) 18 | } 19 | update() { 20 | // All Simple Physics 21 | // Add accelerations to speeds: 22 | this.speed = this.speed.add(this.accel) 23 | this.aSpeed += this.aAccel 24 | // Add speeds to positions 25 | this.pos = this.pos.add(this.speed) 26 | this.angle = withinPiRange(this.angle + this.aSpeed) 27 | this.boundsDetect() //Detect boundaries for position and speed 28 | // delete sprites that are heavily oob 29 | if (this.pos.x < -this.game.width || this.pos.x > 2 * this.game.width || this.pos.y < -this.game.height || this.pos.y > 2 * this.game.height) { 30 | this.delete = true 31 | } 32 | } 33 | boundsDetect() { 34 | // y speed bounds 35 | if (this.speed.y > this.maxSpeed) this.speed.y = this.maxSpeed 36 | // x speed bounds 37 | if (this.speed.x > this.maxSpeed) this.speed.x = this.maxSpeed 38 | // angle speed bounds 39 | if (this.aSpeed > this.maxASpeed) this.aSpeed = this.aSpeed = this.maxASpeed 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /typescript/src/renderedObject.ts: -------------------------------------------------------------------------------- 1 | import Game from './game.js' 2 | import Vector2 from './helpers/Vector2.js' 3 | 4 | export default abstract class RenderedObject { 5 | //Base class for everything that gets drawn 6 | /* Constructor Params */ 7 | game: Game 8 | pos: Vector2 9 | /* Default or Empty Attributes */ 10 | size: Vector2 = new Vector2(10, 10) 11 | angle: number = 0 12 | radius: number = 10 13 | ctx: string = '' 14 | image: CanvasImageSource | null = null // Actual DOM image 15 | 16 | constructor(pos: Vector2, game: Game) { 17 | this.game = game 18 | this.pos = pos 19 | } 20 | draw(name: string = '') { 21 | if (!this.image) return 22 | // Set the context's translation. 23 | let ctx: CanvasRenderingContext2D = this.game.contexts[this.ctx] 24 | ctx.setTransform(1, 0, 0, 1, ((this.pos.x / 10) * this.game.unit - this.game.camera.x) * this.game.zoom, ((this.pos.y / 10) * this.game.unit - this.game.camera.y) * this.game.zoom) 25 | if (this.angle !== 0) ctx.rotate(this.angle) 26 | // Draw the image with a half-size offset, so that rotating works properly and the coordinate represent the center. 27 | ctx.drawImage( 28 | this.image, 29 | ((-(this.size.x / 10) * this.game.unit) / 2) * this.game.zoom, 30 | ((-(this.size.y / 10) * this.game.unit) / 2) * this.game.zoom, 31 | (this.size.x / 10) * this.game.unit * this.game.zoom, 32 | (this.size.y / 10) * this.game.unit * this.game.zoom 33 | ) 34 | if (name !== '') { 35 | ctx.fillStyle = 'white' 36 | ctx.fillText( 37 | name, 38 | ((-(this.size.x / 10) * this.game.unit) / 2) * this.game.zoom, 39 | ((-(this.size.y / 10) * this.game.unit) / 2) * this.game.zoom, 40 | ) 41 | } 42 | } 43 | update() {} 44 | } 45 | -------------------------------------------------------------------------------- /javascript/src/sprite.js: -------------------------------------------------------------------------------- 1 | import { withinPiRange } from './helpers/Angles.js'; 2 | import Vector2 from './helpers/Vector2.js'; 3 | import RenderedObject from './renderedObject.js'; 4 | export default class Sprite extends RenderedObject { 5 | constructor(...args) { 6 | super(...args); 7 | /* Default Attributes */ 8 | this.speed = new Vector2(0, 0); //linear speed 9 | this.accel = new Vector2(0, 0); //linear acceleration 10 | this.maxSpeed = 1000; //Max linear speed 11 | this.aSpeed = 0; //angle speed 12 | this.aAccel = 0; //angle acceleration 13 | this.maxASpeed = 20; //Max angular speed 14 | this.radius = 10; // Object collision Radius 15 | this.mass = 1; //Object mass for collisions 16 | this.delete = false; 17 | } 18 | update() { 19 | // All Simple Physics 20 | // Add accelerations to speeds: 21 | this.speed = this.speed.add(this.accel); 22 | this.aSpeed += this.aAccel; 23 | // Add speeds to positions 24 | this.pos = this.pos.add(this.speed); 25 | this.angle = withinPiRange(this.angle + this.aSpeed); 26 | this.boundsDetect(); //Detect boundaries for position and speed 27 | // delete sprites that are heavily oob 28 | if (this.pos.x < -this.game.width || this.pos.x > 2 * this.game.width || this.pos.y < -this.game.height || this.pos.y > 2 * this.game.height) { 29 | this.delete = true; 30 | } 31 | } 32 | boundsDetect() { 33 | // y speed bounds 34 | if (this.speed.y > this.maxSpeed) 35 | this.speed.y = this.maxSpeed; 36 | // x speed bounds 37 | if (this.speed.x > this.maxSpeed) 38 | this.speed.x = this.maxSpeed; 39 | // angle speed bounds 40 | if (this.aSpeed > this.maxASpeed) 41 | this.aSpeed = this.aSpeed = this.maxASpeed; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /typescript/src/spaceObjects/star.ts: -------------------------------------------------------------------------------- 1 | import Vector2 from '../helpers/Vector2.js' 2 | import Process from '../gameProcess.js' 3 | import Game from '../game.js' 4 | import Sprite from '../sprite.js' 5 | import Planet from './planet.js' 6 | import Torpedo from '../ship/torpedo.js' 7 | 8 | export default class Star extends Sprite { 9 | /* Default Params */ 10 | mass 11 | ctx = 'planets' 12 | initialRadius = 40 13 | radius = 50 + (Math.random() - 0.5) * 5 14 | orbitingPlanets:Planet[] = [] 15 | collapseCountdown = 0 16 | collapsing = false 17 | 18 | 19 | /* Other attributes */ 20 | process: Process | null = null 21 | constructor(...args: [pos: Vector2, game: Game]) { 22 | super(...args) 23 | this.image = this.game.images['star'] 24 | this.mass = (Math.PI * this.radius * this.radius * this.radius) / 10 25 | this.calcSize() 26 | } 27 | initialize(process: Process) { 28 | this.process = process 29 | } 30 | calcSize() { 31 | this.size = new Vector2(this.radius * 3, this.radius * 3) 32 | } 33 | addPlanet(planet: Planet) { 34 | this.orbitingPlanets.push(planet) 35 | } 36 | collapse(after: number) { 37 | this.collapsing = true 38 | this.collapseCountdown = 500 + after 39 | } 40 | update() { 41 | if (!this.process) return 42 | if (this.collapsing) { 43 | if (this.collapseCountdown <= 0) { 44 | this.delete = true 45 | const explosion = new Torpedo(Vector2.zero, this.pos, this.game) 46 | explosion.FRAMES_FOR_EXPLOSION = 162 47 | explosion.EXPLOSION_MAX_SCALE = 30 48 | explosion.explode() 49 | this.process.spawnDeletableObject(explosion) 50 | this.orbitingPlanets.forEach(planet => planet.leaveOrbit()) 51 | return 52 | } else if (this.collapseCountdown <= 500) { 53 | this.radius = this.initialRadius * (-Math.pow(-this.collapseCountdown+500, 5)/Math.pow(500, 5) + 1) 54 | this.calcSize() 55 | } 56 | this.collapseCountdown-- 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /typescript/src/controller.ts: -------------------------------------------------------------------------------- 1 | import Game from './game' 2 | 3 | export default class Controller { 4 | game 5 | pressed = { 6 | //Store if a key is pressed 7 | left: false, 8 | up: false, 9 | right: false, 10 | down: false, 11 | q: false, 12 | e: false, 13 | } 14 | keydown (event: KeyboardEvent) { 15 | let pressCode = event.keyCode 16 | if (pressCode === 37 || pressCode === 65) { 17 | this.pressed.left = true // Press Left 18 | } else if (pressCode === 38 || pressCode === 87) { 19 | this.pressed.up = true // Press Up 20 | } else if (pressCode === 39 || pressCode === 68) { 21 | this.pressed.right = true // Press Right 22 | } else if (pressCode === 40 || pressCode === 83) { 23 | this.pressed.down = true // Press Down 24 | } else if (pressCode === 81) { 25 | this.pressed.q = true 26 | } else if (pressCode === 69) { 27 | this.pressed.e = true 28 | } else if (pressCode === 32) { 29 | //Press space 30 | this.game.watchShip?.tryFire() 31 | } else if (pressCode === 77) { 32 | this.game.watchShip?.tryWarp() 33 | } else if (pressCode === 76) { 34 | this.game.watchShip?.tryLand() 35 | } 36 | } 37 | keyup (event: KeyboardEvent) { 38 | let pressCode = event.keyCode 39 | if (pressCode === 37 || pressCode === 65) { 40 | this.pressed.left = false // un-Press Left 41 | } else if (pressCode === 38 || pressCode === 87) { 42 | this.pressed.up = false // un-Press Up 43 | } else if (pressCode === 39 || pressCode === 68) { 44 | this.pressed.right = false // un-Press Right 45 | } else if (pressCode === 40 || pressCode === 83) { 46 | this.pressed.down = false // un-Press Down 47 | } else if (pressCode === 81) { 48 | this.pressed.q = false 49 | } else if (pressCode === 69) { 50 | this.pressed.e = false 51 | } 52 | } 53 | 54 | constructor(game: Game) { 55 | this.game = game 56 | document.addEventListener('keydown', this.keydown.bind(this)) 57 | document.addEventListener('keyup', this.keyup.bind(this)) 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /typescript/src/spaceObjects/warpGate.ts: -------------------------------------------------------------------------------- 1 | import Game from '../game.js' 2 | import Process from '../gameProcess.js' 3 | import Vector2 from '../helpers/Vector2.js' 4 | 5 | import ColonyShip from '../ship/colonyShip.js' 6 | import { SolarSystemName } from '../galaxies/solarSystem.js' 7 | import Sprite from '../sprite.js' 8 | import { keepInMap } from '../helpers/pos.js' 9 | import { withinPiRange } from '../helpers/Angles.js' 10 | export default class WarpGate extends Sprite { 11 | /* Constructor params */ 12 | destinationSolarSystem 13 | /* Default Attributes */ 14 | ctx = 'planets' 15 | size = new Vector2(50, 50) 16 | radius = 15 17 | mass = -100 18 | fourthDimension = false 19 | /* Other attributes */ 20 | process: Process | null = null 21 | 22 | constructor(destinationSolarystem: SolarSystemName, ...args: [pos: Vector2, game: Game]) { 23 | super(...args) 24 | this.image = this.game.images['warpgate'] 25 | this.destinationSolarSystem = destinationSolarystem 26 | this.mass += Math.random() 27 | } 28 | initialize(process: Process) { 29 | this.process = process 30 | } 31 | warp(ship: ColonyShip) { 32 | let newProcess: Process | undefined = this.game.processes.find((process) => process.solarSystem.name === this.destinationSolarSystem) 33 | if (newProcess) { 34 | ship.solarSystem = newProcess.solarSystem 35 | newProcess.appendShip(ship) 36 | ship.process.dealocateShip(ship) 37 | if (ship.primary) { 38 | newProcess.activate() 39 | this.game.drawnProcess = newProcess 40 | // newProcess.rerenderStatic(); 41 | } 42 | ship.process = newProcess 43 | } else throw Error('Process not found') 44 | } 45 | update() { 46 | if (this.fourthDimension) { 47 | this.angle += Math.random() 48 | this.accel = Vector2.right.rotateTo(this.angle).scale(0.1) 49 | if (keepInMap(this.pos)) { 50 | this.angle = withinPiRange(this.pos.angleToPoint(new Vector2(360, 270))) 51 | this.speed = Vector2.zero 52 | } 53 | super.update() 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /javascript/src/spaceObjects/warpGate.js: -------------------------------------------------------------------------------- 1 | import Vector2 from '../helpers/Vector2.js'; 2 | import Sprite from '../sprite.js'; 3 | import { keepInMap } from '../helpers/pos.js'; 4 | import { withinPiRange } from '../helpers/Angles.js'; 5 | export default class WarpGate extends Sprite { 6 | constructor(destinationSolarystem, ...args) { 7 | super(...args); 8 | /* Default Attributes */ 9 | this.ctx = 'planets'; 10 | this.size = new Vector2(50, 50); 11 | this.radius = 15; 12 | this.mass = -100; 13 | this.fourthDimension = false; 14 | /* Other attributes */ 15 | this.process = null; 16 | this.image = this.game.images['warpgate']; 17 | this.destinationSolarSystem = destinationSolarystem; 18 | this.mass += Math.random(); 19 | } 20 | initialize(process) { 21 | this.process = process; 22 | } 23 | warp(ship) { 24 | let newProcess = this.game.processes.find((process) => process.solarSystem.name === this.destinationSolarSystem); 25 | if (newProcess) { 26 | ship.solarSystem = newProcess.solarSystem; 27 | newProcess.appendShip(ship); 28 | ship.process.dealocateShip(ship); 29 | if (ship.primary) { 30 | newProcess.activate(); 31 | this.game.drawnProcess = newProcess; 32 | // newProcess.rerenderStatic(); 33 | } 34 | ship.process = newProcess; 35 | } 36 | else 37 | throw Error('Process not found'); 38 | } 39 | update() { 40 | if (this.fourthDimension) { 41 | this.angle += Math.random(); 42 | this.accel = Vector2.right.rotateTo(this.angle).scale(0.1); 43 | if (keepInMap(this.pos)) { 44 | this.angle = withinPiRange(this.pos.angleToPoint(new Vector2(360, 270))); 45 | this.speed = Vector2.zero; 46 | } 47 | super.update(); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /typescript/src/galaxies/solarSystem.ts: -------------------------------------------------------------------------------- 1 | import Vector2 from '../helpers/Vector2.js' 2 | import Asteroid from '../spaceObjects/asteroid.js' 3 | import WarpGate from '../spaceObjects/warpGate.js' 4 | import Planet from '../spaceObjects/planet.js' 5 | import AsteroidLauncher from '../spaceObjects/asteroidLauncher.js' 6 | import Game from '../game.js' 7 | import Star from '../spaceObjects/star.js' 8 | import BlackHole from '../spaceObjects/blackhole.js' 9 | 10 | const SolarSystemNames = [ 11 | 'Tutorial', 12 | 'Goose', 13 | 'Waterloo', 14 | 'StackOverflow', 15 | 'Hargun', 16 | 'Olivia', 17 | 'Derek', 18 | 'Ali', 19 | 'ECE105', 20 | 'Torvalds', 21 | 'Zac', 22 | 'Josiah', 23 | 'Elon', 24 | 'Gates', 25 | 'Turing' 26 | ] as const 27 | 28 | export type SolarSystemName = typeof SolarSystemNames[number] 29 | export default class SolarSystem { 30 | shipStartPosition = new Vector2(300, 300) 31 | warpGates: WarpGate[] 32 | planets: Planet[] 33 | asteroids: Asteroid[] 34 | star?: Star 35 | blackhole?: BlackHole 36 | asteroidLaunchers: AsteroidLauncher[] 37 | game: Game 38 | name: SolarSystemName 39 | galaxyName: string 40 | planetNames: string[] 41 | warpGateNames: string[] 42 | constructor(solarSystemName: SolarSystemName, galaxyName: string, game: Game, objects: { 43 | asteroids?: Asteroid[], 44 | warpGates?: WarpGate[], 45 | planets?: Planet[], 46 | asteroidLaunchers?: AsteroidLauncher[], 47 | star?: Star, 48 | blackhole?: BlackHole 49 | }) { 50 | this.game = game 51 | this.galaxyName = galaxyName 52 | this.name = solarSystemName 53 | this.asteroids = objects.asteroids ?? [] 54 | this.warpGates = objects.warpGates ?? [] 55 | this.planets = objects.planets ?? [] 56 | this.asteroidLaunchers = objects.asteroidLaunchers ?? [] 57 | this.star = objects.star 58 | this.blackhole = objects.blackhole 59 | this.planetNames = this.planets.map((planet) => planet.name) 60 | this.warpGateNames = this.warpGates.map((warpGate) => warpGate.destinationSolarSystem) 61 | } 62 | activate() {} 63 | } 64 | -------------------------------------------------------------------------------- /typescript/src/spaceObjects/planetComposition.ts: -------------------------------------------------------------------------------- 1 | export default class PlanetComposition { 2 | /* Attributes */ 3 | water 4 | air 5 | land 6 | metal 7 | safety 8 | temperature 9 | constructor(water: number, air: number, land: number, metal: number, safety: number, temperature: number) { 10 | this.water = water 11 | this.air = air 12 | this.land = land 13 | this.metal = metal 14 | this.safety = safety 15 | this.temperature = temperature 16 | this.maintainRange() 17 | } 18 | maintainRange() { 19 | (['water', 'air', 'land', 'metal', 'safety'] as const).forEach((key) => { 20 | if (this[key] < 0) throw Error(`Planet composition ${key} value must be greater than 0: ${this[key]}`) 21 | if (this[key] > 100) throw Error(`Planet composition ${key} value must be less than 100: ${this[key]}`) 22 | }) 23 | if (this.temperature > 100) throw Error('Planet composition temperature must be less than 100: ' + this.temperature) 24 | else if (this.temperature < -100) throw Error('Planet composition temperature must be greater than -100: ' + this.temperature) 25 | } 26 | get survivabilityChance() { 27 | let survivabilityChance = 0 28 | survivabilityChance += 8 * this.getDistribution100(this.water) 29 | survivabilityChance += 8 * this.getDistribution100(this.air) 30 | survivabilityChance += 6 * this.getDistribution100(this.land) 31 | survivabilityChance += 3 * this.getDistribution100(this.metal) 32 | survivabilityChance += 5 * this.getDistribution100(this.safety) 33 | survivabilityChance += 4 * this.getDistribution20(this.temperature) 34 | if (survivabilityChance > 100) survivabilityChance = 100 35 | return survivabilityChance 36 | } 37 | getDistribution100(num: number) { 38 | // s curve around 50 39 | // 0: 0.127 40 | // 50: 1.5 41 | // 100: 2.87 42 | return Math.atan(0.1 * (num - 50)) + 1.5 43 | } 44 | getDistribution20(num: number) { 45 | // Bell curve around 20 46 | // -100: 0.067 47 | // 0: 1.1 48 | // 20: 2 49 | // 100: 0.14 50 | return 10 / ((0.1 * (num - 20)) ** 2 + 5) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /typescript/src/galaxies/galaxy.ts: -------------------------------------------------------------------------------- 1 | import Game from '../game.js' 2 | import { BuildCompiles } from './compiles.js' 3 | import { BuildCracked } from './cracked.js' 4 | import { BuildJoziac } from './joziac.js' 5 | import { BuildNoob } from './noob.js' 6 | import SolarSystem, { SolarSystemName } from './solarSystem.js' 7 | 8 | //Parent class for galaxies, use data from galaxy jsons and GalaxyMaps scripts 9 | //The constructor is going to build the galaxies 10 | //Think of this as creating all the links between solar system levels 11 | export type GalaxyName = 'Noob' | 'Compiles' | 'Cracked' | 'Joziac' 12 | export default class Galaxy { 13 | /* constructor params */ 14 | name 15 | game 16 | /* Default Attributes */ 17 | solarSystems: SolarSystem[] = [] 18 | /* Other attributes */ 19 | startingSolarSystem: SolarSystem 20 | startingSolarSystemName 21 | solarSystemNames: SolarSystemName[] = [] 22 | constructor(galaxyName: GalaxyName, game: Game, solarSystems: SolarSystem[]) { 23 | this.name = galaxyName 24 | this.game = game 25 | this.solarSystems = solarSystems 26 | 27 | // Create solar systems with associated galaxy 28 | for (const solarSystem of this.solarSystems) { 29 | this.solarSystemNames.push(solarSystem.name) 30 | } 31 | 32 | // Set starting solar system to the first system in the list 33 | this.startingSolarSystem = this.solarSystems[0] 34 | this.startingSolarSystemName = this.solarSystemNames[0] 35 | } 36 | getSolarSystem(solarSystemName: string) { 37 | let returnSolarSystem: SolarSystem | false = false 38 | this.solarSystems.forEach((solarSystem) => { 39 | if (solarSystem.name === solarSystemName) { 40 | returnSolarSystem = solarSystem 41 | } 42 | }) 43 | return returnSolarSystem 44 | } 45 | } 46 | 47 | export const BuildGalaxy = (galaxyName: GalaxyName, game: Game): Galaxy => { 48 | switch (galaxyName) { 49 | case 'Noob': return BuildNoob(game) 50 | case 'Compiles': return BuildCompiles(game) 51 | case 'Cracked': return BuildCracked(game) 52 | case 'Joziac': return BuildJoziac(game) 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /javascript/src/spaceObjects/star.js: -------------------------------------------------------------------------------- 1 | import Vector2 from '../helpers/Vector2.js'; 2 | import Sprite from '../sprite.js'; 3 | import Torpedo from '../ship/torpedo.js'; 4 | export default class Star extends Sprite { 5 | constructor(...args) { 6 | super(...args); 7 | this.ctx = 'planets'; 8 | this.initialRadius = 40; 9 | this.radius = 50 + (Math.random() - 0.5) * 5; 10 | this.orbitingPlanets = []; 11 | this.collapseCountdown = 0; 12 | this.collapsing = false; 13 | /* Other attributes */ 14 | this.process = null; 15 | this.image = this.game.images['star']; 16 | this.mass = (Math.PI * this.radius * this.radius * this.radius) / 10; 17 | this.calcSize(); 18 | } 19 | initialize(process) { 20 | this.process = process; 21 | } 22 | calcSize() { 23 | this.size = new Vector2(this.radius * 3, this.radius * 3); 24 | } 25 | addPlanet(planet) { 26 | this.orbitingPlanets.push(planet); 27 | } 28 | collapse(after) { 29 | this.collapsing = true; 30 | this.collapseCountdown = 500 + after; 31 | } 32 | update() { 33 | if (!this.process) 34 | return; 35 | if (this.collapsing) { 36 | if (this.collapseCountdown <= 0) { 37 | this.delete = true; 38 | const explosion = new Torpedo(Vector2.zero, this.pos, this.game); 39 | explosion.FRAMES_FOR_EXPLOSION = 162; 40 | explosion.EXPLOSION_MAX_SCALE = 30; 41 | explosion.explode(); 42 | this.process.spawnDeletableObject(explosion); 43 | this.orbitingPlanets.forEach(planet => planet.leaveOrbit()); 44 | return; 45 | } 46 | else if (this.collapseCountdown <= 500) { 47 | this.radius = this.initialRadius * (-Math.pow(-this.collapseCountdown + 500, 5) / Math.pow(500, 5) + 1); 48 | this.calcSize(); 49 | } 50 | this.collapseCountdown--; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /typescript/src/spaceObjects/asteroid.ts: -------------------------------------------------------------------------------- 1 | import Sprite from '../sprite.js' 2 | import Meteor from './meteor.js' 3 | import Vector2 from '../helpers/Vector2.js' 4 | import Process from '../gameProcess.js' 5 | import Game from '../game.js' 6 | import { withinPiRange } from '../helpers/Angles.js' 7 | export default class Asteroid extends Sprite { 8 | /* Constructor params */ 9 | process: Process | null = null 10 | 11 | /* Other Attributes */ 12 | ctx = 'objects' 13 | delete = false //Once an item needs to be deleted and stop rendering, set to true 14 | size = new Vector2(30, 30) 15 | mass = 5 16 | gravitySignature = 0 17 | radius = 15 18 | hasExploded = false 19 | 20 | constructor(speed: Vector2, ...args: [pos: Vector2, game: Game]) { 21 | super(...args) 22 | this.speed = speed 23 | this.aSpeed = (Math.random() - 0.5) / 8 24 | this.image = this.game.images['asteroid'] 25 | } 26 | initialize(process: Process) { 27 | this.process = process 28 | } 29 | update() { 30 | //Add special update code here if needed 31 | super.update() 32 | } 33 | shatter() { 34 | // Create a bunch of meteors, somewhat randomly. 35 | this.delete = true 36 | // randomly 2-5 meteors 37 | const numMeteors = Math.floor(2 + Math.random() * 4) 38 | const spawnLocationAngle = (Math.PI * 2) / numMeteors 39 | const startAngle = Math.random() * Math.PI 40 | for (let i = 0; i < numMeteors; i++) { 41 | // space the meteors evenly around the perimeter of where the asteroid once was 42 | let angle = withinPiRange(i * spawnLocationAngle + startAngle + (Math.random() - 0.5) * 5 / numMeteors) 43 | const posFromCenter = Vector2.right.rotateTo(angle).scale(this.radius * 0.7) 44 | // generate a random direction and speed for meteor to go 45 | const velocity = Vector2.right.rotateTo(angle).scale(1 + 0.7 * Math.random()).add(this.speed) 46 | 47 | let meteor = new Meteor(velocity, posFromCenter.add(this.pos), this.game) 48 | if (this.process) this.process.spawnDeletableObject(meteor) 49 | else throw Error('Process not defined') 50 | } 51 | } 52 | receiveDamage() { 53 | // asteroids have 1hp 54 | this.shatter() 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /javascript/src/spaceObjects/planetComposition.js: -------------------------------------------------------------------------------- 1 | export default class PlanetComposition { 2 | constructor(water, air, land, metal, safety, temperature) { 3 | this.water = water; 4 | this.air = air; 5 | this.land = land; 6 | this.metal = metal; 7 | this.safety = safety; 8 | this.temperature = temperature; 9 | this.maintainRange(); 10 | } 11 | maintainRange() { 12 | ['water', 'air', 'land', 'metal', 'safety'].forEach((key) => { 13 | if (this[key] < 0) 14 | throw Error(`Planet composition ${key} value must be greater than 0: ${this[key]}`); 15 | if (this[key] > 100) 16 | throw Error(`Planet composition ${key} value must be less than 100: ${this[key]}`); 17 | }); 18 | if (this.temperature > 100) 19 | throw Error('Planet composition temperature must be less than 100: ' + this.temperature); 20 | else if (this.temperature < -100) 21 | throw Error('Planet composition temperature must be greater than -100: ' + this.temperature); 22 | } 23 | get survivabilityChance() { 24 | let survivabilityChance = 0; 25 | survivabilityChance += 8 * this.getDistribution100(this.water); 26 | survivabilityChance += 8 * this.getDistribution100(this.air); 27 | survivabilityChance += 6 * this.getDistribution100(this.land); 28 | survivabilityChance += 3 * this.getDistribution100(this.metal); 29 | survivabilityChance += 5 * this.getDistribution100(this.safety); 30 | survivabilityChance += 4 * this.getDistribution20(this.temperature); 31 | if (survivabilityChance > 100) 32 | survivabilityChance = 100; 33 | return survivabilityChance; 34 | } 35 | getDistribution100(num) { 36 | // s curve around 50 37 | // 0: 0.127 38 | // 50: 1.5 39 | // 100: 2.87 40 | return Math.atan(0.1 * (num - 50)) + 1.5; 41 | } 42 | getDistribution20(num) { 43 | // Bell curve around 20 44 | // -100: 0.067 45 | // 0: 1.1 46 | // 20: 2 47 | // 100: 0.14 48 | return 10 / ((0.1 * (num - 20)) ** 2 + 5); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /javascript/src/images.js: -------------------------------------------------------------------------------- 1 | const PlanetNames = [ 2 | 'Saturn', 3 | 'BlueStorm', 4 | 'Cheese', 5 | 'DarkLava', 6 | 'DarkNeptune', 7 | 'DeadGrey', 8 | 'EarthLookinAss', 9 | 'GreyLines', 10 | 'IceCube', 11 | 'IceWater', 12 | 'LavaRing', 13 | 'LightLava', 14 | 'Mars', 15 | 'Neptune', 16 | 'PinkSaturn', 17 | 'PurplePlanet', 18 | 'PurpleStripes', 19 | 'SandyCheeks', 20 | ]; 21 | const OtherImageNames = ['background', 'ship', 'thruster', 'thrusterFlame', 'turret', 'asteroid', 'torpedo', 'warpgate', 'blackhole', 'star']; 22 | export const imageSrcs = [ 23 | ['background', 'SpaceObjects/Space.png'], 24 | ['ship', 'ship/ColonyShip.png'], 25 | ['thruster', 'ship/ThrusterNozzle.png'], 26 | ['thrusterFlame', 'ship/ThrusterFlame.png'], 27 | ['turret', 'ship/TurretSprite.png'], 28 | ['asteroid', 'SpaceObjects/Meteor.png'], 29 | ['Saturn', 'planets/Saturn.png'], 30 | ['BlueStorm', 'planets/BlueStorm.png'], 31 | ['Cheese', 'planets/Cheese.png'], 32 | ['DarkLava', 'planets/DarkLava.png'], 33 | ['DarkNeptune', 'planets/DarkNeptune.png'], 34 | ['DeadGrey', 'planets/DeadGrey.png'], 35 | ['EarthLookinAss', 'planets/EarthLookinAss.png'], 36 | ['GreyLines', 'planets/GreyLines.png'], 37 | ['IceCube', 'planets/IceCube.png'], 38 | ['IceWater', 'planets/IceWater.png'], 39 | ['LavaRing', 'planets/LavaRing.png'], 40 | ['LightLava', 'planets/LightLava.png'], 41 | ['Mars', 'planets/Mars.png'], 42 | ['Neptune', 'planets/Neptune.png'], 43 | ['PinkSaturn', 'planets/PinkSaturn.png'], 44 | ['PurplePlanet', 'planets/PurplePlanet.png'], 45 | ['PurpleStripes', 'planets/PurpleStripes.png'], 46 | ['SandyCheeks', 'planets/SandyCheeks.png'], 47 | ['warpgate', 'SpaceObjects/WarpGate.png'], 48 | ['blackhole', 'SpaceObjects/BlackHole.png'], 49 | ['torpedo', 'SpaceObjects/Torpedo.png'], 50 | ['star', 'SpaceObjects/Star.png'], 51 | ['explosion0', 'explosions/0.png'], 52 | ['explosion1', 'explosions/1.png'], 53 | ['explosion2', 'explosions/2.png'], 54 | ['explosion3', 'explosions/3.png'], 55 | ['explosion4', 'explosions/4.png'], 56 | ['explosion5', 'explosions/5.png'], 57 | ['explosion6', 'explosions/6.png'], 58 | ['explosion7', 'explosions/7.png'], 59 | ['explosion8', 'explosions/8.png'], 60 | ]; 61 | -------------------------------------------------------------------------------- /javascript/src/spaceObjects/asteroid.js: -------------------------------------------------------------------------------- 1 | import Sprite from '../sprite.js'; 2 | import Meteor from './meteor.js'; 3 | import Vector2 from '../helpers/Vector2.js'; 4 | import { withinPiRange } from '../helpers/Angles.js'; 5 | export default class Asteroid extends Sprite { 6 | constructor(speed, ...args) { 7 | super(...args); 8 | /* Constructor params */ 9 | this.process = null; 10 | /* Other Attributes */ 11 | this.ctx = 'objects'; 12 | this.delete = false; //Once an item needs to be deleted and stop rendering, set to true 13 | this.size = new Vector2(30, 30); 14 | this.mass = 5; 15 | this.gravitySignature = 0; 16 | this.radius = 15; 17 | this.hasExploded = false; 18 | this.speed = speed; 19 | this.aSpeed = (Math.random() - 0.5) / 8; 20 | this.image = this.game.images['asteroid']; 21 | } 22 | initialize(process) { 23 | this.process = process; 24 | } 25 | update() { 26 | //Add special update code here if needed 27 | super.update(); 28 | } 29 | shatter() { 30 | // Create a bunch of meteors, somewhat randomly. 31 | this.delete = true; 32 | // randomly 2-5 meteors 33 | const numMeteors = Math.floor(2 + Math.random() * 4); 34 | const spawnLocationAngle = (Math.PI * 2) / numMeteors; 35 | const startAngle = Math.random() * Math.PI; 36 | for (let i = 0; i < numMeteors; i++) { 37 | // space the meteors evenly around the perimeter of where the asteroid once was 38 | let angle = withinPiRange(i * spawnLocationAngle + startAngle + (Math.random() - 0.5) * 5 / numMeteors); 39 | const posFromCenter = Vector2.right.rotateTo(angle).scale(this.radius * 0.7); 40 | // generate a random direction and speed for meteor to go 41 | const velocity = Vector2.right.rotateTo(angle).scale(1 + 0.7 * Math.random()).add(this.speed); 42 | let meteor = new Meteor(velocity, posFromCenter.add(this.pos), this.game); 43 | if (this.process) 44 | this.process.spawnDeletableObject(meteor); 45 | else 46 | throw Error('Process not defined'); 47 | } 48 | } 49 | receiveDamage() { 50 | // asteroids have 1hp 51 | this.shatter(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /typescript/src/ship/torpedo.ts: -------------------------------------------------------------------------------- 1 | import Sprite from '../sprite.js' 2 | import Vector2 from '../helpers/Vector2.js' 3 | import Process from '../gameProcess.js' 4 | import ColonyShip from './colonyShip.js' 5 | import Game from '../game.js' 6 | 7 | 8 | 9 | //Mini asteroid from asteroid explosion 10 | export default class Torpedo extends Sprite { 11 | /* Constructor Params */ 12 | fuseFrameDuration = 0 13 | frameCreated 14 | NUMBER_OF_EXPLOSION_SPRITES = 9 15 | FRAMES_FOR_EXPLOSION = 81 16 | EXPLOSION_MAX_SCALE = 10 17 | 18 | /* Other attributes */ 19 | delete = false //Once an item needs to be deleted and stop rendering, set to true 20 | size = new Vector2(10, 10) 21 | radius = 5 22 | originalSize = this.size.clone() 23 | originalRadius = this.radius 24 | ctx = 'objects' 25 | hasExploded = false 26 | frameExploded = 0 27 | process: Process | null = null 28 | 29 | constructor(velocity: Vector2, ...args: [pos: Vector2, game: Game]) { 30 | super(...args) 31 | this.speed = velocity 32 | this.angle = velocity.angle() // torpedoes point in the direction they are moving 33 | this.image = this.game.images['torpedo'] 34 | this.frameCreated = this.game.frame 35 | } 36 | update() { 37 | //Add special update code here if needed 38 | super.update() 39 | if (this.fuseFrameDuration > 0 && this.game.frame - this.frameCreated >= this.fuseFrameDuration) { 40 | this.explode() // Explode after fuse expires 41 | } 42 | if (this.hasExploded) { 43 | const currentFrame = this.game.frame 44 | const framesSinceExploded = currentFrame - this.frameExploded 45 | const explosionNumber = Math.floor((framesSinceExploded * this.NUMBER_OF_EXPLOSION_SPRITES) / this.FRAMES_FOR_EXPLOSION) 46 | if (explosionNumber < this.NUMBER_OF_EXPLOSION_SPRITES) { 47 | this.image = this.game.images['explosion' + explosionNumber] 48 | this.size = this.originalSize.scale(this.EXPLOSION_MAX_SCALE * Math.sqrt(framesSinceExploded / this.FRAMES_FOR_EXPLOSION)) 49 | this.radius = this.originalRadius * this.EXPLOSION_MAX_SCALE * Math.sqrt(framesSinceExploded / this.FRAMES_FOR_EXPLOSION) 50 | } else { 51 | this.delete = true 52 | } 53 | } 54 | } 55 | explode() { 56 | if (this.hasExploded) return 57 | this.speed = Vector2.zero 58 | this.hasExploded = true 59 | this.frameExploded = this.game.frame 60 | } 61 | receiveDamage() { 62 | // torpedoes have 1hp and explode when hitting something 63 | this.explode() 64 | } 65 | initialize(process: Process) { 66 | this.process = process 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /typescript/src/images.ts: -------------------------------------------------------------------------------- 1 | const PlanetNames = [ 2 | 'Saturn', 3 | 'BlueStorm', 4 | 'Cheese', 5 | 'DarkLava', 6 | 'DarkNeptune', 7 | 'DeadGrey', 8 | 'EarthLookinAss', 9 | 'GreyLines', 10 | 'IceCube', 11 | 'IceWater', 12 | 'LavaRing', 13 | 'LightLava', 14 | 'Mars', 15 | 'Neptune', 16 | 'PinkSaturn', 17 | 'PurplePlanet', 18 | 'PurpleStripes', 19 | 'SandyCheeks', 20 | ] as const 21 | 22 | const OtherImageNames = ['background', 'ship', 'thruster', 'thrusterFlame', 'turret', 'asteroid', 'torpedo', 'warpgate', 'blackhole', 'star'] as const 23 | 24 | type imageFileName = `${string}.png` 25 | 26 | export type PlanetImageName = typeof PlanetNames[number] 27 | type OtherImageName = typeof OtherImageNames[number] 28 | type ExplosionImageName = `explosion${number}` 29 | 30 | type ImageName = PlanetImageName | OtherImageName | ExplosionImageName 31 | 32 | export const imageSrcs: [ImageName, imageFileName][] = [ 33 | ['background', 'SpaceObjects/Space.png'], 34 | ['ship', 'ship/ColonyShip.png'], 35 | ['thruster', 'ship/ThrusterNozzle.png'], 36 | ['thrusterFlame', 'ship/ThrusterFlame.png'], 37 | ['turret', 'ship/TurretSprite.png'], 38 | ['asteroid', 'SpaceObjects/Meteor.png'], 39 | ['Saturn', 'planets/Saturn.png'], 40 | ['BlueStorm', 'planets/BlueStorm.png'], 41 | ['Cheese', 'planets/Cheese.png'], 42 | ['DarkLava', 'planets/DarkLava.png'], 43 | ['DarkNeptune', 'planets/DarkNeptune.png'], 44 | ['DeadGrey', 'planets/DeadGrey.png'], 45 | ['EarthLookinAss', 'planets/EarthLookinAss.png'], 46 | ['GreyLines', 'planets/GreyLines.png'], 47 | ['IceCube', 'planets/IceCube.png'], 48 | ['IceWater', 'planets/IceWater.png'], 49 | ['LavaRing', 'planets/LavaRing.png'], 50 | ['LightLava', 'planets/LightLava.png'], 51 | ['Mars', 'planets/Mars.png'], 52 | ['Neptune', 'planets/Neptune.png'], 53 | ['PinkSaturn', 'planets/PinkSaturn.png'], 54 | ['PurplePlanet', 'planets/PurplePlanet.png'], 55 | ['PurpleStripes', 'planets/PurpleStripes.png'], 56 | ['SandyCheeks', 'planets/SandyCheeks.png'], 57 | ['warpgate', 'SpaceObjects/WarpGate.png'], 58 | ['blackhole', 'SpaceObjects/BlackHole.png'], 59 | ['torpedo', 'SpaceObjects/Torpedo.png'], 60 | ['star', 'SpaceObjects/Star.png'], 61 | ['explosion0', 'explosions/0.png'], 62 | ['explosion1', 'explosions/1.png'], 63 | ['explosion2', 'explosions/2.png'], 64 | ['explosion3', 'explosions/3.png'], 65 | ['explosion4', 'explosions/4.png'], 66 | ['explosion5', 'explosions/5.png'], 67 | ['explosion6', 'explosions/6.png'], 68 | ['explosion7', 'explosions/7.png'], 69 | ['explosion8', 'explosions/8.png'], 70 | ] 71 | -------------------------------------------------------------------------------- /typescript/src/spaceObjects/asteroidLauncher.ts: -------------------------------------------------------------------------------- 1 | import Asteroid from './asteroid.js' 2 | import Vector2 from '../helpers/Vector2.js' 3 | import Process from '../gameProcess.js' 4 | import Game from '../game.js' 5 | import { withinPiRange } from '../helpers/Angles.js' 6 | 7 | const FRAMES_PER_SECOND = 60 8 | 9 | export default class AsteroidLauncher { 10 | /* Attributes */ 11 | game 12 | process: Process | null = null 13 | spawnPeriod 14 | random: boolean 15 | angle: number 16 | currentDelay = 0 17 | speed: number 18 | pos: Vector2 19 | constructor(game: Game, pos: Vector2, aimTo: Vector2, random = false, spawnPeriod = 4, speed: number = 0.75) { 20 | this.game = game 21 | this.pos = pos 22 | this.random = random 23 | this.speed = speed 24 | if (this.pos.x > -10 && this.pos.x < this.game.width + 10 && this.pos.y > -10 && this.pos.y < this.game.height + 10) { 25 | throw Error(`Can't build asteroid launcher within map, that is buggy, and instead of solving it I just say we don't allow the bug. Pos: ${pos.x}, ${pos.y}`) 26 | } 27 | if (this.pos.x < -this.game.width || this.pos.x > 2 * this.game.width || this.pos.y < -this.game.height || this.pos.y > 2 * this.game.height) { 28 | throw Error(`Can't build asteroid launcher too far out of the map, asteroids will not spawn. Pos: ${this.pos.x}, ${this.pos.y}`) 29 | } 30 | if (!(aimTo.x > 0 && aimTo.x < this.game.width && aimTo.y > 0 && aimTo.y < this.game.height)) { 31 | throw Error(`Must aim within map. Current Aim: ${aimTo.x}, ${aimTo.y}`) 32 | } 33 | this.spawnPeriod = spawnPeriod * FRAMES_PER_SECOND + (this.random ? Math.random() -0.5 : 0) 34 | // Expects positive radians values... rotation == -1 denotes random angle 35 | this.angle = this.pos.angleToPoint(aimTo) 36 | } 37 | initialize(process: Process) { 38 | this.process = process 39 | } 40 | 41 | launchAsteroid() { 42 | const speed = this.random ? Math.random() * 2 * this.speed : this.speed // random speed 43 | const angle = this.random ? withinPiRange(this.angle + Math.random() - 0.5) : this.angle 44 | const velocity = Vector2.right.rotate(angle).scale(speed) // random direction 45 | let asteroid = new Asteroid(velocity, this.pos, this.game) 46 | if (this.process) { 47 | asteroid.initialize(this.process) 48 | this.process.spawnDeletableObject(asteroid) 49 | } else throw Error('This.process is not defined') 50 | } 51 | 52 | update() { 53 | if (this.currentDelay > this.spawnPeriod) { 54 | this.launchAsteroid() 55 | this.currentDelay = 0 56 | } else { 57 | this.currentDelay++ 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /typescript/src/ship/passiveSensors.ts: -------------------------------------------------------------------------------- 1 | import { PassiveReading } from './passiveReading.js' 2 | import ColonyShip from './colonyShip.js' 3 | import RenderedObject from '../renderedObject.js' 4 | import Game from '../game.js' 5 | 6 | export default class PassiveSensors extends RenderedObject { 7 | parentShip: ColonyShip 8 | ctx = 'ships' 9 | cooldown = 0 10 | constructor(parentShip: ColonyShip, game: Game) { 11 | super(parentShip.pos, game) 12 | this.parentShip = parentShip 13 | this.game = game 14 | } 15 | scan(): PassiveReading[] | Error { 16 | this.parentShip.energyUsed += 25 17 | // Ensure solar system is initialized before performing scan 18 | if (!this.parentShip.solarSystem) throw Error('Cannot perform PassiveSensors scan until solar system initialized') 19 | if (this.cooldown) return new Error('sensors are still on cooldown') 20 | this.cooldown = 50 21 | // Note: angle must account for relative position of object to ship (not global position on board) 22 | // To find angle, find angle difference between the vector from ship to object & current ship heading 23 | // y coordinate is inverted due to the flipped board axis (greater y value indicates lower position) 24 | let readings: PassiveReading[] = [] 25 | for (const planet of this.parentShip.solarSystem.planets) { 26 | const angle = this.parentShip.pos.angleToPoint(planet.pos) 27 | const distance = this.parentShip.pos.distance(planet.pos) 28 | readings.push(new PassiveReading(angle, planet.mass / Math.pow(distance, 2))) 29 | } 30 | 31 | for (const warpgate of this.parentShip.solarSystem.warpGates) { 32 | const angle = this.parentShip.pos.angleToPoint(warpgate.pos) 33 | const distance = this.parentShip.pos.distance(warpgate.pos) 34 | readings.push(new PassiveReading(angle, warpgate.mass / Math.pow(distance, 2))) 35 | } 36 | 37 | return readings 38 | } 39 | draw() { 40 | if (!this.cooldown) return 41 | // Set the context's translation. 42 | const ctx: CanvasRenderingContext2D = this.game.contexts[this.ctx] 43 | ctx.setTransform(1, 0, 0, 1, ((this.pos.x / 10) * this.game.unit - this.game.camera.x) * this.game.zoom, ((this.pos.y / 10) * this.game.unit - this.game.camera.y) * this.game.zoom) 44 | ctx.fillStyle = `rgba(0, 0, 255, ${this.cooldown / 100})` 45 | ctx.lineWidth = 2 46 | const radius = (50 - this.cooldown) * 10 47 | ctx.beginPath() 48 | ctx.ellipse(0, 0, radius, radius, 0, 0, 2 * Math.PI) 49 | ctx.fill() 50 | } 51 | update() { 52 | if (this.cooldown > 0) this.cooldown -= 1 53 | else this.cooldown = 0 54 | this.pos = this.parentShip.pos 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /javascript/src/spaceObjects/asteroidLauncher.js: -------------------------------------------------------------------------------- 1 | import Asteroid from './asteroid.js'; 2 | import Vector2 from '../helpers/Vector2.js'; 3 | import { withinPiRange } from '../helpers/Angles.js'; 4 | const FRAMES_PER_SECOND = 60; 5 | export default class AsteroidLauncher { 6 | constructor(game, pos, aimTo, random = false, spawnPeriod = 4, speed = 0.75) { 7 | this.process = null; 8 | this.currentDelay = 0; 9 | this.game = game; 10 | this.pos = pos; 11 | this.random = random; 12 | this.speed = speed; 13 | if (this.pos.x > -10 && this.pos.x < this.game.width + 10 && this.pos.y > -10 && this.pos.y < this.game.height + 10) { 14 | throw Error(`Can't build asteroid launcher within map, that is buggy, and instead of solving it I just say we don't allow the bug. Pos: ${pos.x}, ${pos.y}`); 15 | } 16 | if (this.pos.x < -this.game.width || this.pos.x > 2 * this.game.width || this.pos.y < -this.game.height || this.pos.y > 2 * this.game.height) { 17 | throw Error(`Can't build asteroid launcher too far out of the map, asteroids will not spawn. Pos: ${this.pos.x}, ${this.pos.y}`); 18 | } 19 | if (!(aimTo.x > 0 && aimTo.x < this.game.width && aimTo.y > 0 && aimTo.y < this.game.height)) { 20 | throw Error(`Must aim within map. Current Aim: ${aimTo.x}, ${aimTo.y}`); 21 | } 22 | this.spawnPeriod = spawnPeriod * FRAMES_PER_SECOND + (this.random ? Math.random() - 0.5 : 0); 23 | // Expects positive radians values... rotation == -1 denotes random angle 24 | this.angle = this.pos.angleToPoint(aimTo); 25 | } 26 | initialize(process) { 27 | this.process = process; 28 | } 29 | launchAsteroid() { 30 | const speed = this.random ? Math.random() * 2 * this.speed : this.speed; // random speed 31 | const angle = this.random ? withinPiRange(this.angle + Math.random() - 0.5) : this.angle; 32 | const velocity = Vector2.right.rotate(angle).scale(speed); // random direction 33 | let asteroid = new Asteroid(velocity, this.pos, this.game); 34 | if (this.process) { 35 | asteroid.initialize(this.process); 36 | this.process.spawnDeletableObject(asteroid); 37 | } 38 | else 39 | throw Error('This.process is not defined'); 40 | } 41 | update() { 42 | if (this.currentDelay > this.spawnPeriod) { 43 | this.launchAsteroid(); 44 | this.currentDelay = 0; 45 | } 46 | else { 47 | this.currentDelay++; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /javascript/src/controller.js: -------------------------------------------------------------------------------- 1 | export default class Controller { 2 | constructor(game) { 3 | this.pressed = { 4 | //Store if a key is pressed 5 | left: false, 6 | up: false, 7 | right: false, 8 | down: false, 9 | q: false, 10 | e: false, 11 | }; 12 | this.game = game; 13 | document.addEventListener('keydown', this.keydown.bind(this)); 14 | document.addEventListener('keyup', this.keyup.bind(this)); 15 | } 16 | keydown(event) { 17 | var _a, _b, _c; 18 | let pressCode = event.keyCode; 19 | if (pressCode === 37 || pressCode === 65) { 20 | this.pressed.left = true; // Press Left 21 | } 22 | else if (pressCode === 38 || pressCode === 87) { 23 | this.pressed.up = true; // Press Up 24 | } 25 | else if (pressCode === 39 || pressCode === 68) { 26 | this.pressed.right = true; // Press Right 27 | } 28 | else if (pressCode === 40 || pressCode === 83) { 29 | this.pressed.down = true; // Press Down 30 | } 31 | else if (pressCode === 81) { 32 | this.pressed.q = true; 33 | } 34 | else if (pressCode === 69) { 35 | this.pressed.e = true; 36 | } 37 | else if (pressCode === 32) { 38 | //Press space 39 | (_a = this.game.watchShip) === null || _a === void 0 ? void 0 : _a.tryFire(); 40 | } 41 | else if (pressCode === 77) { 42 | (_b = this.game.watchShip) === null || _b === void 0 ? void 0 : _b.tryWarp(); 43 | } 44 | else if (pressCode === 76) { 45 | (_c = this.game.watchShip) === null || _c === void 0 ? void 0 : _c.tryLand(); 46 | } 47 | } 48 | keyup(event) { 49 | let pressCode = event.keyCode; 50 | if (pressCode === 37 || pressCode === 65) { 51 | this.pressed.left = false; // un-Press Left 52 | } 53 | else if (pressCode === 38 || pressCode === 87) { 54 | this.pressed.up = false; // un-Press Up 55 | } 56 | else if (pressCode === 39 || pressCode === 68) { 57 | this.pressed.right = false; // un-Press Right 58 | } 59 | else if (pressCode === 40 || pressCode === 83) { 60 | this.pressed.down = false; // un-Press Down 61 | } 62 | else if (pressCode === 81) { 63 | this.pressed.q = false; 64 | } 65 | else if (pressCode === 69) { 66 | this.pressed.e = false; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /typescript/src/galaxies/compiles.ts: -------------------------------------------------------------------------------- 1 | import Game from "../game.js" 2 | import { V2 } from "../helpers/Vector2.js" 3 | import Asteroid from "../spaceObjects/asteroid.js" 4 | import AsteroidLauncher from "../spaceObjects/asteroidLauncher.js" 5 | import Planet from "../spaceObjects/planet.js" 6 | import WarpGate from "../spaceObjects/warpGate.js" 7 | import Galaxy from "./galaxy.js" 8 | import SolarSystem from "./solarSystem.js" 9 | 10 | export const BuildCompiles = (game: Game): Galaxy => { 11 | /* 12 | Goose --> Waterloo --> StackOverflow --> Goose 13 | */ 14 | const Goose = new SolarSystem("Goose", "Compiles", game, { 15 | asteroids: [ 16 | new Asteroid(V2(0, 0), V2(210, 200), game), 17 | new Asteroid(V2(-0.3, 0), V2(700, 40), game), 18 | new Asteroid(V2(-0.2, -0.3), V2(370, 480), game), 19 | new Asteroid(V2(-0.4, 0), V2(510, 50), game), 20 | new Asteroid(V2(-0.2, -0.2), V2(110, 95), game), 21 | new Asteroid(V2(-0.2, 0.1), V2(460, 130), game), 22 | new Asteroid(V2(-0.2, -0.2), V2(460, 310), game), 23 | ], 24 | warpGates: [ 25 | new WarpGate('Waterloo', V2(343, 323), game) 26 | ], 27 | }) 28 | const Waterloo = new SolarSystem("Waterloo", "Compiles", game, { 29 | asteroids: [ 30 | new Asteroid(V2(0.1, 0), V2(200, 420), game), 31 | new Asteroid(V2(0.1, 0.2), V2(130, 170), game), 32 | new Asteroid(V2(0.2, 0.2), V2(430, 110), game), 33 | new Asteroid(V2(-0.3, -0.3), V2(680, 380), game), 34 | new Asteroid(V2(-0.4, 0.4), V2(460, 310), game), 35 | new Asteroid(V2(0.5, -0.5), V2(40, 280), game), 36 | ], 37 | warpGates: [ 38 | new WarpGate('StackOverflow', V2(32, 39), game) 39 | ], 40 | asteroidLaunchers: [ 41 | new AsteroidLauncher(game, V2(220, -20), V2(150, 150)), 42 | ] 43 | }) 44 | const StackOverflowAsteroids = [] 45 | for (let i = 0; i < 10; i++) { 46 | StackOverflowAsteroids.push(new Asteroid(V2(Math.random()-0.5, Math.random()-0.5), V2(((31 + 25 * i) % 71) * 10, ((17 + 29 * i) % 53) * 10), game)) 47 | } 48 | const StackOverflow = new SolarSystem("StackOverflow", "Compiles", game, { 49 | asteroids: StackOverflowAsteroids, 50 | planets: [ 51 | new Planet('Steve-O', 30, V2(690, 410), game), 52 | new Planet('COBOL', 25, V2(80, 400), game), 53 | ], 54 | warpGates: [ 55 | new WarpGate('Goose', V2(140, 270), game) 56 | ], 57 | asteroidLaunchers: [ 58 | new AsteroidLauncher(game, V2(-20, 320), V2(450, 450)), 59 | new AsteroidLauncher(game, V2(740, 300), V2(400, 400)), 60 | ] 61 | }) 62 | console.log(`Welcome to your first real challenge. 63 | You will have to fly through warp gates until you find a planet. 64 | To improve your survival chance, make sure to land on a viable planet!`) 65 | return new Galaxy('Compiles', game, [Goose, Waterloo, StackOverflow]) 66 | } -------------------------------------------------------------------------------- /javascript/src/ship/torpedo.js: -------------------------------------------------------------------------------- 1 | import Sprite from '../sprite.js'; 2 | import Vector2 from '../helpers/Vector2.js'; 3 | //Mini asteroid from asteroid explosion 4 | export default class Torpedo extends Sprite { 5 | constructor(velocity, ...args) { 6 | super(...args); 7 | /* Constructor Params */ 8 | this.fuseFrameDuration = 0; 9 | this.NUMBER_OF_EXPLOSION_SPRITES = 9; 10 | this.FRAMES_FOR_EXPLOSION = 81; 11 | this.EXPLOSION_MAX_SCALE = 10; 12 | /* Other attributes */ 13 | this.delete = false; //Once an item needs to be deleted and stop rendering, set to true 14 | this.size = new Vector2(10, 10); 15 | this.radius = 5; 16 | this.originalSize = this.size.clone(); 17 | this.originalRadius = this.radius; 18 | this.ctx = 'objects'; 19 | this.hasExploded = false; 20 | this.frameExploded = 0; 21 | this.process = null; 22 | this.speed = velocity; 23 | this.angle = velocity.angle(); // torpedoes point in the direction they are moving 24 | this.image = this.game.images['torpedo']; 25 | this.frameCreated = this.game.frame; 26 | } 27 | update() { 28 | //Add special update code here if needed 29 | super.update(); 30 | if (this.fuseFrameDuration > 0 && this.game.frame - this.frameCreated >= this.fuseFrameDuration) { 31 | this.explode(); // Explode after fuse expires 32 | } 33 | if (this.hasExploded) { 34 | const currentFrame = this.game.frame; 35 | const framesSinceExploded = currentFrame - this.frameExploded; 36 | const explosionNumber = Math.floor((framesSinceExploded * this.NUMBER_OF_EXPLOSION_SPRITES) / this.FRAMES_FOR_EXPLOSION); 37 | if (explosionNumber < this.NUMBER_OF_EXPLOSION_SPRITES) { 38 | this.image = this.game.images['explosion' + explosionNumber]; 39 | this.size = this.originalSize.scale(this.EXPLOSION_MAX_SCALE * Math.sqrt(framesSinceExploded / this.FRAMES_FOR_EXPLOSION)); 40 | this.radius = this.originalRadius * this.EXPLOSION_MAX_SCALE * Math.sqrt(framesSinceExploded / this.FRAMES_FOR_EXPLOSION); 41 | } 42 | else { 43 | this.delete = true; 44 | } 45 | } 46 | } 47 | explode() { 48 | if (this.hasExploded) 49 | return; 50 | this.speed = Vector2.zero; 51 | this.hasExploded = true; 52 | this.frameExploded = this.game.frame; 53 | } 54 | receiveDamage() { 55 | // torpedoes have 1hp and explode when hitting something 56 | this.explode(); 57 | } 58 | initialize(process) { 59 | this.process = process; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /javascript/src/ship/passiveSensors.js: -------------------------------------------------------------------------------- 1 | import { PassiveReading } from './passiveReading.js'; 2 | import RenderedObject from '../renderedObject.js'; 3 | export default class PassiveSensors extends RenderedObject { 4 | constructor(parentShip, game) { 5 | super(parentShip.pos, game); 6 | this.ctx = 'ships'; 7 | this.cooldown = 0; 8 | this.parentShip = parentShip; 9 | this.game = game; 10 | } 11 | scan() { 12 | this.parentShip.energyUsed += 25; 13 | // Ensure solar system is initialized before performing scan 14 | if (!this.parentShip.solarSystem) 15 | throw Error('Cannot perform PassiveSensors scan until solar system initialized'); 16 | if (this.cooldown) 17 | return new Error('sensors are still on cooldown'); 18 | this.cooldown = 50; 19 | // Note: angle must account for relative position of object to ship (not global position on board) 20 | // To find angle, find angle difference between the vector from ship to object & current ship heading 21 | // y coordinate is inverted due to the flipped board axis (greater y value indicates lower position) 22 | let readings = []; 23 | for (const planet of this.parentShip.solarSystem.planets) { 24 | const angle = this.parentShip.pos.angleToPoint(planet.pos); 25 | const distance = this.parentShip.pos.distance(planet.pos); 26 | readings.push(new PassiveReading(angle, planet.mass / Math.pow(distance, 2))); 27 | } 28 | for (const warpgate of this.parentShip.solarSystem.warpGates) { 29 | const angle = this.parentShip.pos.angleToPoint(warpgate.pos); 30 | const distance = this.parentShip.pos.distance(warpgate.pos); 31 | readings.push(new PassiveReading(angle, warpgate.mass / Math.pow(distance, 2))); 32 | } 33 | return readings; 34 | } 35 | draw() { 36 | if (!this.cooldown) 37 | return; 38 | // Set the context's translation. 39 | const ctx = this.game.contexts[this.ctx]; 40 | ctx.setTransform(1, 0, 0, 1, ((this.pos.x / 10) * this.game.unit - this.game.camera.x) * this.game.zoom, ((this.pos.y / 10) * this.game.unit - this.game.camera.y) * this.game.zoom); 41 | ctx.fillStyle = `rgba(0, 0, 255, ${this.cooldown / 100})`; 42 | ctx.lineWidth = 2; 43 | const radius = (50 - this.cooldown) * 10; 44 | ctx.beginPath(); 45 | ctx.ellipse(0, 0, radius, radius, 0, 0, 2 * Math.PI); 46 | ctx.fill(); 47 | } 48 | update() { 49 | if (this.cooldown > 0) 50 | this.cooldown -= 1; 51 | else 52 | this.cooldown = 0; 53 | this.pos = this.parentShip.pos; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ "main" ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ "main" ] 20 | schedule: 21 | - cron: '18 5 * * 4' 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | runs-on: ubuntu-latest 27 | permissions: 28 | actions: read 29 | contents: read 30 | security-events: write 31 | 32 | strategy: 33 | fail-fast: false 34 | matrix: 35 | language: [ 'typescript' ] 36 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] 37 | # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support 38 | 39 | steps: 40 | - name: Checkout repository 41 | uses: actions/checkout@v3 42 | 43 | # Initializes the CodeQL tools for scanning. 44 | - name: Initialize CodeQL 45 | uses: github/codeql-action/init@v2 46 | with: 47 | languages: ${{ matrix.language }} 48 | # If you wish to specify custom queries, you can do so here or in a config file. 49 | # By default, queries listed here will override any specified in a config file. 50 | # Prefix the list here with "+" to use these queries and those in the config file. 51 | 52 | # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs 53 | # queries: security-extended,security-and-quality 54 | 55 | 56 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 57 | # If this step fails, then you should remove it and run the build manually (see below) 58 | - name: Autobuild 59 | uses: github/codeql-action/autobuild@v2 60 | 61 | # ℹ️ Command-line programs to run using the OS shell. 62 | # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun 63 | 64 | # If the Autobuild fails above, remove it and uncomment the following three lines. 65 | # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. 66 | 67 | # - run: | 68 | # echo "Run, Build Application using script" 69 | # ./location_of_script_within_repo/buildscript.sh 70 | 71 | - name: Perform CodeQL Analysis 72 | uses: github/codeql-action/analyze@v2 73 | -------------------------------------------------------------------------------- /javascript/src/galaxies/compiles.js: -------------------------------------------------------------------------------- 1 | import { V2 } from "../helpers/Vector2.js"; 2 | import Asteroid from "../spaceObjects/asteroid.js"; 3 | import AsteroidLauncher from "../spaceObjects/asteroidLauncher.js"; 4 | import Planet from "../spaceObjects/planet.js"; 5 | import WarpGate from "../spaceObjects/warpGate.js"; 6 | import Galaxy from "./galaxy.js"; 7 | import SolarSystem from "./solarSystem.js"; 8 | export const BuildCompiles = (game) => { 9 | /* 10 | Goose --> Waterloo --> StackOverflow --> Goose 11 | */ 12 | const Goose = new SolarSystem("Goose", "Compiles", game, { 13 | asteroids: [ 14 | new Asteroid(V2(0, 0), V2(210, 200), game), 15 | new Asteroid(V2(-0.3, 0), V2(700, 40), game), 16 | new Asteroid(V2(-0.2, -0.3), V2(370, 480), game), 17 | new Asteroid(V2(-0.4, 0), V2(510, 50), game), 18 | new Asteroid(V2(-0.2, -0.2), V2(110, 95), game), 19 | new Asteroid(V2(-0.2, 0.1), V2(460, 130), game), 20 | new Asteroid(V2(-0.2, -0.2), V2(460, 310), game), 21 | ], 22 | warpGates: [ 23 | new WarpGate('Waterloo', V2(343, 323), game) 24 | ], 25 | }); 26 | const Waterloo = new SolarSystem("Waterloo", "Compiles", game, { 27 | asteroids: [ 28 | new Asteroid(V2(0.1, 0), V2(200, 420), game), 29 | new Asteroid(V2(0.1, 0.2), V2(130, 170), game), 30 | new Asteroid(V2(0.2, 0.2), V2(430, 110), game), 31 | new Asteroid(V2(-0.3, -0.3), V2(680, 380), game), 32 | new Asteroid(V2(-0.4, 0.4), V2(460, 310), game), 33 | new Asteroid(V2(0.5, -0.5), V2(40, 280), game), 34 | ], 35 | warpGates: [ 36 | new WarpGate('StackOverflow', V2(32, 39), game) 37 | ], 38 | asteroidLaunchers: [ 39 | new AsteroidLauncher(game, V2(220, -20), V2(150, 150)), 40 | ] 41 | }); 42 | const StackOverflowAsteroids = []; 43 | for (let i = 0; i < 10; i++) { 44 | StackOverflowAsteroids.push(new Asteroid(V2(Math.random() - 0.5, Math.random() - 0.5), V2(((31 + 25 * i) % 71) * 10, ((17 + 29 * i) % 53) * 10), game)); 45 | } 46 | const StackOverflow = new SolarSystem("StackOverflow", "Compiles", game, { 47 | asteroids: StackOverflowAsteroids, 48 | planets: [ 49 | new Planet('Steve-O', 30, V2(690, 410), game), 50 | new Planet('COBOL', 25, V2(80, 400), game), 51 | ], 52 | warpGates: [ 53 | new WarpGate('Goose', V2(140, 270), game) 54 | ], 55 | asteroidLaunchers: [ 56 | new AsteroidLauncher(game, V2(-20, 320), V2(450, 450)), 57 | new AsteroidLauncher(game, V2(740, 300), V2(400, 400)), 58 | ] 59 | }); 60 | console.log(`Welcome to your first real challenge. 61 | You will have to fly through warp gates until you find a planet. 62 | To improve your survival chance, make sure to land on a viable planet!`); 63 | return new Galaxy('Compiles', game, [Goose, Waterloo, StackOverflow]); 64 | }; 65 | -------------------------------------------------------------------------------- /typescript/src/ship/turretControls.ts: -------------------------------------------------------------------------------- 1 | import Vector2 from '../helpers/Vector2.js' 2 | import Torpedo from './torpedo.js' 3 | import RenderedObject from '../renderedObject.js' 4 | import ColonyShip from './colonyShip.js' 5 | import Game from '../game.js' 6 | import { angleDiff } from '../helpers/Angles.js' 7 | 8 | const TUBE_COOLDOWN_FRAMES = 100 9 | const NUMBER_OF_TUBES = 4 10 | const TORPEDO_VELOCITY = 3 11 | const FUSE_FRAME_DURATION = undefined 12 | 13 | export default class TurretControls extends RenderedObject { 14 | /* Constuctor Params */ 15 | parentShip 16 | 17 | /* Other Attributes */ 18 | cooldownFrames = TUBE_COOLDOWN_FRAMES 19 | numberOfTubes = NUMBER_OF_TUBES 20 | lastFrameFiredByTube = Array(NUMBER_OF_TUBES).fill(-Infinity) 21 | launchSpeed = TORPEDO_VELOCITY 22 | ctx = 'ships' 23 | 24 | constructor(parentShip: ColonyShip, ...args: [pos: Vector2, game: Game]) { 25 | super(...args) 26 | this.image = this.game.images['turret'] 27 | this.parentShip = parentShip 28 | this.pos = this.parentShip.pos 29 | } 30 | update() { 31 | this.pos = this.parentShip.pos 32 | } 33 | // This is currently assumed to be an absolute direction, it can be implemented as a relative direction through a change of basis 34 | aimTurret(angle: number) { 35 | this.parentShip.energyUsed += 0.1 * Math.abs(angleDiff(angle, this.angle)) 36 | //User called function for aiming turret 37 | this.angle = angle 38 | } 39 | getNumberOfTubes(): number { 40 | return this.numberOfTubes 41 | } 42 | getTubeCooldown(tubeIndex: number): number | Error { 43 | this.parentShip.energyUsed += 0.05 44 | if (tubeIndex >= 0 && tubeIndex < NUMBER_OF_TUBES) { 45 | //User called function for getting tube cooldown 46 | const currentFrame = this.parentShip.game.frame 47 | const framesWaited = currentFrame - this.lastFrameFiredByTube[tubeIndex] 48 | const framesToWait = Math.max(this.cooldownFrames - framesWaited, 0) 49 | return framesToWait 50 | } else { 51 | // Invalid tubeIndex 52 | return new Error('getTubeCooldownFailed due to invalid tube index; expected tubeIndex from 0 (inclusive) up to ' + NUMBER_OF_TUBES + ' (exclusive) but received ' + tubeIndex) 53 | } 54 | } 55 | fireTorpedo(tubeIndex: number): Error | null { 56 | this.parentShip.energyUsed += 2 57 | //User called function for firing torpedo 58 | //check for valid torpedo stuff, then create new one 59 | if (tubeIndex >= 0 && tubeIndex < NUMBER_OF_TUBES) { 60 | const tubeCooldownResponse = this.getTubeCooldown(tubeIndex) 61 | if (tubeCooldownResponse instanceof Error) return tubeCooldownResponse 62 | else if (tubeCooldownResponse === 0) { 63 | const relativeVelocity = new Vector2(0, this.launchSpeed).rotateTo(this.angle) 64 | const torpedoVelocity = relativeVelocity.add(this.parentShip.speed) 65 | const newTorpedo = new Torpedo(torpedoVelocity, this.parentShip.pos, this.parentShip.game) 66 | this.parentShip.process.spawnDeletableObject(newTorpedo) 67 | this.parentShip.torpedoesFired++ 68 | this.parentShip.energyUsed += 6 69 | this.lastFrameFiredByTube[tubeIndex] = this.parentShip.game.frame 70 | return null 71 | } else { 72 | return new Error('fireTorpedo failed due to internal call to getTubeCooldown not returning zero tubeCooldown response for tubeIndex ' + tubeIndex) 73 | } 74 | } else { 75 | return new Error('fireTorpedo due to invalid tube index; expected tubeIndex from 0 (inclusive) up to ' + NUMBER_OF_TUBES + ' (exclusive) but received ' + tubeIndex) 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /typescript/src/helpers/Vector2.ts: -------------------------------------------------------------------------------- 1 | import Matrix2 from './Matrix2' 2 | export const V2 = (x: number, y: number): Vector2 => new Vector2(x, y) 3 | export default class Vector2 { 4 | x: number 5 | y: number 6 | /* 7 | I rewrote the whole library to be a class so that 8 | we can create our own static methods and functions 9 | */ 10 | constructor(x: number, y: number) { 11 | this.x = x 12 | this.y = y 13 | } 14 | 15 | static zero = new Vector2(0, 0) 16 | static right = new Vector2(1, 0) 17 | static one = new Vector2(1, 1) 18 | 19 | set(x: number = 0, y: number = 0) { 20 | this.x = x 21 | this.y = y 22 | } 23 | clone() { 24 | return new Vector2(this.x, this.y) 25 | } 26 | equals(vector: Vector2) { 27 | return this.x === vector.x && this.y === vector.y 28 | } 29 | 30 | add(vector: Vector2) { 31 | return new Vector2(this.x + vector.x, this.y + vector.y) 32 | } 33 | 34 | subtract(vector: Vector2) { 35 | return new Vector2(this.x - vector.x, this.y - vector.y) 36 | } 37 | 38 | scale(scalar: number) { 39 | return new Vector2(this.x * scalar, this.y * scalar) 40 | } 41 | scaleTo(magnitude: number) { 42 | let ratio = magnitude / this.magnitude() 43 | return this.scale(ratio) 44 | } 45 | 46 | dot(vector: Vector2) { 47 | return this.x * vector.x + this.y * vector.y 48 | } 49 | 50 | moveTowards(vector: Vector2, t: number) { 51 | // Linearly interpolates between vectors A and B by t. 52 | // t = 0 returns A, t = 1 returns B 53 | t = Math.min(t, 1) // still allow negative t 54 | let diff = vector.subtract(this) 55 | return this.add(diff.scale(t)) 56 | } 57 | 58 | magnitude() { 59 | return Math.sqrt(this.magnitudeSqr()) 60 | } 61 | 62 | magnitudeSqr() { 63 | return this.x * this.x + this.y * this.y 64 | } 65 | 66 | distance(vector: Vector2) { 67 | return Math.sqrt(this.distanceSqr(vector)) 68 | } 69 | 70 | distanceSqr(vector: Vector2) { 71 | let deltaX = this.x - vector.x 72 | let deltaY = this.y - vector.y 73 | return deltaX * deltaX + deltaY * deltaY 74 | } 75 | 76 | normalize() { 77 | let mag = this.magnitude() 78 | let vector = this.clone() 79 | if (Math.abs(mag) < 1e-9) { 80 | vector.x = 0 81 | vector.y = 0 82 | } else { 83 | vector.x /= mag 84 | vector.y /= mag 85 | } 86 | return vector 87 | } 88 | 89 | angle() { 90 | return Math.atan2(this.y, this.x) 91 | } 92 | angleTo(vector: Vector2) { 93 | return vector.angle() - this.angle() 94 | } 95 | 96 | angleToPoint(point: Vector2) { 97 | return point.subtract(this).angle() 98 | } 99 | 100 | rotate(alpha: number) { 101 | let cos = Math.cos(alpha) 102 | let sin = Math.sin(alpha) 103 | let vector = new Vector2(this.x * cos - this.y * sin, this.x * sin + this.y * cos) 104 | return vector 105 | } 106 | 107 | rotateTo(angle: number) { 108 | let rotateBy = angle - this.angle() 109 | return this.rotate(rotateBy) 110 | } 111 | 112 | toPrecisionString(precision: number) { 113 | let vector = this.clone() 114 | let x = vector.x.toFixed(precision) 115 | let y = vector.y.toFixed(precision) 116 | return { x: x, y: y } 117 | } 118 | 119 | toString() { 120 | let vector = this.toPrecisionString(1) 121 | return '[' + vector.x + '; ' + vector.y + ']' 122 | } 123 | 124 | // M is a Matrix2, returns Mv 125 | matrixMultiply(M: Matrix2) { 126 | return new Vector2(M.m[0][0] * this.x + M.m[0][1] * this.y, M.m[1][0] * this.x + M.m[1][1] * this.y) 127 | } 128 | } 129 | --------------------------------------------------------------------------------