Mammut's scripts are written in JavaScript or TypeScript. You don't need to know much to get started, because the script editor suggests what's available as you type. This page lists free courses, guides and references to learn from, and the parts of the language Mammut uses most.
Most courses teach JavaScript for building websites. A Mammut game is a web page, so nearly everything they teach applies. You can skip the parts about setting up files, <script> tags, import and export, Node.js, npm and frameworks such as React. In Mammut you write inside a scene script instead, which is laid out a little differently. See JavaScript in Mammut once you know the basics.
Where to start
- If you've never programmed before, start freeCodeCamp's JavaScript course or The Modern JavaScript Tutorial
- Once JavaScript feels comfortable, read TypeScript for JavaScript Programmers.
JavaScript courses
- Dynamic scripting with JavaScript (MDN): Mozilla's beginner course. It covers variables, functions, loops, events and changing a page, with small exercises along the way.
- The Modern JavaScript Tutorial: a thorough tutorial that goes from the basics to advanced topics. It works as a course and as a place to look things up.
- freeCodeCamp JavaScript: lessons, workshops and small projects you complete in the browser.
- The Odin Project JavaScript: a project-based course. It follows on from their Foundations course, which starts from nothing.
- Learn JavaScript (web.dev): Google's course on the core of the language, one topic per page.
- Eloquent JavaScript: a free book, with exercises you can run on the page. Good if you like learning by reading.
- W3Schools JavaScript Tutorial: short pages, each with an example you can edit and run. Quick for looking up one thing.
Practice
- Exercism JavaScript: small exercises that check your answer, with optional feedback from volunteer mentors.
Debugging
- To see what your own game is doing while it runs, see Debugging.
References
- MDN JavaScript Guide: explains each part of the language in order.
- MDN JavaScript Reference: every built-in object, function and operator, such as
Math,ArrayandJSON.
From version 0.9.22, hold Ctrl (⌘ on a Mac) and click a built-in like Math.floor in the script editor to open its MDN page. Engine commands like SceneManager.SwitchScene open their page in this wiki.
What Mammut uses most
You'll use these in almost every script, so they're worth learning well:
| Topic | Where you'll use it | Learn it |
|---|---|---|
| Objects and methods | A scene script is the inside of an object | Object initializer, Method definitions |
this |
Every member of your script is reached through this |
this |
| Arrow functions | Callbacks inside methods, such as timers | Arrow functions |
| The DOM | this.dom holds the scene's elements, so you can change their text, style and classes |
DOM scripting |
| Events | Reacting to clicks and key presses | Events |
Promises and await |
Waiting for a state's animation, a scene switch or a chapter to finish | Asynchronous JavaScript, async function |
| Template literals | Building text with values in it, like `Score: ${score}` |
Template literals |
| Optional chaining | Calling something that might not be there, like SceneManager.GetScene("hud")?.addCoins?.(1) |
Optional chaining |
Learning TypeScript
TypeScript is JavaScript with types added, so learn JavaScript first. Everything you know carries over, and TypeScript lets the editor catch mistakes as you type. New scenes start in TypeScript.
- TypeScript for the New Programmer: what TypeScript is and why it exists, if you're new to programming.
- TypeScript for JavaScript Programmers: a short introduction for people who already know JavaScript.
- Everyday Types: the types you'll write most often. This chapter covers nearly everything a scene script needs.
- The TypeScript Handbook: the full official guide, for when you want to go further.
- Beginner's TypeScript Tutorial (Total TypeScript): free interactive exercises with short videos.
- Learn TypeScript (Codecademy): a free interactive course.
- Exercism TypeScript: practice exercises, like the JavaScript track.
- TypeScript Deep Dive: a free book that explains how TypeScript works in more detail.
- TypeScript Playground: write TypeScript in the browser and see the JavaScript it turns into.
Mammut's TypeScript checking is relaxed, so you don't have to add types everywhere. You'll mostly write types on your own script members, with as. See Script Types.
Mammut's own guides
- JavaScript in Mammut: why scene scripts are laid out the way they are.
- Scene Script: the parts of a scene script and when they run.
- TypeScript: choosing a language, and what the editor checks.
- Script Types: how
this.dom,this.varsand your own members are typed. - Scripting API: every command the engine gives you, with examples.
- Debugging: finding out what's going wrong while your game runs.