Changeset 3477 for 2012/27/DenisZ


Ignore:
Timestamp:
2012-07-03 13:17:05 (8 years ago)
Author:
dezhidki
Message:

Talletus.

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  
    2323        { 
    2424            keyboard = Game.Keyboard; 
     25            CanRotate = false; 
    2526            setupKeys(); 
    2627        } 
  • 2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/Room.cs

    r3466 r3477  
    1212        public Vector Position { get; set; } 
    1313        public double width, height, thickness; 
    14         private List<IPhysicsObject> roomObjects = new List<IPhysicsObject>(); 
     14        protected List<IPhysicsObject> roomObjects = new List<IPhysicsObject>(); 
    1515        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; 
    1621        public Game Game { get; set; } 
    1722 
     
    2328            height = size.Y; 
    2429            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]; 
    2540        } 
    2641 
     
    3550                Game.Add(obj); 
    3651            } 
     52 
     53            foreach (IPhysicsObject obj in insideObjects) 
     54            { 
     55                if(obj != null) 
     56                Game.Add(obj); 
     57            } 
     58             
    3759 
    3860            isBuilt = true; 
     
    5072        } 
    5173 
     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 
    5282        public void createBorders() 
    5383        { 
    54             PhysicsObject wallTop = createWall(Position, width, thickness); 
     84            PhysicsObject wallTop = createWall(Position, width + thickness, thickness); 
    5585            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); 
    5888            roomObjects.Add(wallTop); 
    5989            roomObjects.Add(wallLeft); 
     
    70100            return wall; 
    71101        } 
    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 
    73114    } 
    74115 
    75116    class RoomTemplates 
    76117    { 
    77          
     118 
    78119    } 
    79120} 
  • 2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/TestRoom.cs

    r3466 r3477  
    44using System.Text; 
    55using Jypeli; 
     6using MathHelper; 
    67 
    78namespace Rooms 
     
    1920        { 
    2021            createBorders(); 
     22            roomObjects.Add(createBackground()); 
     23            addBlock(new PhysicsObject(blockWidth, blockHeight), 0, 0); 
    2124        } 
    2225    } 
  • 2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/TheDungeonGame.cs

    r3466 r3477  
    1212public class TheDungeonGame : PhysicsGame 
    1313{ 
     14    public const double ROOMWIDTH = 850; 
     15    public const double ROOMHEIGHT = 500; 
    1416    private Player player; 
    1517 
     
    1820        IsMouseVisible = true; 
    1921        SetWindowSize(800, 600); 
    20          
     22        Level.Width = 100000; 
     23        Level.Height = 100000; 
    2124        Level.CreateBorders(); 
    22         Camera.ZoomToLevel(); 
     25        Camera.Zoom(0.8); 
    2326 
    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); 
    2528        testroom.buildLevel(); 
    2629 
    2730        player = new Player(Vector.Zero); 
    28         Add(player); 
     31        Add(player, 1); 
    2932 
    3033        Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Lopeta peli");    
  • 2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/TheDungeonGame.csproj

    r3466 r3477  
    111111  </ItemGroup> 
    112112  <ItemGroup> 
     113    <Compile Include="LevelGenerator.cs" /> 
    113114    <Compile Include="Room.cs" /> 
    114115    <Compile Include="Player.cs" /> 
Note: See TracChangeset for help on using the changeset viewer.