Coder Social home page Coder Social logo

snake-in-typescript's Introduction

Snake in TypeScript

An example of using the Playdate API with TypeScript to build a Snake game

Getting set up

git clone ...
cd ...
yarn install

Then open the editor:

code .

You realistically need copy of vscode-playdate set up in your editor to get working efficiently. From there, you can hit the run button in the debugging panel to start everything up.

How it works

Pressing start will:

  • Run the Playdate compiler over Source
  • Start the TypeScript to Lua watcher

This repo uses TypeScriptToLua to convert *.ts files in Src to Source.

Files of interest

  • TS2Lua/requireToImport.js - a plugin for TypeScriptToLua which makes the emitted Lua files use import and not require
  • playdate.d.ts - an ambient declaration file (e.g. one that affects global scope) which adds the playdate SDK globals

Keybindings

If you come from a Mac background, these are keybindings which I think makes your life easier for Xcode-like running of your app.

[
      {
        "key": "cmd+r",
        "command": "workbench.action.debug.start",
        "when": "!inDebugMode"
    },
    {
        "key": "cmd+r",
        "command": "workbench.action.debug.restart",
        "when": "inDebugMode"
    },
    {
        "key": "cmd+shift+r",
        "command": "workbench.action.debug.restart"
    },
    {
        "key": "cmd+shift+.",
        "command": "workbench.action.debug.stop"
    }
]

Here's my full keybindings for reference also

[
    {
        "key": "ctrl+cmd+left",
        "command": "workbench.action.navigateBack"
    },
    {
        "key": "ctrl+cmd+right",
        "command": "workbench.action.navigateForward"
    },
    {
        "key": "cmd+e",
        "command": "editor.action.addSelectionToNextFindMatch"
    },
    {
        "key": "cmd+t",
        "command": "workbench.action.quickOpen"
    },
    {
        "key": "cmd+r",
        "command": "workbench.action.debug.start",
        "when": "!inDebugMode"
    },
    {
        "key": "cmd+r",
        "command": "workbench.action.debug.restart",
        "when": "inDebugMode"
    },
    {
        "key": "cmd+shift+r",
        "command": "workbench.action.debug.restart"
    },
    {
        "key": "cmd+shift+.",
        "command": "workbench.action.debug.stop"
    },
    {
        "key": "cmd+shift+[",
        "command": "workbench.action.previousEditor"
    },
    {
        "key": "cmd+shift+]",
        "command": "workbench.action.nextEditor"
    },
    {
        "key": "ctrl+cmd+e",
        "command": "editor.action.changeAll"
    },
    {
        "key": "cmd+1",
        "command": "workbench.view.explorer"
    },
    {
        "key": "cmd+2",
        "command": "workbench.view.search"
    },
    {
        "key": "cmd+3",
        "command": "workbench.view.git"
    },
    {
        "key": "cmd+4",
        "command": "workbench.view.debug"
    },
    {
        "key": "cmd+5",
        "command": "workbench.view.extensions"
    },
    {
        "key": "cmd+enter",
        "command": "editor.action.goToDeclaration",
        "when": "editorTextFocus"
    },
    {
        "key": "cmd+.",
        "command": "editor.action.triggerSuggest",
        "when": "editorHasCompletionItemProvider && editorTextFocus && !editorReadonly"
    },
    {
        "key": "cmd+k p",
        "command": "editor.action.previewDeclaration",
        "when": "editorHasDefinitionProvider && editorTextFocus && !inReferenceSearchEditor && !isInEmbeddedEditor"
    },
    {
        "key": "cmd+k f",
        "command": "editor.action.referenceSearch.trigger",
        "when": "editorHasReferenceProvider && editorTextFocus && !inReferenceSearchEditor && !isInEmbeddedEditor"
    },
    {
        "key": "cmd+k e",
        "command": "editor.action.rename",
        "when": "editorHasRenameProvider && editorTextFocus && !editorReadonly"
    },
    {
        "key": "cmd+shift n",
        "command": "workbench.action.files.newUntitledFile",
        "when": "editorTextFocus"
    },
    {
        "key": "shift+cmd+t",
        "command": "workbench.action.terminal.toggleTerminal"
    },
    {
        "key": "ctrl+`",
        "command": "-workbench.action.terminal.toggleTerminal"
    },
    {
        "key": "ctrl+.",
        "command": "toggleSuggestionDetails",
        "when": "editorTextFocus && suggestWidgetVisible"
    },
    {
        "key": "ctrl+space",
        "command": "-toggleSuggestionDetails",
        "when": "editorTextFocus && suggestWidgetVisible"
    },
    {
        "key": "shift+cmd+.",
        "command": "editor.action.quickFix",
        "when": "editorHasCodeActionsProvider && editorTextFocus && !editorReadonly"
    },
    {
        "key": "cmd+.",
        "command": "-editor.action.quickFix",
        "when": "editorHasCodeActionsProvider && editorTextFocus && !editorReadonly"
    },
    {
        "key": "ctrl+1",
        "command": "workbench.action.focusFirstEditorGroup"
    },
    {
        "key": "cmd+1",
        "command": "-workbench.action.focusFirstEditorGroup"
    },
    {
        "key": "ctrl+2",
        "command": "workbench.action.focusSecondEditorGroup"
    },
    {
        "key": "cmd+2",
        "command": "-workbench.action.focusSecondEditorGroup"
    },
    {
        "key": "ctrl+3",
        "command": "workbench.action.focusThirdEditorGroup"
    },
    {
        "key": "cmd+3",
        "command": "-workbench.action.focusThirdEditorGroup"
    },
    {
        "key": "ctrl+alt+left",
        "command": "workbench.action.navigateEditorGroups"
    },
    {
        "key": "ctrl+alt+right",
        "command": "workbench.action.navigateEditorGroups"
    },
    {
        "key": "cmd+l",
        "command": "workbench.action.gotoLine"
    },
    {
        "key": "ctrl+g",
        "command": "-workbench.action.gotoLine"
    }
]

snake-in-typescript's People

Contributors

orta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

alexrogalskiy

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.