- Timestamp:
- 2012-07-03 13:17:05 (9 years ago)
- Location:
- 2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/Player.cs
r3462 r3477 23 23 { 24 24 keyboard = Game.Keyboard; 25 CanRotate = false; 25 26 setupKeys(); 26 27 } -
2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/Room.cs
r3466 r3477 12 12 public Vector Position { get; set; } 13 13 public double width, height, thickness; 14 pr ivateList<IPhysicsObject> roomObjects = new List<IPhysicsObject>();14 protected List<IPhysicsObject> roomObjects = new List<IPhysicsObject>(); 15 15 private bool isBuilt = false; 16 protected IPhysicsObject[,] insideObjects; 17 protected double blockWidth, blockHeight; 18 protected double insideWidth, insideHeight; 19 protected Vector insidePos; 20 protected int bWidth, bHeight; 16 21 public Game Game { get; set; } 17 22 … … 23 28 height = size.Y; 24 29 this.thickness = thickness; 30 31 insidePos = VecMath.add(pos, new Vector(thickness, -thickness)); 32 insideWidth = width - thickness; 33 insideHeight = height - thickness; 34 blockWidth = insideWidth / 10; 35 blockHeight = blockWidth; 36 bWidth = (int)(insideWidth / blockWidth); 37 bHeight = (int)(insideHeight / blockHeight); 38 39 insideObjects = new PhysicsObject[bWidth, bHeight]; 25 40 } 26 41 … … 35 50 Game.Add(obj); 36 51 } 52 53 foreach (IPhysicsObject obj in insideObjects) 54 { 55 if(obj != null) 56 Game.Add(obj); 57 } 58 37 59 38 60 isBuilt = true; … … 50 72 } 51 73 74 public void addBlock(IPhysicsObject obj, int bx, int by) 75 { 76 if (bx > bWidth || bx < 0 || by > bHeight || by < 0 || insideObjects[bx,by] != null) throw new Exception("Can't put block to " + bx + " , " + by); 77 obj.Left = insidePos.X + (bx * blockWidth); 78 obj.Top = insidePos.Y + (by * blockHeight); 79 insideObjects[bx, by] = obj; 80 } 81 52 82 public void createBorders() 53 83 { 54 PhysicsObject wallTop = createWall(Position, width , thickness);84 PhysicsObject wallTop = createWall(Position, width + thickness, thickness); 55 85 PhysicsObject wallLeft = createWall(VecMath.sub(Position, new Vector(0, thickness)), thickness, height); 56 PhysicsObject wallDown = createWall(VecMath.sub(Position, new Vector(0, height)), width +thickness, thickness);57 PhysicsObject wallRight = createWall(VecMath.add(Position, new Vector(width, 0)), thickness, height);86 PhysicsObject wallDown = createWall(VecMath.sub(Position, new Vector(0, height)), width + thickness, thickness); 87 PhysicsObject wallRight = createWall(VecMath.add(Position, new Vector(width, -thickness)), thickness, height-thickness); 58 88 roomObjects.Add(wallTop); 59 89 roomObjects.Add(wallLeft); … … 70 100 return wall; 71 101 } 72 102 103 public PhysicsObject createBackground() 104 { 105 PhysicsObject bg = PhysicsObject.CreateStaticObject(insideWidth, insideHeight); 106 bg.Left = Position.X + thickness; 107 bg.Top = Position.Y - thickness; 108 bg.IgnoresCollisionResponse = true; 109 bg.Color = Color.Black; 110 bg.IgnoresExplosions = true; 111 return bg; 112 } 113 73 114 } 74 115 75 116 class RoomTemplates 76 117 { 77 118 78 119 } 79 120 } -
2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/TestRoom.cs
r3466 r3477 4 4 using System.Text; 5 5 using Jypeli; 6 using MathHelper; 6 7 7 8 namespace Rooms … … 19 20 { 20 21 createBorders(); 22 roomObjects.Add(createBackground()); 23 addBlock(new PhysicsObject(blockWidth, blockHeight), 0, 0); 21 24 } 22 25 } -
2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/TheDungeonGame.cs
r3466 r3477 12 12 public class TheDungeonGame : PhysicsGame 13 13 { 14 public const double ROOMWIDTH = 850; 15 public const double ROOMHEIGHT = 500; 14 16 private Player player; 15 17 … … 18 20 IsMouseVisible = true; 19 21 SetWindowSize(800, 600); 20 22 Level.Width = 100000; 23 Level.Height = 100000; 21 24 Level.CreateBorders(); 22 Camera.Zoom ToLevel();25 Camera.Zoom(0.8); 23 26 24 TestRoom testroom = new TestRoom(this,new Vector( Level.Left, Level.Top), new Vector(200, 100), 20);27 TestRoom testroom = new TestRoom(this,new Vector(-460, 300), new Vector(ROOMWIDTH, ROOMHEIGHT), 70); 25 28 testroom.buildLevel(); 26 29 27 30 player = new Player(Vector.Zero); 28 Add(player );31 Add(player, 1); 29 32 30 33 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Lopeta peli"); -
2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/TheDungeonGame.csproj
r3466 r3477 111 111 </ItemGroup> 112 112 <ItemGroup> 113 <Compile Include="LevelGenerator.cs" /> 113 114 <Compile Include="Room.cs" /> 114 115 <Compile Include="Player.cs" />
Note: See TracChangeset
for help on using the changeset viewer.