Last active
September 15, 2019 06:47
-
-
Save umaruru/1e2f0bb9bfb5fdb49f46d637f4f32e74 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// Place your snippets for haxe here. Each snippet is defined under a snippet name and has a prefix, body and | |
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | |
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the | |
// same ids are connected. | |
// Example: | |
// "Print to console": { | |
// "prefix": "log", | |
// "body": [ | |
// "console.log('$1');", | |
// "$2" | |
// ], | |
// "description": "Log output to console" | |
// } | |
"New empty class": { | |
"prefix": "class", | |
"body": [ | |
"class ${NAME} {", | |
"\t;", | |
"}" | |
], | |
"description": "new empty class" | |
}, | |
"New public function": { | |
"prefix": "public function", | |
"body": [ | |
"public function ${1:name}(${2:args}): ${3:Void} {", | |
"\t", | |
"}" | |
], | |
"description": "create public function" | |
}, | |
"new function": { | |
"prefix": "public function new", | |
"body": [ | |
"public function new() {", | |
"", | |
"}" | |
], | |
"description": "create function 'new'" | |
}, | |
"Kha Main file": { | |
"prefix": "kha Main", | |
"body": [ | |
"package;", | |
"", | |
"import kha.Assets;", | |
"import kha.Framebuffer;", | |
"import kha.Scheduler;", | |
"import kha.System;", | |
"", | |
"class Main {", | |
"\tpublic static var PROJECT_NAME = \"${1:Project}\";", | |
"\tpublic static var WIDTH = ${2:800};", | |
"\tpublic static var HEIGHT = ${3:600};", | |
"\t", | |
"\tstatic var project: Project;", | |
"\t", | |
"\tstatic function update(): Void {", | |
"\t\tproject.update();", | |
"\t}", | |
"\t", | |
"\tstatic function render(frames: Array<Framebuffer>): Void {", | |
"\t\tproject.render(frames[0]);", | |
"\t}", | |
"\t", | |
"\tpublic static function main() {", | |
"\t\tSystem.start({title: PROJECT_NAME, width: WIDTH, height: HEIGHT}, function (_) {", | |
"\t\t\t// Just loading everything is ok for small projects", | |
"\t\t\tAssets.loadEverything(function () {", | |
"\t\t\t\t// Avoid passing update/render directly", | |
"\t\t\t\t// so replacing them via code injection works", | |
"\t\t\t\tScheduler.addTimeTask(function () { update(); }, 0, 1 / 60);", | |
"\t\t\t\tSystem.notifyOnFrames(function (frames) { render(frames); });", | |
"\t\t\t\tproject = new Project();", | |
"\t\t\t});", | |
"\t\t});", | |
"\t}", | |
"}" | |
], | |
"description": "kha main file" | |
}, | |
"Kha project file": { | |
"prefix": "kha Project", | |
"body": [ | |
"package;", | |
"", | |
"import kha.Framebuffer;", | |
"", | |
"class Project {", | |
"\tpublic function new() {", | |
"\t\t", | |
"\t}", | |
"\t", | |
"\tpublic function update(): Void {", | |
"\t\t", | |
"\t}", | |
"\t", | |
"\tpublic function render(framebuffer:Framebuffer): Void {", | |
"\t\tvar graphics = framebuffer.g2;", | |
"\t\tgraphics.begin();", | |
"\t\t", | |
"\t\tgraphics.end();", | |
"\t}", | |
"}" | |
], | |
"description": "kha project file" | |
}, | |
"Kha graphics class": { | |
"prefix": "kha class graphics", | |
"body": [ | |
"package ${1:Package};", | |
"", | |
"import kha.graphics2.Graphics;", | |
"using kha.graphics2.GraphicsExtension;", | |
"import kha.Color;", | |
"import kha.Assets;", | |
"", | |
"class ${2:Name} {", | |
"\tpublic function new() {", | |
"\t\t", | |
"\t}", | |
"\t", | |
"\tpublic function update() {", | |
"\t\t", | |
"\t}", | |
"\t", | |
"\tpublic function render(graphics:Graphics) {", | |
"\t\t", | |
"\t}", | |
"}" | |
], | |
"description": "graphics class for kha" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment