namespace Game { class Stage { const int UNIT_H = 101; const int UNIT_V = 82; private Clutter.Stage _clStage; public Stage () { _clStage = Clutter.Stage.get_default (); AddTree (5,3); _clStage.color = Clutter.Color () { alpha = 255 }; _clStage.show_all (); } public void AddDrawable (Drawable drawable) { _clStage.add_actor (drawable); } public void AddTree (int x, int y) { AddDrawable (new Tree (x*UNIT_H, y*UNIT_V+UNIT_V/2)); } } class Drawable : Clutter.Actor { private Cairo.ImageSurface _surface; public Drawable (float x, float y, float width, float height, string filepath) { this.x = x; this.y = y; this.width = width; this.height = height; var canvas = new Clutter.Canvas (); set_content (canvas); canvas.set_size ((int)width, (int)height); canvas.draw.connect (drawme); _surface = new Cairo.ImageSurface.from_png (filepath); canvas.invalidate (); } private bool drawme (Cairo.Context ctx, int w, int h) { ctx.set_source_surface (_surface, 0, 0); ctx.paint (); return true; } } class GameObject : Drawable { const int IMG_WIDTH = 101; const int IMG_HEIGHT = 171; public GameObject (float x, float y, string filepath) { base (x, y, IMG_WIDTH, IMG_HEIGHT, filepath); } } class Tree : GameObject { const string IMG_PATH = "imgs/Tree Tall.png"; public Tree (float x, float y) { base (x, y, IMG_PATH); } } void main (string[] args) { stdout.printf ("HELLO"); } }