Changeset 7816 for 2016/27


Ignore:
Timestamp:
2016-07-05 18:47:56 (3 years ago)
Author:
empaheik
Message:

Kamera yrittää seurata kahta pelaajaa

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2016/27/ohjaajat/VenienteFragore/VenienteFragore/VenienteFragore/VenienteFragore.cs

    r7811 r7816  
    66using Jypeli.Effects; 
    77using Jypeli.Widgets; 
     8using System.Linq; 
    89using SimplePhysics; 
    910 
     
    1920        private Vector cameraSpeed = new Vector(2.0, 4.0); 
    2021        private Vector cameraTarget; 
     22 
     23        SimplePhysics.Object borderleft; 
     24        SimplePhysics.Object borderright; 
    2125 
    2226        public VenienteFragore() : base(tileSize: 50) 
     
    6367            Camera.StayInLevel = true; 
    6468 
     69            Window.Width = 1500; 
     70            Window.Height = 750; 
     71 
     72            borderleft = new SimplePhysics.Object(TileSize, Level.Height) { X = Camera.X + Window.Width / 2, IsVisible = false }; 
     73            Add(borderleft); 
     74            borderright = new SimplePhysics.Object(TileSize, Level.Height) { X = Camera.X - Window.Width / 2, IsVisible = false}; 
     75            Add(borderright); 
     76 
    6577            Timer checkit = new Timer(); 
    6678            checkit.Interval = 0.02; 
     
    7688            { 
    7789                case 1: 
     90                    Camera.StopFollowing(); 
    7891                    Player soloYolo = activePlayers[0]; 
    7992                    cameraTarget.X = soloYolo.Position.X + (soloYolo.FacingDirection.GetVector().X * (TileSize * 4)); 
     
    8295                    break; 
    8396                case 2: 
    84                     cameraTarget = activePlayers[1].Position; 
     97                    Vector minPosition = new Vector(activePlayers.Max(p => p.X), activePlayers.Min(p => p.Y)); 
     98                    Vector maxPosition = new Vector(activePlayers.Min(p => p.X), activePlayers.Max(p => p.Y)); 
     99                    cameraTarget = (minPosition + maxPosition) * 0.5; 
    85100                    break; 
    86101                default: 
     
    89104                    break; 
    90105            } 
     106             
     107            borderleft.X = Camera.X + Window.Width / 2 ; 
     108            borderright.X = Camera.X - Window.Width / 2; 
    91109        } 
    92110 
     
    102120        { 
    103121            if (objectMethods.ContainsKey(name)) 
    104                 objectMethods[name](position, width, height, properties); 
     122            objectMethods[name](position, width, height, properties); 
    105123            else 
    106124                throw new Exception("Unknown object type: " + name); 
Note: See TracChangeset for help on using the changeset viewer.