notes: /* empty */
libs:
  random: {}
  place:
    gridY: 512
    gridX: 512
  keyboard: {}
  pointer:
    preventdefault: false
    startlocked: false
soundtick: 0
roomtick: 1
templatetick: 6
styletick: 3
starting: 0
settings:
  export:
    linux: true
    windows: true
    mac: true
    functionWrap: false
    codeModifier: none
    bundleAssetTree: false
    autocloseDesktop: true
    bundleAssetTypes:
      texture: true
      template: true
      room: true
      behavior: false
      font: false
      sound: false
      style: false
      tandem: false
      typefaces: !<tag:yaml.org,2002:js/undefined> ''
    showErrors: true
    errorsLink: ''
  branding:
    icon: -1
    accent: '#446adb'
    invertPreloaderScheme: true
  rendering:
    maxFPS: 60
    pixelatedrender: false
    highDensity: true
    usePixiLegacy: true
    desktopMode: maximized
    mobileScreenOrientation: unspecified
    viewMode: fastScale
  authoring:
    title: Space Shooter (tutorial)
    author: Cosmo Myzrail Gorynych
    site: 'https://ctjs.rocks/'
    version:
      - 0
      - 0
      - 0
    versionPostfix: ''
  fps: 30
palette:
  - 'rgba(0,0,0,0.61)'
startroom: 8eced6ed-b52a-4344-8266-3fa909005671
ctjsVersion: 5.0.0
scripts: []
actions:
  - name: Shoot
    methods:
      - code: keyboard.Space
      - code: pointer.Primary
  - name: MoveY
    methods:
      - code: keyboard.ArrowUp
        multiplier: -1
      - code: keyboard.ArrowDown
      - code: keyboard.KeyW
        multiplier: -1
      - code: keyboard.KeyS
  - name: MoveX
    methods:
      - code: keyboard.KeyA
        multiplier: -1
      - code: keyboard.KeyD
      - code: keyboard.ArrowLeft
        multiplier: -1
      - code: keyboard.ArrowRight
texturetick: 7
contentTypes: []
language: typescript
assets:
  - name: PlayerShip
    depth: 0
    uid: f5832845-7841-408b-bae7-a72aaffcae6c
    lastmod: 1661144793029
    extends: {}
    texture: a82335b3-69b6-4de0-bec1-da2dea358142
    events:
      - lib: core
        arguments: {}
        code: >-
          /**
           * Move the ship
           * See Settings > Edit actions panel
           * and "Actions" in the docs.
           */

          this.x += 8 * u.delta * actions.MoveX.value; // Move by X axis

          this.y += 8 * u.delta * actions.MoveY.value; // Move by Y axis


          /**
           * Check whether the ship fell off the viewport
           */
          if (this.x < 0) { // Have the ship crossed the left border?
              this.x = 0; // Go back to the left border
          }

          if (this.x > camera.width) { // Have the ship crossed the right
          border?
              this.x = camera.width; // Go back to the right border
          }

          if (this.y < camera.height / 2) { // Have the ship crossed the middle
          line?
              this.y = camera.height / 2; // Go back to the middle line
          }

          if (this.y > camera.height) { // Have the ship crossed the bottom
          border?
              this.y = camera.height; // Go back to the bottom border
          }


          this.move();
        eventKey: OnStep
      - eventKey: OnActionPress
        code: 'templates.copy(''Laser_Blue'', this.x, this.y);'
        arguments:
          action: Shoot
        lib: core
      - eventKey: collisionCGroup
        code: |-
          if (templates.isCopy(other)) {
              other.kill = true;    
          }
          rooms.current.lives --;
          if (rooms.current.lives <= 0) {
              this.kill = true;
              setTimeout(function() {
                  rooms.switch('Main');
              }, 1000);
          }
        arguments:
          group: Hostile
        lib: place
    type: template
    loopAnimation: true
    visible: true
    blendMode: normal
    animationFPS: 30
    playAnimationOnStart: false
    behaviors: []
    baseClass: AnimatedSprite
    nineSliceSettings:
      left: 16
      top: 16
      right: 16
      bottom: 16
    style: -1
    extendTypes: ''
  - name: Laser_Red
    depth: 0
    uid: ebe33c0f-6f27-4123-ac8a-3029404dbc7a
    lastmod: 1703591612127
    extends:
      cgroup: Hostile
    texture: 083c3d39-1a4a-44f2-9fae-e4043e45f28e
    events:
      - lib: core
        arguments: {}
        code: |-
          this.speed = 480;
          this.direction = 90;

          this.angle = random.deg();
        eventKey: OnCreate
      - lib: core
        arguments: {}
        code: |-
          if (this.y > camera.height + 40) {
              this.kill = true;
          }

          this.move();

          this.angle -= 250 * u.time;
        eventKey: OnStep
    type: template
    loopAnimation: true
    visible: true
    blendMode: normal
    animationFPS: 30
    playAnimationOnStart: false
    behaviors: []
    baseClass: AnimatedSprite
    nineSliceSettings:
      left: 16
      top: 16
      right: 16
      bottom: 16
    style: -1
    extendTypes: ''
  - name: Laser_Blue
    depth: 0
    uid: cd732ad2-d2ae-4745-b6d8-07a57a9d3a2e
    lastmod: 1703590425345
    extends: {}
    texture: 3dde237d-ec51-4153-8b31-58279ece7c55
    events:
      - lib: core
        arguments: {}
        code: |-
          this.speed = 1000;
          this.direction = 270;
        eventKey: OnCreate
      - lib: core
        arguments: {}
        code: |-
          if (this.y < -40) {
              this.kill = true;
          }

          this.move();
        eventKey: OnStep
    type: template
    loopAnimation: true
    visible: true
    blendMode: normal
    animationFPS: 30
    playAnimationOnStart: false
    behaviors: []
    baseClass: AnimatedSprite
    nineSliceSettings:
      left: 16
      top: 16
      right: 16
      bottom: 16
    style: -1
    extendTypes: ''
  - name: EnemyShip
    depth: 0
    uid: 5d3e8a47-30e6-45b1-8b36-d445fdcb8e14
    lastmod: 1703591109917
    extends:
      cgroup: Hostile
    texture: feb33556-81c7-4794-a806-da5ddea5be81
    events:
      - lib: core
        arguments: {}
        code: |-
          this.speed = 180;
          this.direction = 90;

          this.timer1 = 1;
        eventKey: OnCreate
      - lib: core
        arguments: {}
        code: |-
          this.move();

          if (this.y > camera.height + 80) {
              this.kill = true;
          }
        eventKey: OnStep
      - eventKey: collisionTemplate
        code: |-
          other.kill = true;
          this.kill = true;
          rooms.current.score += 100;
        arguments:
          template: cd732ad2-d2ae-4745-b6d8-07a57a9d3a2e
        lib: place
      - eventKey: Timer1
        code: |-
          this.timer1 = 3;
          templates.copy('Laser_Red', this.x, this.y + 32);
        arguments:
          isUi: false
          name: Shoot
        lib: core
    type: template
    loopAnimation: true
    visible: true
    blendMode: normal
    animationFPS: 30
    playAnimationOnStart: false
    behaviors: []
    baseClass: AnimatedSprite
    nineSliceSettings:
      left: 16
      top: 16
      right: 16
      bottom: 16
    style: -1
    extendTypes: ''
  - name: Asteroid_Medium
    depth: 0
    uid: f829b135-ac68-4193-9980-d367e90448a1
    lastmod: 1703591593620
    extends:
      cgroup: Hostile
    texture: aa5664f9-a2c3-47b2-8f0f-2dfead9c67c9
    events:
      - lib: core
        arguments: {}
        code: |-
          this.speed = random.range(50, 200);
          this.direction = random.range(90 - 30, 90 + 30);
        eventKey: OnCreate
      - lib: core
        arguments: {}
        code: |-
          this.move();

          if (this.y > camera.height + 80) {
              this.kill = true;
          }
        eventKey: OnStep
      - eventKey: collisionTemplate
        code: |-
          other.kill = true;
          this.kill = true;
          rooms.current.score += 10;
        arguments:
          template: cd732ad2-d2ae-4745-b6d8-07a57a9d3a2e
        lib: place
    type: template
    loopAnimation: true
    visible: true
    blendMode: normal
    animationFPS: 30
    playAnimationOnStart: false
    behaviors: []
    baseClass: AnimatedSprite
    nineSliceSettings:
      left: 16
      top: 16
      right: 16
      bottom: 16
    style: -1
    extendTypes: ''
  - name: Asteroid_Big
    depth: 0
    uid: 41fbc5fe-0f41-4151-b7bf-26acefce80ae
    lastmod: 1703591590773
    extends:
      cgroup: Hostile
    texture: 4e5cb233-48f8-4f20-abaf-384f4551e1e9
    events:
      - lib: core
        arguments: {}
        code: |-
          this.speed = random.range(50, 200);
          this.direction = random.range(90 - 30, 90 + 30);
        eventKey: OnCreate
      - lib: core
        arguments: {}
        code: |-
          this.move();

          if (this.y > camera.height + 80) {
              this.kill = true;
          }
        eventKey: OnStep
      - eventKey: collisionTemplate
        code: |-
          other.kill = true;
          this.kill = true;
          templates.copy('Asteroid_Medium', this.x, this.y);
          templates.copy('Asteroid_Medium', this.x, this.y);
          rooms.current.score += 25;
        arguments:
          template: cd732ad2-d2ae-4745-b6d8-07a57a9d3a2e
        lib: place
    type: template
    loopAnimation: true
    visible: true
    blendMode: normal
    animationFPS: 30
    playAnimationOnStart: false
    behaviors: []
    baseClass: AnimatedSprite
    nineSliceSettings:
      left: 16
      top: 16
      right: 16
      bottom: 16
    style: -1
    extendTypes: ''
  - name: Main
    onleave: ''
    width: 800
    height: 800
    backgrounds:
      - depth: -5
        texture: 004e6497-a9f8-4a44-8b43-346ee79e6514
        shiftX: 0
        shiftY: 0
        parallaxX: 1
        parallaxY: 1
        movementX: 0
        movementY: 0.5
        scaleX: 1
        scaleY: 1
        repeat: repeat
    uid: 8eced6ed-b52a-4344-8266-3fa909005671
    grid: 80
    lastmod: 1703591490194
    thumbnail: 1
    gridX: 40
    gridY: 40
    tiles:
      - depth: -10
        tiles: []
        extends: {}
        hidden: false
    copies:
      - x: 400
        'y': 720
        opacity: 1
        tint: 16777215
        scale:
          x: 1
          'y': 1
        rotation: 0
        uid: f5832845-7841-408b-bae7-a72aaffcae6c
        exts: {}
        customProperties: {}
        bindings: {}
      - x: 40
        'y': 40
        opacity: 1
        tint: 16777215
        scale:
          x: 1
          'y': 1
        rotation: 0
        uid: RM4JgQc2cFpPTc
        exts: {}
        customProperties: {}
        bindings: {}
        customAnchor:
          x: 0
          'y': 0.5
      - x: 760
        'y': 40
        opacity: 1
        tint: 16777215
        scale:
          x: 1
          'y': 1
        rotation: 0
        uid: 7Gpfq12g2PHGbf
        exts: {}
        customProperties: {}
        bindings: {}
        customAnchor:
          x: 1
          'y': 0.5
    events:
      - lib: core
        arguments: {}
        code: |-
          this.timer1 = 0.3; // asteroid timer
          this.timer2 = 3; // enemy timer

          this.score = 0;
          this.lives = 3;
        eventKey: OnRoomStart
      - eventKey: Timer1
        code: >-
          // asteroid timer

          this.timer1 = random.range(0.3, 3);

          templates.copy(random.dice('Asteroid_Big', 'Asteroid_Medium'),
          random(camera.width), -100);
        arguments:
          name: Asteroids
          isUi: false
        lib: core
      - eventKey: Timer2
        code: |-
          // enemy timer
          this.timer2 = random.range(3, 6);
          templates.copy('EnemyShip', random(camera.width), -100);
        arguments:
          isUi: false
          name: Ships
        lib: core
    type: room
    simulate: true
    extends: {}
    isUi: false
    follow: -1
    behaviors: []
    extendTypes: ''
  - name: ScoreText
    uid: 4f2f6d4b-a339-4e30-98f3-80db10aafc4f
    origname: s1
    font:
      family: sans-serif
      size: 32
      weight: '800'
      italic: true
      valign: top
      halign: left
    lastmod: 1703591534722
    fill:
      type: '0'
      color: '#54BEFF'
    stroke:
      color: '#FFFFFF'
      weight: 4
    type: style
    shadow:
      color: 'rgba(0,0,0,0.61)'
      x: -2
      'y': 2
      blur: 3
    typeface: -1
  - name: LivesText
    uid: b1e32885-9439-412d-9220-7d18fae8bf91
    origname: s3
    font:
      family: sans-serif
      size: 32
      weight: '800'
      italic: true
      valign: top
      halign: left
    lastmod: 1703591496995
    fill:
      type: '0'
      color: '#FF7388'
    shadow:
      color: 'rgba(0,0,0,0.61)'
      x: -2
      'y': 2
      blur: 3
    stroke:
      color: '#FFFFFF'
      weight: 4
    type: style
    typeface: -1
  - name: PlayerShip
    untill: 0
    grid:
      - 1
      - 1
    axis:
      - 55.5
      - 39.25
    marginx: 0
    marginy: 0
    imgWidth: 112
    imgHeight: 75
    width: 112
    height: 75
    offx: 0
    offy: 0
    origname: i1.png
    shape: strip
    left: 50
    right: 50
    top: 12
    bottom: 32
    lastmod: 1552035691040
    r: 37
    uid: a82335b3-69b6-4de0-bec1-da2dea358142
    stripPoints:
      - x: 11.5
        'y': -19
      - x: 55.5
        'y': 3.5
      - x: 38.25
        'y': 31.75
      - x: -38.5
        'y': 32
      - x: -55.25
        'y': 4
      - x: -11.25
        'y': -18.25
      - x: 0.25
        'y': -40.5
    closedStrip: true
    padding: 1
    type: texture
  - name: LaserRed
    untill: 0
    grid:
      - 1
      - 1
    axis:
      - 24
      - 23
    marginx: 0
    marginy: 0
    imgWidth: 48
    imgHeight: 46
    width: 48
    height: 46
    offx: 0
    offy: 0
    origname: i2.png
    shape: circle
    left: 0
    right: 48
    top: 0
    bottom: 46
    lastmod: 1552035694113
    r: 23
    uid: 083c3d39-1a4a-44f2-9fae-e4043e45f28e
    padding: 1
    type: texture
  - name: Laser_Blue
    untill: 0
    grid:
      - 1
      - 1
    axis:
      - 4
      - 27
    marginx: 0
    marginy: 0
    imgWidth: 9
    imgHeight: 54
    width: 9
    height: 54
    offx: 0
    offy: 0
    origname: i3.png
    shape: rect
    left: 4
    right: 5
    top: 27
    bottom: 27
    lastmod: 1552035707940
    uid: 3dde237d-ec51-4153-8b31-58279ece7c55
    padding: 1
    type: texture
  - name: EnemyShip
    untill: 0
    grid:
      - 1
      - 1
    axis:
      - 51
      - 42
    marginx: 0
    marginy: 0
    imgWidth: 103
    imgHeight: 84
    width: 103
    height: 84
    offx: 0
    offy: 0
    origname: i4.png
    shape: strip
    left: 51
    right: 52
    top: 42
    bottom: 42
    lastmod: 1703591084472
    r: 42
    uid: feb33556-81c7-4794-a806-da5ddea5be81
    stripPoints:
      - x: 27.75
        'y': -35.25
      - x: 50.75
        'y': -2.75
      - x: 37.5
        'y': 41.5
      - x: -38.75
        'y': 40.5
      - x: -51
        'y': -2
      - x: -25.5
        'y': -36.25
    closedStrip: true
    padding: 1
    type: texture
  - name: Asteroid_Medium
    untill: 0
    grid:
      - 1
      - 1
    axis:
      - 21
      - 21
    marginx: 0
    marginy: 0
    imgWidth: 43
    imgHeight: 43
    width: 43
    height: 43
    offx: 0
    offy: 0
    origname: i5.png
    shape: strip
    left: 21
    right: 22
    top: 21
    bottom: 22
    lastmod: 1552035960459
    r: 21
    uid: aa5664f9-a2c3-47b2-8f0f-2dfead9c67c9
    stripPoints:
      - x: 17.5
        'y': -18
      - x: 20.5
        'y': 8.25
      - x: -0.75
        'y': 20.75
      - x: -13
        'y': 17
      - x: -21.25
        'y': -3.25
      - x: -9.5
        'y': -19.25
    closedStrip: true
    padding: 1
    type: texture
  - name: Asteroid_Big
    untill: 0
    grid:
      - 1
      - 1
    axis:
      - 50
      - 42
    marginx: 0
    marginy: 0
    imgWidth: 101
    imgHeight: 84
    width: 101
    height: 84
    offx: 0
    offy: 0
    origname: i6.png
    shape: strip
    left: 50
    right: 51
    top: 42
    bottom: 42
    lastmod: 1552035775666
    r: 42
    uid: 4e5cb233-48f8-4f20-abaf-384f4551e1e9
    stripPoints:
      - x: 50.75
        'y': -2
      - x: 34.5
        'y': 32.5
      - x: 9.75
        'y': 28.5
      - x: -22.75
        'y': 40.75
      - x: -50.5
        'y': 8.75
      - x: -33.5
        'y': -40.75
      - x: 23.5
        'y': -41.5
    closedStrip: true
    padding: 1
    type: texture
  - name: BG
    untill: 0
    grid:
      - 1
      - 1
    axis:
      - 0
      - 0
    marginx: 0
    marginy: 0
    imgWidth: 256
    imgHeight: 256
    width: 256
    height: 256
    offx: 0
    offy: 0
    origname: i7.png
    shape: rect
    left: 0
    right: 256
    top: 0
    bottom: 256
    lastmod: 1598928510756
    uid: 004e6497-a9f8-4a44-8b43-346ee79e6514
    padding: 1
    tiled: true
    type: texture
  - type: template
    baseClass: Text
    name: LivesText
    depth: 1000
    texture: -1
    playAnimationOnStart: false
    loopAnimation: true
    animationFPS: 30
    visible: true
    events:
      - eventKey: OnStep
        lib: core
        code: 'this.text = ''Lives: '' + rooms.current.lives;'
        arguments: {}
    extends: {}
    nineSliceSettings:
      left: 16
      top: 16
      right: 16
      bottom: 16
      autoUpdate: false
    lastmod: 1703591382237
    uid: RM4JgQc2cFpPTc
    behaviors: []
    textStyle: b1e32885-9439-412d-9220-7d18fae8bf91
    defaultText: 'Lives: 3'
    extendTypes: ''
  - type: template
    baseClass: Text
    name: ScoreText
    depth: 1000
    texture: -1
    playAnimationOnStart: false
    loopAnimation: true
    animationFPS: 30
    visible: true
    events:
      - eventKey: OnStep
        lib: core
        code: 'this.text = ''Score: '' + rooms.current.score;'
        arguments: {}
    extends: {}
    nineSliceSettings:
      left: 16
      top: 16
      right: 16
      bottom: 16
      autoUpdate: false
    lastmod: 1703591441958
    uid: 7Gpfq12g2PHGbf
    behaviors: []
    textStyle: 4f2f6d4b-a339-4e30-98f3-80db10aafc4f
    defaultText: 'Score: 60063'
    extendTypes: ''
globalVars: []
