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

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

Talletus.

RevLine 
[2187]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{
[2227]11    const int SCREEN_WIDTH = 50;
12    const int SCREEN_HEIGTH = 50;
[2206]13    Player player;
14
[2187]15    public override void Begin()
16    {
17        Gravity = new Vector(0, -1000);
18
[2227]19        createLevel();
[2187]20
[2234]21        Camera.Follow(player);
22        Camera.ZoomFactor = 1.2;
23        Camera.StayInLevel = true;
[2187]24    }
25
[2227]26    void createLevel()
[2187]27    {
[2231]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);
[2245]34        Level.CreateBorders();
[2187]35    }
36
[2231]37    Player addPlayer()
[2227]38    {
[2252]39        player = new Player(33, 74, Shape.Rectangle);
[2261]40        //Image i = LoadImage("Images/character");
41        //player.Image = i;
[2231]42        return player;
[2227]43    }
44
[2231]45    MeleeAlien addMeleeAlien()
46    {
[2252]47        MeleeAlien meleeAlien = new MeleeAlien(45, 80, Shape.Rectangle, 10, "Patrol");
[2231]48        return meleeAlien;
[2227]49    }
50
[2231]51    PhysicsObject createHorizontalBlock()
52    {
53        PhysicsObject hBlock = PhysicsObject.CreateStaticObject(SCREEN_WIDTH, SCREEN_HEIGTH);
54        hBlock.Color = Color.Black;
55        return hBlock;
[2227]56    }
57
[2231]58    PhysicsObject createVerticalBlock()
59    {
60        PhysicsObject vBlock = PhysicsObject.CreateStaticObject(SCREEN_WIDTH, SCREEN_HEIGTH);
61        vBlock.Color = Color.Red;
62        return vBlock;
[2227]63    }
[2217]64}
Note: See TracBrowser for help on using the repository browser.