WarriorJS Docs
  • Играч
  • Аутор
  • Заједница
  • Српски језик (Ћирилица)
    • English
    • العربية
    • Català
    • Čeština
    • Deutsch
    • Ελληνικά
    • Español
    • Français
    • Italiano
    • Polskie
    • Русский
    • Svenska
    • Türkçe
    • 中文
    • 繁體中文
    • Помозите у превођењу
  • GitHub

›Водич

Водич

  • Увод
  • Направите своју кулу
  • Додавање нивоа
  • Дефинисање способности
  • Дефинисање јединица
  • Реструктурирање кода
  • Провера
  • Објављивање

API Аутора

  • Space API
  • Unit API
Translate

Додавање нивоа

Ниво представља JavaScript објекат:

const Level1 = {
  // Level definition.
};

Започећемо са описивањем услова и околине, а затим и саветом за прелазак нивоа:

const Level1 = {
  description:
    "You've entered the ancient castle of Eastwatch to escape from a blizzard. But it's deadly cold inside too.",
  tip:
    "Call `warrior.walk()` to walk forward in the Player's `playTurn` method.",
};

Треба да дефинишемо два броја: временски бонус и врхунски резултат. Временски бонус се добија у зависности од тога колико брзо играч заврши ниво (смањује се са сваким потезом док не стигне до нуле). Са друге стране, врхунски резултат се користи за израчунавање тежине нивоа ( само у епском моду). Сви резултати који су већи или једнаки са врхунским резултатом добиће "S". Хајде да додамо ове бројеве:

const Level1 = {
  description:
    "You've entered the ancient castle of Eastwatch to escape from a blizzard. But it's deadly cold inside too.",
  tip:
    "Call `warrior.walk()` to walk forward in the Player's `playTurn` method.",
  timeBonus: 15,
  aceScore: 10,
};

Ова два броја потребно је фино подесити када се кула буде тестирала у игри. За овај водич, ми смо то унапред одрадили.

Следећа ствар коју радимо јесте дефинисање спрата нивоа, почећемо од његове величине:

const Level1 = {
  description:
    "You've entered the ancient castle of Eastwatch to escape from a blizzard. But it's deadly cold inside too.",
  tip:
    "Call `warrior.walk()` to walk forward in the Player's `playTurn` method.",
  timeBonus: 15,
  aceScore: 10,
  floor: {
    size: {
      width: 8,
      height: 1,
    },
  },
};

Следеће што треба да урадимо јесте да поставимо степенице како би ратник могао прећи на следећи ниво:

const Level1 = {
  description:
    "You've entered the ancient castle of Eastwatch to escape from a blizzard. But it's deadly cold inside too.",
  tip:
    "Call `warrior.walk()` to walk forward in the Player's `playTurn` method.",
  timeBonus: 15,
  aceScore: 10,
  floor: {
    size: {
      width: 8,
      height: 1,
    },
    stairs: {
      x: 7,
      y: 0,
    },
  },
};

Када смо ниво уобличили дефинисаћемо и ратника за овај ниво:

const Level1 = {
  description:
    "You've entered the ancient castle of Eastwatch to escape from a blizzard. But it's deadly cold inside too.",
  tip:
    "Call `warrior.walk()` to walk forward in the Player's `playTurn` method.",
  timeBonus: 15,
  aceScore: 10,
  floor: {
    size: {
      width: 8,
      height: 1,
    },
    stairs: {
      x: 7,
      y: 0,
    },
    warrior: {
      character: '@',
      maxHealth: 20,
      position: {
        x: 0,
        y: 0,
        facing: 'east',
      },
    },
  },
};

Са овим завршамо ниво. Пре него што наставимо дефинисаћемо још један ниво:

const Level2 = {
  description:
    'The cold became more intense. In the distance, you see a pair of deep and blue eyes, a blue that burns like ice.',
  tip:
    "Use `warrior.feel().isEmpty()` to see if there's anything in front of you, and `warrior.attack()` to fight it. Remember, you can only do one action per turn.",
  clue:
    'Add an if/else condition using `warrior.feel().isEmpty()` to decide whether to attack or walk.',
  timeBonus: 20,
  aceScore: 26,
  floor: {
    size: {
      width: 8,
      height: 1,
    },
    stairs: {
      x: 7,
      y: 0,
    },
    warrior: {
      character: '@',
      maxHealth: 20,
      position: {
        x: 0,
        y: 0,
        facing: 'east',
      },
    },
  },
};

Како нивои постају све захтевнији, овде ћемо додати траг. Трагови нису обавезни и показаће се само на захтев играча.

Сада ћемо додати ова да нивоа кули. Нивои се додају у levels низ унутар куле:

module.exports = {
  name: 'Game of Thrones',
  description:
    'There is only one war that matters: the Great War. And it is here.',
  levels: [Level1, Level2],
};

Фантастично! Могли сте приметити да смо издали команде играчу warrior.attack(), warrior.feel(), и warrior.walk() али нисмо научили Ратника како да уради било шта од тога. То ћемо следеће урадити!

← Направите своју кулуДефинисање способности →
WarriorJS Docs
Docs
PlayerMaker
Community
SpectrumTwitterFollow WarriorJS on Twitter
More
DonateGitHubStar