Browse Source

first commit

master
nuno 3 years ago
parent
commit
9cac232a8a
  1. 1
      .gitignore
  2. 15
      .vscode/launch.json
  3. 13
      .vscode/tasks.json
  4. 7
      build.hxml
  5. 45
      src/Main.hx

1
.gitignore

@ -0,0 +1 @@
Nuno.hl

15
.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"
}
}
]
}

13
.vscode/tasks.json

@ -0,0 +1,13 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "haxe",
"args": "active configuration",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}

7
build.hxml

@ -0,0 +1,7 @@
-cp src
-lib heaps
-lib hlsdl
-main Main
-debug
-hl Nuno.hl

45
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
Loading…
Cancel
Save