Wednesday, 25 November 2015

Moar Better Rainbows! - mcpi_dart 0.0.4 Minecraft and Dart

I recently purchased a Raspberry Pi 2 with the snazzy 'official' case, so it was time to dust off my old Dart Minecraft library for an update. TLDR : Moar Better Rainbows!

Screenshot from the PC version of Minecraft.

The setBlock method now takes an extra parameter for data which allows the use of color on blocks such as wool. This means the rainbow can now be drawn in better colours. Yay!

The getPos method now returns a list of int's so the rainbow is built close to the player's position in the game. You may need to spin around to see it. Unfortunately, the Rasperry Pi version of the API does not allow us to obtain the players direction of view so this will be the case with everything we build.

So what is next? I am starting to have fun building structures using this package. Hopefully feeding back a nice set of utility functions to mcpi_dart. Now that ARM builds of Dart are available, it is possible to run Dart on the Raspberry Pi itself so it would be great to get something running without a remote machine.

Have fun and please send screenshots of anything you build!

Thursday, 19 November 2015

Dart SDK and Dartium 1.13.0 Chocolatey Packages for Windows

Chocolatey is a package manager for Windows similar to Linux's apt-get, based on Microsoft's Nuget tool and Powershell scripting language. It works from the command-line and from a WPF GUI interface.

Chocolatey still has a large moderation backlog - however you can install unmoderated versions by specifiying the install version during installation.

Command line installation:

choco uninstall dart-sdk

choco install -y dart-sdk  -version 1.13.0
To verify you have the right version on your path.
dart --version

Dart VM version: 1.13.0 (Wed Nov 18 12:24:20 2015) on "windows_x64"

Command line installation:

choco uninstall dartium

choco install -y dartium  -version 1.13.0

Friday, 6 November 2015

Sprite Lifecycle - Simplegamelib Part Ten

This is the tenth part in an ongoing series where we will look at the package I am currently writing called simplegamelib. Development is usually a little ahead of the current blog post. The projects homepage is located here.

Ninjas have a tough life and often have a lot thrown at them at once. This sometimes involves painful objects. In a game, we need to check how each object is interacting with others in the game world. The projectiles will be in the SpriteGroup. Sadly these will cause the Ninja to die but we don't want the character just to suddenly vanish. We want a skeleton to appear (or an explosion in a game set in space). This is why the Sprite has both an alive property and a dying property.

import 'dart:html';
import 'package:simplegamelib/simplegamelib.dart';

Sprite player;
SpriteGroup fireballs = new SpriteGroup();
Game game = new Game("My Game", '#surface');

void main() {
  player = game.createSprite('images/ninjadude.png', 48, 48);
  player
    ..setDyingImage('images/deaddude.png')
    ..cyclesToDie = 1000;
  for (int i = 0; i < 5; i++) {
    var fireball = game.createSprite('images/fire.png', 24, 24);
    fireball
      ..movement = Movements.west
      ..x = 290 + i * 100
      ..y = 60
      ..speed = 3;
    fireballs.add(fireball);
  }

  game
    ..player.sprite = player
    ..renderer.liveBackground.setImageBackground('images/background.png')
    ..customUpdate = spriteDying;

  player
    ..position = new Point(10, 30)
    ..movement = new Point(0, 0);

  print('starting game...');
  game.start();
}

void spriteDying() {
  if (player.dying) return;
  List collisions = fireballs.detectCollision(player);

  collisions.forEach((Sprite fireball) {
    fireball.alive = false;
    fireballs.removeDead();
    game.player.sprite.dying = true;
  });
}

Next time, we will take a break and have a look at the Left-Right shoot-em-up I have been working on using simplegamelib!

Wednesday, 4 November 2015

Internet of Programmable Things - Kasper Lund

This introduction to IOT and Fletch (a new VM that runs Dart on embedded devices) was recorded at GOTO Copenhagen 2015. Very interesting!