Skip to content

Project structure #9

@Chris-Mingay

Description

@Chris-Mingay

Hi there, first off thanks for this project it sounds like exactly what I'm after.

Not an issue with your work, more my own inexperience with typescript but I've fallen at the first hurdle, I'm not sure how I go about referencing classes in different files. Are you able to provide any pointers?

Instinctively I wanted to do something like

./src/Thing.ts

export class Thing {

    name: string;

    constructor(_name: string){
        this.name = _name;
    }

}

main.ts

// title:  game title
// author: game developer
// desc:   short description
// script: js

import { Thing } from './src/Thing';

let t = 0
let x = 96
let y = 24

let items: Thing[] = [
  new Thing("Chris"),
  new Thing("Bob"),
  new Thing("Freddie")
]

function TIC() {
  if (btn(0)) y--
  if (btn(1)) y++
  if (btn(2)) x--
  if (btn(3)) x++
  cls(13)
  spr(1 + (((t % 60) / 30) | 0) * 2, x, y, 14, 3, 0, 0, 2, 2)
  print("HELLO WORLD 2!", 84, 84)

  let tY = 0;
  items.forEach(item => {
    print(item.name, 0, tY);
    tY+=10;
  })

  t++
}

When I try tsc80 run I get

"src/Thing.ts(1,14): error TS6131: Cannot compile modules using option 'outFile' unless the '--module' flag is 'amd' or 'system'.\r\n",

If I set the module to amd in tsconfig.json the application compiles but from within TIC80 I get

image

If I set the module to system in tsconfig.json the application compiles but from within TIC80 I get

image

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions