Ignore:
Timestamp:
2012-07-04 14:33:08 (9 years ago)
Author:
dezhidki
Message:

Finished camera.
Adjusted perfect speed for camera.

Location:
2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • 2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/LevelGenerator.cs

    r3538 r3539  
    1212        private double width, height; 
    1313        private int roomAmountHor, roomAmountVert; 
    14         private Game game; 
     14        private TheDungeonGame game; 
    1515        private Room[,] rooms; 
    1616        private List<Room> roomList = new List<Room>(); 
     
    5050            foreach (Room room in roomList) 
    5151            { 
     52                room.initRoom(); 
    5253                room.buildLevel(); 
    5354            } 
  • 2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/Room.cs

    r3538 r3539  
    2121        protected Vector insidePos; 
    2222        protected int bWidth, bHeight; 
    23         public Game Game { get; set; } 
     23        public TheDungeonGame Game { get; set; } 
    2424        public Vector PosOnGrid { get; set; } 
    2525        public PhysicsObject wall; 
    2626 
    27         public Room(Game game, Vector pos, Vector size, double thickness) 
     27        public Room(TheDungeonGame game, Vector pos, Vector size, double thickness) 
    2828        { 
    2929            Game = game; 
     
    9898 
    9999        // En vitsinyt käyttää enempää aikaa tämän parantamiseksi. Helppo ja toimiva 
    100         public void addDoors(int[] directions) 
    101         { 
    102             if (directions.Length > 4) throw new ArgumentException("Argument's length must be 4!"); 
    103  
    104             for (int i = 0; i < directions.Length; i++) 
    105             { 
    106                 if (directions[i] == -1) continue; 
     100        public void addDoors() 
     101        { 
     102         //   if (directions.Length > 4) throw new ArgumentException("Argument's length must be 4!"); 
     103 
     104            for (int i = 0; i < 4; i++) 
     105            { 
     106                Room room = Game.LevelGen.getRoomAt(PosOnGrid + RoomDirection.getOffsetFromDir(i)); 
     107 
     108                if (room == null) continue; 
    107109 
    108110                PhysicsObject door = null; 
    109111 
    110                 if (directions[i] == RoomDirection.North) 
     112                if (i == RoomDirection.North) 
    111113                { 
    112114                    door = PhysicsObject.CreateStaticObject(thickness, thickness); 
     
    115117                } 
    116118                else 
    117                     if (directions[i] == RoomDirection.East) 
     119                    if (i == RoomDirection.East) 
    118120                    { 
    119121                        door = PhysicsObject.CreateStaticObject(thickness, thickness); 
     
    122124                    } 
    123125                    else 
    124                         if (directions[i] == RoomDirection.South) 
     126                        if (i == RoomDirection.South) 
    125127                        { 
    126128                            door = PhysicsObject.CreateStaticObject(thickness, thickness); 
     
    129131                        } 
    130132                        else 
    131                             if (directions[i] == RoomDirection.West) 
     133                            if (i == RoomDirection.West) 
    132134                            { 
    133135                                door = PhysicsObject.CreateStaticObject(thickness, thickness); 
  • 2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/TestRoom.cs

    r3525 r3539  
    1111    { 
    1212 
    13         public TestRoom(Game game, Vector pos, Vector size, double thickness) 
     13        public TestRoom(TheDungeonGame game, Vector pos, Vector size, double thickness) 
    1414            : base(game, pos, size, thickness) 
    1515        { 
    16             initRoom(); 
    1716        } 
    1817 
    1918        public override void initRoom() 
    2019        { 
    21             int[] doorLocations = { RoomDirection.North, RoomDirection.South, RoomDirection.West, RoomDirection.East }; 
     20           // int[] doorLocations = { RoomDirection.North, RoomDirection.South, RoomDirection.West, RoomDirection.East }; 
    2221            createBorders(); 
    2322            roomObjects.Add(createBackground()); 
    24             addDoors(doorLocations); 
     23            addDoors(); 
    2524        //    PhysicsObject testblock = PhysicsObject.CreateStaticObject(blockWidth, blockHeight); 
    2625          //  addBlock(testblock, 0, 1); 
  • 2012/27/DenisZ/TheDungeonGame/TheDungeonGame/TheDungeonGame/TheDungeonGame.cs

    r3538 r3539  
    2121    public LevelGenerator LevelGen { get { return generator; } } 
    2222 
    23     private Vector cameraPosMission; 
    24     private Vector cameraVelocity, newPos; 
     23    private Vector cameraPosMission, cameraVelocity, newPos, currentPos; 
    2524    private bool moveCamera = false; 
    2625 
     
    4948    public void moveToRoom(Room room) 
    5049    { 
    51         //  Camera.Position = room.Position + new Vector(ROOMWIDTH / 2 + ROOMTHICKNESS / 2, -ROOMHEIGHT / 2 + ROOMTHICKNESS / 4); 
    52         // Camera.Velocity = new Vector(0, 1); 
    53         Vector currentpos = player.currentRoom.Position + new Vector(ROOMWIDTH / 2 + ROOMTHICKNESS / 2, -ROOMHEIGHT / 2 + ROOMTHICKNESS / 4); 
    54         Vector newpos = room.Position + new Vector(ROOMWIDTH / 2 + ROOMTHICKNESS / 2, -ROOMHEIGHT / 2 + ROOMTHICKNESS / 4); 
    55  
    56         moveCameraTo(newpos - currentpos); 
     50        currentPos = player.currentRoom.Position + new Vector(ROOMWIDTH / 2 + ROOMTHICKNESS / 2, -ROOMHEIGHT / 2 + ROOMTHICKNESS / 4); 
     51        newPos = room.Position + new Vector(ROOMWIDTH / 2 + ROOMTHICKNESS / 2, -ROOMHEIGHT / 2 + ROOMTHICKNESS / 4); 
     52        moveCameraTo(newPos - currentPos); 
    5753        player.Position = generator.getRoomAt(room.PosOnGrid).Position + new Vector(ROOMWIDTH / 2, -ROOMHEIGHT / 2); 
    5854    } 
     
    6157    { 
    6258        cameraPosMission = pos; 
    63         newPos = Camera.Position + pos; 
    64         cameraVelocity = pos; 
     59        cameraVelocity = pos * 1.5 ; 
    6560        moveCamera = true; 
    6661    } 
     
    7065        Camera.Velocity = cameraVelocity; 
    7166        Vector remainingLenght = Camera.Position - newPos; 
    72         if ((int)remainingLenght.X == 0 && (int)remainingLenght.Y == 0) 
     67        Console.WriteLine(Math.Abs(remainingLenght.X)+", " + Math.Abs(remainingLenght.Y)); 
     68        if (Math.Abs((int)remainingLenght.X) < 20 && Math.Abs((int)remainingLenght.Y) < 20) 
    7369        { 
     70            cameraPosMission = Vector.Zero; 
     71            cameraVelocity = Vector.Zero; 
     72            Camera.Velocity = cameraVelocity; 
    7473            Camera.Position = newPos; 
    7574            moveCamera = false; 
     
    113112            moveCameraPart(); 
    114113        } 
    115         else 
    116         { 
    117             cameraPosMission = Vector.Zero; 
    118             cameraVelocity = Vector.Zero; 
    119             newPos = Vector.Zero; 
    120             Camera.Velocity = cameraVelocity; 
    121         } 
    122114 
    123115        player.Update(time); 
Note: See TracChangeset for help on using the changeset viewer.