Пример #1
0
    static void game()
    {
        //-------------Client code starts here

        var scene  = new Scene();
        var layer1 = new Layer();

        layer1.ClassName = "ObjectsLayer";
        var enemyLayer = new Layer();

        enemyLayer.ClassName = "EnemyLayer";

        var hero = new RenderableObject(new Vec2(400, 300));

        hero.ClassName = "Hero";
        var graph = new Glc.Component.GraphicalComponent.Animation(Glc.Component.GraphicalComponent.AnimationType.Cyclic);

        graph.AddFrame(new SpriteFrame(@"resources\soldier\Soldier1.png", 400));
        graph.AddFrame(new SpriteFrame(@"resources\soldier\Soldier2.png", 400));
        hero.GraphComponent = graph;
        hero.AddComponent(new Glc.Component.Script(@"player.gcs"));

        var bullet = new RenderableObject(new Vec2());

        bullet.ClassName      = "Bullet";
        bullet.GraphComponent = new Glc.Component.GraphicalComponent.Sprite(@"resources\bullet.jpg");
        bullet.AddComponent(new Glc.Component.Script(@"bullet.gcs"));
        bullet.AddComponent(new Glc.Component.Collider(Glc.Component.Collider.Type.Circle).SetRadius(5));
        bullet.IsRenderableAtStart = false;

        Random rand = new Random();

        for (var i = 0; i < 70; ++i)
        {
            var enemy  = new Glc.RenderableObject(new Vec2((float)rand.Next(0, 800), (float)600.54));
            var eGraph = new Glc.Component.GraphicalComponent.Animation(Glc.Component.GraphicalComponent.AnimationType.Cyclic);
            eGraph.AddFrame(new SpriteFrame(@"resources\enemy\enemy1.png", (float)rand.Next(300, 600)));
            eGraph.AddFrame(new SpriteFrame(@"resources\enemy\enemy2.png", (float)rand.Next(300, 600)));
            enemy.GraphComponent = eGraph;
            enemy.AddComponent(new Glc.Component.Collider(Glc.Component.Collider.Type.Rectangle).SetSize(new Vec2(54, 94)));
            enemy.AddComponent(new Glc.Component.Script(@"enemy.gcs"));
            enemyLayer.AddObject(enemy);
        }

        layer1.AddObject(hero);
        layer1.AddObject(bullet);
        scene.AddLayer(enemyLayer);
        scene.AddLayer(layer1);
        Glance.AddScene(scene);
        //-------------Client code ends here
        Glance.Build();

        Console.ReadKey();
    }
Пример #2
0
    static void emptyGame()
    {
        var scene = new Scene();
        var layer = new Layer();

        Glance.AddScene(scene);
        scene.AddLayer(layer);
        //-------------Client code ends here
        Glance.Build();

        Console.ReadKey();
    }