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

Revision 2252, 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
21        Camera.Follow(player);
22        Camera.ZoomFactor = 1.2;
23        Camera.StayInLevel = true;
24    }
25
26    void createLevel()
27    {
28        TileMap levelSpec = TileMap.FromFile("ReactorEntrance.txt");
29        levelSpec['='] = createVerticalBlock;
30        levelSpec['|'] = createHorizontalBlock;
31        levelSpec['P'] = addPlayer;
32        levelSpec['a'] = addMeleeAlien;
33        levelSpec.Insert(SCREEN_WIDTH, SCREEN_HEIGTH);
34        Level.CreateBorders();
35    }
36
37    Player addPlayer()
38    {
39        player = new Player(33, 74, Shape.Rectangle);
40        Image i = LoadImage("character");
41        player.Image = i;
42        return player;
43    }
44
45    MeleeAlien addMeleeAlien()
46    {
47        MeleeAlien meleeAlien = new MeleeAlien(45, 80, Shape.Rectangle, 10, "Patrol");
48        return meleeAlien;
49    }
50
51    PhysicsObject createHorizontalBlock()
52    {
53        PhysicsObject hBlock = PhysicsObject.CreateStaticObject(SCREEN_WIDTH, SCREEN_HEIGTH);
54        hBlock.Color = Color.Black;
55        return hBlock;
56    }
57
58    PhysicsObject createVerticalBlock()
59    {
60        PhysicsObject vBlock = PhysicsObject.CreateStaticObject(SCREEN_WIDTH, SCREEN_HEIGTH);
61        vBlock.Color = Color.Red;
62        return vBlock;
63    }
64}
Note: See TracBrowser for help on using the repository browser.