Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Set graphic colour
- for (key => state in just_pressed.active) {
- if (!state) {
- display.color = display.init_color;
- continue;
- }
- display.color = switch (key) {
- case Left: Color.Red;
- case Right: Color.Red;
- case Down: Color.Red;
- case Up: Color.Red;
- default: Color.Transparent;
- }
- if (key == Left) {
- trace('Left: ' + display.color);
- }
- if (key == Right) {
- trace('Right: ' + display.color);
- }
- if (key == Up) {
- trace('Up: ' + display.color);
- }
- if (key == Down) {
- trace('Down: ' + display.color);
- }
- }
- // Render loop
- override function update() {
- if (Game.framebuffer == null) {
- return;
- }
- var graphics = Game.framebuffer.g2;
- graphics.begin();
- for (node in this.display_id) {
- var position = this.position.get(node);
- var display = this.display.get(node);
- graphics.color = display.color;
- trace(graphics.color);
- graphics.fillRect(position.x, position.y, display.width, display.height);
- }
- graphics.end();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement