hello_dart 0.2.0

  • README.md
  • Installing
  • Versions
  • 56

Hello Dart #

Hello Dart is a visual and playful introduction to programming with Dart. It's your visual hello world for Dart.

Star this Repo Pub Package

GitHub | Pub | Course Materials

Hello Dart Screenshot

Course Materials #

Hello Dart contains free materials for a complete introductory course in programming. It includes theory, instructions, exercises, and solutions.

How it Works #

Hello Dart makes it easy to get startet with programming. It keeps the motivation high by providing an attractive visual feedback to the programmer.

Player and MyPlayer #

The class Player provides all functionality for controlling the character. The player provides various action methods (like move() and putStar()) and some sensory methods (like canMove() and treeLeft()).

The programming is done in the MyPlayer class which, through inheritance, can access all the methods of Player. Thus, the complexity of the player's methods are hidden from the programming novice at first.

MyPlayer has one method that must be implemented called start(). The start()-method is where the user writes his program. It is called automatically when the program is started.

MyPlayer should also have a main()-function that calls createWorld() to initialize the program.

Here is an example of a typical MyPlayer class:

import 'package:hello_dart/hello_dart.dart';

/// Your player.
class MyPlayer extends Player {

  /// Your program.
  start() {

main() {
  createWorld('scenario.txt', new MyPlayer());

World #

The class World is the central class that creates the visual environment and manages all actors.

Once the world is created and initialized with a call to createWorld(), the user's program in the start() method is executed. If we would just run the actions at full speed, the user would not see much of his program's execution. Therefore, we slow down the execution of each action step with the action queue.

Action Queue #

Dart and JavaScript are single-threaded programming languages. This means we cannot put a method to sleep in the middle of its execution as this would freeze the entire application including all animations.

When the World executes the start() method all actions (like move(), turnLeft(), etc.) are collected in an action queue. When all actions are queued they are played back in any desired speed.

This mechanism enables us to put a delay between each action which would otherwise not be possible.

We've set a limit to how many action methods may be called during the execution of the start()-method. The limit is 10'000 calls (see World.maxActionCalls) which should be more than enough for such simple programs. This also means that we will detect and report possibly never-ending cycles to the user at the end of the execution.

Scenarios #

Each Hello Dart scenario comes with a .txt file that provides information about the positions of the actors in the world (see example folder).

A Scenario contains a scenario title and information about the positions of the actors in the world.

The actors are described with the following signs:

  • Player: @
  • Tree: %
  • Star: .
  • Box: $
  • Box on star: *
  • Player on star: +

The background:

  • Empty: a space
  • Border or holes: #

Note: The border must form a polygon with the actors inside.

Here is how a scenario.txt file looks like:

1.03 - Around Tree
#         #
#@ % %  %.#

You may create your own scenarios, of course.

Options #

There are some options for changing the appearance and behavior of Hello Dart. Most options can be found in the hello_dart.dart file.

  • character: Defines the player image. Possible values are boy, catgirl, stargirl, pinkgirl.
  • field: The background field image. Possible values are grass, stone, wood, dirt.
  • backgroundColorTop: The top color of the background gradient. To take screenshots I usually set this color to white (#fff).
  • backgroundColorBottom: The bottom color of the background gradient.
  • messages: The error messages are in English but you may provide translations of those messages. An example can be found in the MessagesDe class.
  • Speed: The createWorld()-function provides an optional third argumtent to set the initial speed (in seconds). You may define the speed in a floating point number.

Here is an example of how to apply various options in the main()-function:

main() {
  // Change appearance.
  character = 'catgirl';
  field = 'stone';
  backgroundColorTop = '#fff';

  // Set to German error messages.
  messages = new MessagesDe();

  // Create the world with an initial speed of 0.3 seconds.
  createWorld('scenario.txt', new MyPlayer(), 0.3);

Attribution #

  • Planet Cute art by Daniel Cook (Lostgarden.com)
  • Oleg Yadrov has extended the "Planet Cute" theme with additional sprite perspectives. He was so kind to provide his graphics.
  • The sprites have been combined and optimized with TexturePacker.

Many thanks to Daniel and Oleg!

License #

The MIT License (MIT)

Changelog #

Version 0.2.0 (2018-11-07) #

  • Update to Dart 2

Version 0.1.1 (2015-03-20) #

  • Rename scenario1.04 from "around-tree-with-method" to "around-tree-with-function"
  • Add badges to readme.

Version 0.1.0 (2015-03-04) #

  • Contains all scenarios of the five parts.

Version 0.0.1 (2015-01-22) #

  • Initial Version.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  hello_dart: ^0.2.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:hello_dart/hello_dart.dart';
Version Uploaded Documentation Archive
0.2.0 Nov 7, 2018 Go to the documentation of hello_dart 0.2.0 Download hello_dart 0.2.0 archive
0.1.1+1 May 1, 2015 Go to the documentation of hello_dart 0.1.1+1 Download hello_dart 0.1.1+1 archive
0.1.1 Mar 20, 2015 Go to the documentation of hello_dart 0.1.1 Download hello_dart 0.1.1 archive
0.1.0+1 Mar 11, 2015 Go to the documentation of hello_dart 0.1.0+1 Download hello_dart 0.1.0+1 archive
0.1.0 Mar 4, 2015 Go to the documentation of hello_dart 0.1.0 Download hello_dart 0.1.0 archive
0.0.1 Jan 22, 2015 Go to the documentation of hello_dart 0.0.1 Download hello_dart 0.0.1 archive
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on May 20, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.3.0
  • pana: 0.12.15


Detected platforms: web

Primary library: package:hello_dart/hello_dart.dart with components: html.

Health suggestions

Fix lib/src/world/scenario.dart. (-2.96 points)

Analysis of lib/src/world/scenario.dart reported 6 hints, including:

line 51 col 23: Use = to separate a named parameter from its default value.

line 51 col 51: Use = to separate a named parameter from its default value.

line 281 col 81: Use = to separate a named parameter from its default value.

line 299 col 84: Use = to separate a named parameter from its default value.

line 318 col 83: Use = to separate a named parameter from its default value.

Fix lib/src/actors/actor.dart. (-0.50 points)

Analysis of lib/src/actors/actor.dart reported 1 hint:

line 128 col 22: Use = to separate a named parameter from its default value.

Fix lib/src/actors/player.dart. (-0.50 points)

Analysis of lib/src/actors/player.dart reported 1 hint:

line 392 col 22: Use = to separate a named parameter from its default value.

Fix lib/src/world/world.dart. (-0.50 points)

Analysis of lib/src/world/world.dart reported 1 hint:

line 512 col 12: Don't explicitly initialize variables to null.

Format lib/hello_dart.dart.

Run dartfmt to format lib/hello_dart.dart.

Maintenance suggestions

The package description is too short. (-1 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example.

None of the files in the package's example/ directory matches known example patterns.

Common filename patterns include main.dart, example.dart, and hello_dart.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
collection ^1.14.11 1.14.11
stagexl ^1.4.0+2 1.4.0+3
string_scanner ^1.0.4 1.0.4
Transitive dependencies
charcode 1.1.2
convert 2.1.1
meta 1.1.7
path 1.6.2
petitparser 2.3.0
source_span 1.5.5
term_glyph 1.1.0
typed_data 1.1.6
xml 3.5.0
Dev dependencies
build_runner ^1.1.1
build_web_compilers ^0.4.4+2