private Lane createLane(LaneSetting laneSetting, int yBefore, out int yAfter) { // Create the drawing area rectangle for this lane. // We'll draw from the bottom up Rectangle laneArea = new Rectangle(); laneArea.X = 0; laneArea.Y = yBefore; laneArea.Height = configuration.HighwayOptions.LaneWidth; laneArea.Width = this.ParentArea.Width; // Create a new vehicle lane. Lane lane = new Lane(); lane.DrawingBehaviour = new DefaultDrawBehaviour(); lane.Direction = laneSetting.Direction; lane.PercentDifficulty = laneSetting.PercentDifficulty; lane.OffsetPixels = laneSetting.OffsetPixels; lane.LeftTravellingObjectFolder = configuration.HighwayOptions.LeftToRightVehicleImageFolder; lane.RightTravellingObjectFolder = configuration.HighwayOptions.RightToLeftVehicleImageFolder; lane.SetPosition(laneArea); lane.Configure(); // Record the next drawing position. yAfter = yBefore - (laneArea.Height + (configuration.HighwayOptions.LaneSeperatorWidth + 1)); return(lane); }
private GameSettings getGameSettings() { // The game needs to be as configurable as possible. For this purpose we have // a configurations module see TwoWayConfig module. GameSettings gameSettings = new GameSettings(); gameSettings.HighwayOptions.GameScreenArea = this.ClientRectangle; // Key options are configurable... gameSettings.KeyOptions.DownKey = (int)Keys.Down; gameSettings.KeyOptions.UpKey = (int)Keys.Up; gameSettings.KeyOptions.RightKey = (int)Keys.Right; gameSettings.KeyOptions.LeftKey = (int)Keys.Left; // Basic setting to display appearance of the game. gameSettings.HighwayOptions.BottomCurbWidth = 200; gameSettings.HighwayOptions.LaneSeperatorWidth = 1; gameSettings.HighwayOptions.LaneWidth = 50; // Instead of using a resource file for the moving entities, a decision is made // to use image files to improve configurability. gameSettings.HighwayOptions.LeftToRightVehicleImageFolder = @"Files\Images\left"; gameSettings.HighwayOptions.RightToLeftVehicleImageFolder = @"Files\Images\right"; gameSettings.PedestrianOptions.ImageFile = @"Files\Images\pedestrian\human.GIF"; gameSettings.PedestrianOptions.OffsetPixels = 2; List <LaneSetting> lanes = new List <LaneSetting>(); // Lanes are configurable for later versions // Can configure direction, speed, wait frames, and difficulty level. LaneSetting lane1 = new LaneSetting(GameEntityDirectionEnum.Left, 25, 50, 2); LaneSetting lane2 = new LaneSetting(GameEntityDirectionEnum.Right, 32, 50, 2); lanes.Add(lane1); lanes.Add(lane2); gameSettings.HighwayOptions.LaneCollection = lanes; return(gameSettings); }