source: 2011/26/JaakkoL/Rogue Agent 2372/Rogue Agent 2372/Rogue Agent 2372/Peli.cs @ 2234

Revision 2234, 1.6 KB checked in by teeevasa, 8 years ago (diff)

Talletus.

Line 
1using System;
2using System.Collections.Generic;
3using Jypeli;
4using Jypeli.Assets;
5using Jypeli.Controls;
6using Jypeli.Effects;
7using Jypeli.Widgets;
8
9public class Peli : PhysicsGame
10{
11    const int SCREEN_WIDTH = 50;
12    const int SCREEN_HEIGTH = 50;
13    Player player;
14
15    public override void Begin()
16    {
17        Gravity = new Vector(0, -1000);
18
19        createLevel();
20        //lisaaNappaimet();
21
22        Camera.Follow(player);
23        Camera.ZoomFactor = 1.2;
24        Camera.StayInLevel = true;
25    }
26
27    void createLevel()
28    {
29        TileMap levelSpec = TileMap.FromFile("ReactorEntrance.txt");
30        levelSpec['='] = createVerticalBlock;
31        levelSpec['|'] = createHorizontalBlock;
32        levelSpec['P'] = addPlayer;
33        levelSpec['a'] = addMeleeAlien;
34        levelSpec.Insert(SCREEN_WIDTH, SCREEN_HEIGTH);
35    }
36
37    Player addPlayer()
38    {
39        player = new Player(10.0, 10.0, Shape.Rectangle);
40        return player;
41    }
42
43    MeleeAlien addMeleeAlien()
44    {
45        MeleeAlien meleeAlien = new MeleeAlien(SCREEN_WIDTH, SCREEN_HEIGTH, Shape.Rectangle, 10, "Patrol");
46        return meleeAlien;
47    }
48
49    PhysicsObject createHorizontalBlock()
50    {
51        PhysicsObject hBlock = PhysicsObject.CreateStaticObject(SCREEN_WIDTH, SCREEN_HEIGTH);
52        hBlock.Color = Color.Black;
53        return hBlock;
54    }
55
56    PhysicsObject createVerticalBlock()
57    {
58        PhysicsObject vBlock = PhysicsObject.CreateStaticObject(SCREEN_WIDTH, SCREEN_HEIGTH);
59        vBlock.Color = Color.Red;
60        return vBlock;
61    }
62}
Note: See TracBrowser for help on using the repository browser.