public MapMesh(MapCompiled map) { texture = new Texture("Images/wall.png"); material = new ObjMaterial("Models/wall.mtl").Lookup("wall"); colorGroups = new List<WallColorGroup>(); var colorMap = new Dictionary<Color, MeshBuilder<VertexTNP3>>(); foreach (var wall in map.Walls) { MeshBuilder<VertexTNP3> builder; if (!colorMap.TryGetValue(wall.Color, out builder)) { builder = new MeshBuilder<VertexTNP3>(); colorMap.Add(wall.Color, builder); } for (int i = 0; i < wall.Verts1.Length-1; i++) makeQuads(wall, builder, i, i+1); if (wall.Shape == ShapeData.Closed) makeQuads(wall, builder, wall.Verts1.Length-1, 0); } foreach (var pair in colorMap) { WallColorGroup g; g.Color = pair.Key; g.Mesh = pair.Value.ToMesh().Compile(); colorGroups.Add(g); } }
public MainWindow(MapCompiled map) { this.map = map; GameWindow = new GameWindow(800, 600); GameWindow.Title = "Rimbazlo"; //var graphicsMode = new GraphicsMode(new ColorFormat(8, 8, 8, 8)); //GameWindow = new GameWindow(640, 480, graphicsMode, "Rimbalzo", GameWindowFlags.Default, DisplayDevice.Default, 3, 1, GraphicsContextFlags.Default); //GameWindow = new GameWindow(640, 480); //GameWindow.TargetRenderPeriod = 0f; zoom = 80f; rotate = 0f; minZoom = 2f; maxZoom = 1000f; xPos = 0f; yPos = 0f; isOrtho = false; showNebula = false; GameWindow.Resize += HandleWindowResize; GameWindow.Keyboard.KeyDown += HandleWindowKeyboardKeyDown; GameWindow.Keyboard.KeyUp += HandleGameWindowKeyboardKeyUp; GameWindow.Mouse.WheelChanged += HandleWindowMouseWheelChanged; GameWindow.Mouse.ButtonDown += HandleGameWindowMouseButtonDown; GameWindow.Mouse.ButtonUp += HandleGameWindowMouseButtonUp; GameWindow.Load += HandleLoad; GameWindow.RenderFrame += HandleRenderFrame; GameWindow.UpdateFrame += HandleUpdateFrame;; }
public OfflineWindow(MapCompiled map) : base(map) { }
public Simulation(MapCompiled map) { World = new World(Vector2.Zero); fixtureMap = new Dictionary<int, FixtureKey>(); Fixture fixture; FixtureKey key; Goalies = new Goalie[map.Goalies.Length]; for (int i = 0; i < map.Goalies.Length; i++) { Goalies[i] = new Goalie(World, map.Goalies[i]); key.Index = i; key.Kind = FixtureKind.Goalie; fixtureMap[Goalies[i].Fixture.FixtureId] = key; } Balls = new Ball[map.Balls.Length]; for (int i = 0; i < map.Balls.Length; i++) { Balls[i] = new Ball(this, map.Balls[i]); key.Index = i; key.Kind = FixtureKind.Ball; fixtureMap[Balls[i].Fixture.FixtureId] = key; } for (int i = 0; i < map.Walls.Count; i++) { var wall = new Wall(World, map.Walls[i]); foreach (var wallFixture in wall.Fixtures) { key.Index = i; key.Kind = FixtureKind.Wall; fixtureMap[wallFixture.FixtureId] = key; } } Ships = new Ship[map.Spawns.Length]; for (int i = 0; i < map.Spawns.Length; i++) { Ships[i] = new Ship(World, map.Spawns[i], i); key.Index = i; key.Kind = FixtureKind.Ship; fixtureMap[Ships[i].Fixture.FixtureId] = key; key.Kind = FixtureKind.Gravity; fixtureMap[Ships[i].FixtureGravity.FixtureId] = key; } Goals = new Color[map.NumGoalTriangles]; int goalCount = 0; foreach (var goal in map.Goals) { foreach (var tri in goal.Triangles) { var goalBody = new Body(World); var goalShape = new PolygonShape(tri, 1f); fixture = goalBody.CreateFixture(goalShape); fixture.IsSensor = true; key.Index = goalCount; key.Kind = FixtureKind.Goal; fixtureMap[fixture.FixtureId] = key; Goals[goalCount] = goal.Color; goalCount++; } } Speedups = new Vector2[map.NumSpeedupTriangles]; int speedupCount = 0; foreach (var speedup in map.Speedups) { foreach (var tri in speedup.Triangles) { var speedupBody = new Body(World); var speedupShape = new PolygonShape(tri, 1f); fixture = speedupBody.CreateFixture(speedupShape); fixture.IsSensor = true; key.Index = speedupCount; key.Kind = FixtureKind.Speedup; fixtureMap[fixture.FixtureId] = key; Speedups[speedupCount] = speedup.Force; speedupCount++; } } World.ContactManager.ContactFilter = ContactFilter; }