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

Revision 2345, 2.1 KB checked in by jaollipa, 8 years ago (diff)

Started Menus

Line 
1 using 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    List<Label> titleMenu;
16
17    public override void Begin()
18    {
19        Gravity = new Vector(0, -1000);
20        createLevel();
21        menuCreate();
22
23        // Starts playing the background music, which is set to repeat
24        MediaPlayer.Play("Sounds/Stage1Music");
25        MediaPlayer.Volume = 0.5;
26        MediaPlayer.IsRepeating = true;
27
28        Camera.Follow(player);
29        Camera.ZoomFactor = 1.0;
30        Camera.StayInLevel = true;
31    }
32
33
34    // Creates the level from a text file
35    void createLevel()
36    {
37        TileMap levelSpec = TileMap.FromFile("ReactorEntrance.txt");
38        levelSpec['='] = createVerticalBlock;
39        levelSpec['|'] = createHorizontalBlock;
40        levelSpec['P'] = addPlayer;
41        levelSpec['a'] = addMeleeAlien;
42        levelSpec.Insert(SCREEN_WIDTH, SCREEN_HEIGTH);
43        Level.CreateBorders();
44        Level.Background.Image = background1;
45    }
46
47    Player addPlayer()
48    {
49        player = new Player(33, 74, Shape.Rectangle);
50        return player;
51    }
52
53    MeleeAlien addMeleeAlien()
54    {
55        MeleeAlien meleeAlien = new MeleeAlien(45, 80, Shape.Rectangle, 10, "Patrol");
56        return meleeAlien;
57    }
58
59    PhysicsObject createHorizontalBlock()
60    {
61        PhysicsObject hBlock = PhysicsObject.CreateStaticObject(SCREEN_WIDTH, SCREEN_HEIGTH,
62            Shape.Rectangle, CollisionShapeQuality.Best);
63        hBlock.Color = Color.Gray;
64        return hBlock;
65    }
66
67    PhysicsObject createVerticalBlock()
68    {
69        PhysicsObject vBlock = PhysicsObject.CreateStaticObject(SCREEN_WIDTH, SCREEN_HEIGTH,
70            Shape.Rectangle, CollisionShapeQuality.Best);
71        vBlock.Color = Color.DarkGray;
72        return vBlock;
73    }
74
75    void menuCreate()
76    {
77
78    }
79}
Note: See TracBrowser for help on using the repository browser.