Example #1
0
        public void LoadTracks()
        {
            string path = Path.Combine(Environment.CurrentDirectory, "Tracks");

            string[] files = Directory.GetFiles(path, "*.txt");
            foreach (var file in files)
            {
                Tracks.Add(Track.LoadFromTxt(file));
            }
        }
Example #2
0
        public Game()
        {
            State     = GameState.CountDown;
            CountDown = TimeSpan.FromSeconds(3);

            Track = Track.LoadFromTxt("./Tracks/Track1.txt");

            Vector goal          = Track.GetGoalPosition();
            Vector startOffset1  = new Vector();
            Vector startOffset2  = new Vector();
            float  startRotation = 0f;

            switch (Track.GetTileByIndex((int)goal.X, (int)goal.Y))
            {
            case TrackTile.GoalDown:
                startOffset1  = new Vector(0.75f, 0.25f);
                startOffset2  = new Vector(0.25f, 0.25f);
                startRotation = 180f;
                break;

            case TrackTile.GoalLeft:
                startOffset1  = new Vector(0.75f, 0.75f);
                startOffset2  = new Vector(0.75f, 0.25f);
                startRotation = -90f;
                break;

            case TrackTile.GoalRight:
                startOffset1  = new Vector(0.25f, 0.25f);
                startOffset2  = new Vector(0.25f, 0.75f);
                startRotation = 90f;
                break;

            case TrackTile.GoalUp:
                startOffset1  = new Vector(0.25f, 0.75f);
                startOffset2  = new Vector(0.75f, 0.75f);
                startRotation = 0f;
                break;
            }

            Player1 = new Player()
            {
                Position = (goal + startOffset1) * Track.CELLSIZE, Direction = startRotation
            };
        }