Skip to content

Instantly share code, notes, and snippets.

@01010111
Created March 4, 2019 16:13
Show Gist options
  • Select an option

  • Save 01010111/b600cd7825b62bbcecdc204f65d8545e to your computer and use it in GitHub Desktop.

Select an option

Save 01010111/b600cd7825b62bbcecdc204f65d8545e to your computer and use it in GitHub Desktop.
Very simple heaps example
import h2d.Scene;
import h2d.Graphics;
import hxd.App;
import hxd.Key;
class Game extends App
{
static function main() new Game();
var player:Player;
override function init()
{
player = new Player(this.s2d);
}
override function update(dt)
{
player.player_move(10);
}
}
class Player extends Graphics
{
public function new(scene:Scene)
{
super(scene);
beginFill(0xffffff);
drawRect(0, 0, 30, 30);
endFill();
}
public function player_move(speed:Float)
{
if (Key.isDown(Key.A)) x -= speed;
if (Key.isDown(Key.D)) x += speed;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment