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

Revision 2295, 1.9 KB checked in by jaollipa, 8 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    Image background1 = LoadImage("Images/reactorBG");
15
16    public override void Begin()
17    {
18        Gravity = new Vector(0, -1000);
19
20        createLevel();
21
22        MediaPlayer.Play("Sounds/Stage1Music");
23        MediaPlayer.Volume = 0.5;
24
25        Camera.Follow(player);
26        Camera.ZoomFactor = 1.0;
27        Camera.StayInLevel = true;
28    }
29
30    void createLevel()
31    {
32        TileMap levelSpec = TileMap.FromFile("ReactorEntrance.txt");
33        levelSpec['='] = createVerticalBlock;
34        levelSpec['|'] = createHorizontalBlock;
35        levelSpec['P'] = addPlayer;
36        levelSpec['a'] = addMeleeAlien;
37        levelSpec.Insert(SCREEN_WIDTH, SCREEN_HEIGTH);
38        Level.CreateBorders();
39        Level.Background.Image = background1;
40    }
41
42    Player addPlayer()
43    {
44        player = new Player(33, 74, Shape.Rectangle);
45        //Image i = LoadImage("Images/character");
46        //player.Image = i;
47        return player;
48    }
49
50    MeleeAlien addMeleeAlien()
51    {
52        MeleeAlien meleeAlien = new MeleeAlien(45, 80, Shape.Rectangle, 10, "Patrol");
53        return meleeAlien;
54    }
55
56    PhysicsObject createHorizontalBlock()
57    {
58        PhysicsObject hBlock = PhysicsObject.CreateStaticObject(SCREEN_WIDTH, SCREEN_HEIGTH,
59            Shape.Rectangle, CollisionShapeQuality.Best);
60        hBlock.Color = Color.Gray;
61        return hBlock;
62    }
63
64    PhysicsObject createVerticalBlock()
65    {
66        PhysicsObject vBlock = PhysicsObject.CreateStaticObject(SCREEN_WIDTH, SCREEN_HEIGTH,
67            Shape.Rectangle, CollisionShapeQuality.Best);
68        vBlock.Color = Color.DarkGray;
69        return vBlock;
70    }
71}
Note: See TracBrowser for help on using the repository browser.