Book Image

DART Cookbook

By : Ivo Balbaert
Book Image

DART Cookbook

By: Ivo Balbaert

Overview of this book

Table of Contents (18 chapters)
Dart Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Structuring a game project


Board games, for the greater part, have the same structure; what the user sees (the view) is a surface containing a grid of cells (model classes) that can be of different shapes. Along with a few utility classes to choose a color at random, this constitutes a solid base to build a board game. With his experience in building game projects, Dzenan Ridjanovic has extracted this game structure in the boarding project, which can be found at https://github.com/dzenanr/boarding.

How to do it...

Download the game project as a zip from the preceding URL, unzip it, and open it in Dart Editor. The code that is the starting part of a new board game can be found in the lib folder; the library that is boarding (in boarding.dart) imports the view classes Surface and Shape:

library boarding;

import 'dart:html';
import 'dart:math';

import 'package:boarding/boarding_model.dart';

part 'view/shape.dart';
part 'view/surface.dart';

The script boarding_model.dart declares the library...