From 9cac232a8a7119e1265bc652382f7a24bb9d35c0 Mon Sep 17 00:00:00 2001 From: nuno Date: Fri, 10 Dec 2021 16:24:13 +0400 Subject: [PATCH] first commit --- .gitignore | 1 + .vscode/launch.json | 15 +++++++++++++++ .vscode/tasks.json | 13 +++++++++++++ build.hxml | 7 +++++++ src/Main.hx | 45 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 81 insertions(+) create mode 100644 .gitignore create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json create mode 100644 build.hxml create mode 100644 src/Main.hx diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e0e699e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +Nuno.hl diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..39b3dd7 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "HashLink", + "request": "launch", + "type": "hl", + "cwd": "${workspaceFolder}", + "preLaunchTask": { + "type": "haxe", + "args": "active configuration" + } + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..23c0b2b --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,13 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "haxe", + "args": "active configuration", + "group": { + "kind": "build", + "isDefault": true + } + } + ] +} \ No newline at end of file diff --git a/build.hxml b/build.hxml new file mode 100644 index 0000000..ffc00ec --- /dev/null +++ b/build.hxml @@ -0,0 +1,7 @@ +-cp src +-lib heaps +-lib hlsdl +-main Main +-debug + +-hl Nuno.hl diff --git a/src/Main.hx b/src/Main.hx new file mode 100644 index 0000000..95cdc09 --- /dev/null +++ b/src/Main.hx @@ -0,0 +1,45 @@ +import hxd.Key; + +class Main extends hxd.App { + var bmp:h2d.Bitmap; + var deplacement = 5; + + override function init() { + var tile = h2d.Tile.fromColor(0x0085ff, 100, 100); + bmp = new h2d.Bitmap(tile, s2d); + bmp.x = s2d.width * 0.5; + bmp.y = s2d.height * 0.5; + hxd.Window.getInstance().addEventTarget(onEvent); + } + + function onEvent(event:hxd.Event) { + switch (event.kind) { + case EKeyDown: + switch (event.keyCode) { + case 37: // LEFT + bmp.x -= deplacement; + if (bmp.x < bmp.width) bmp.x = bmp.width; + case 38: // UP + bmp.y -= deplacement; + if (bmp.y < bmp.height) bmp.y = bmp.height; + case 39: // RIGHT + bmp.x += deplacement; + if (bmp.x > s2d.width - bmp.width) bmp.x = s2d.width - bmp.width; + case 40: // DOWN + bmp.y += deplacement; + if (bmp.y > s2d.height - bmp.height) bmp.y = s2d.height - bmp.height; + } + + case _: + } + } + + override function update(dt:Float) { + bmp.rotation += 0.3; + } + + static function main() { + new Main(); + } +} +// faire une tuile de 100sur100 et de la faire deplacer grace aux fleches