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

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