/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { using (Game1 game = new Game1()) { game.Run(); } }
public void CheckCheckpoints(Game1 g) { if (_hasPassed) if (new Rectangle((int)g.playerCar.x, (int)g.playerCar.y, 1, 1).Intersects(new Rectangle((int)_goal.X, (int)_goal.Y, 100, 500))) { g.laps++; _hasPassed = !_hasPassed; } else ; else if (new Rectangle((int)g.playerCar.x, (int)g.playerCar.y, 1, 1).Intersects(new Rectangle((int)_checkpoint.X, (int)_checkpoint.Y, 100, 500))) { _hasPassed = true; } }
public bool OnRoad(Game1 G) { Color[] RetrievedColor = new Color[4]; map2.GetData<Color>(0, new Rectangle((int)(G.playerCar.x-picPos2.X + Math.Cos(G.playerCar.angle + G.playerCar.drift) * 50), (int)(G.playerCar.y-picPos2.Y + Math.Sin(G.playerCar.angle + G.playerCar.drift) * 50), 1, 1), RetrievedColor, 0, 1); map2.GetData<Color>(0, new Rectangle((int)(G.playerCar.x - picPos2.X + Math.Cos(G.playerCar.angle + G.playerCar.drift) * 0), (int)(G.playerCar.y- picPos2.Y + Math.Sin(G.playerCar.angle + G.playerCar.drift) * 0), 1, 1), RetrievedColor, 1, 1); map2.GetData<Color>(0, new Rectangle((int)(G.playerCar.x - picPos2.X + Math.Cos(G.playerCar.angle + G.playerCar.drift + 0.525) * 57.8), (int)(G.playerCar.y - picPos2.Y + Math.Sin(G.playerCar.angle + 0.525 + G.playerCar.drift) * 57.8), 1, 1), RetrievedColor, 2, 1); map2.GetData<Color>(0, new Rectangle((int)(G.playerCar.x - picPos2.X + Math.Cos(G.playerCar.angle + G.playerCar.drift + MathHelper.PiOver2) * 29), (int)(G.playerCar.y - picPos2.Y + Math.Sin(G.playerCar.angle + G.playerCar.drift + MathHelper.PiOver2) * 29), 1, 1), RetrievedColor, 3, 1); for (int i = 0; i < RetrievedColor.Length; i++) if (RetrievedColor[i].B >125) { return false; } else if (i == 3) return true; return true; }
public Map(Game1 g) { map = g.Content.Load<Texture2D>(@"./Textures/map"); map2 = g.Content.Load<Texture2D>(@"./Textures/mapcheck"); }
public void SetCamera(Game1 g, int X, int Y) { Distance = new Vector2(X, Y) / 2 - new Vector2(g.playerCar.x, g.playerCar.y); if (!(map.Bounds.Right + _picPos.X < X && Distance.X < 0 || _picPos.X > 0 && Distance.X > 0)) { g.playerCar.x += Distance.X; g.copCar.x += Distance.X; _picPos.X += Distance.X; _picPos2.X += Distance.X; _goal.X += Distance.X; _checkpoint.X += Distance.X; for (int i = 0; i < g.copCar.copDest.Count; i++) { Vector2 V = (Vector2)g.copCar.copDest[i]; V.X += Distance.X; g.copCar.copDest[i] = V; } } if (!(map.Bounds.Bottom + _picPos.Y < Y && Distance.Y < 0 || _picPos.Y > 0 && Distance.Y > 0)) { g.playerCar.y += Distance.Y; g.copCar.y += Distance.Y; _goal.Y += Distance.Y; _checkpoint.Y += Distance.Y; _picPos.Y += Distance.Y; _picPos2.Y += Distance.Y; for (int i = 0; i < g.copCar.copDest.Count; i++) { Vector2 V = (Vector2)g.copCar.copDest[i]; V.Y += Distance.Y; g.copCar.copDest[i] = V; } } }
public Menu(Game1 g) { _background = g.Content.Load<Texture2D>(@"Textures/menubg"); _width = g.GraphicsDevice.DisplayMode.Width; _height = g.GraphicsDevice.DisplayMode.Height; }