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

Revision 2290, 1.8 KB checked in by teeevasa, 8 years ago (diff)

CollisionShapeQuality? -> "fixes head in ceiling" -bug
In addition, restarted weapons

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.0;
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            Shape.Rectangle, CollisionShapeQuality.Best);
58        hBlock.Color = Color.Black;
59        return hBlock;
60    }
61
62    PhysicsObject createVerticalBlock()
63    {
64        PhysicsObject vBlock = PhysicsObject.CreateStaticObject(SCREEN_WIDTH, SCREEN_HEIGTH,
65            Shape.Rectangle, CollisionShapeQuality.Best);
66        vBlock.Color = Color.Red;
67        return vBlock;
68    }
69}
Note: See TracBrowser for help on using the repository browser.