public void Update(AbstractHumanoid currentPlayer, RayTracer rayTracer, AbstractMap map, Surface surface) { int columnXLeftMargin = 0; for (int columnId = 0; columnId < columnCount; columnId++) { double straightDistance = Optics.GetStraightDistance(currentPlayer, rayTracer[columnId]); double columnHeight = Optics.GetColumnHeight(straightDistance, screenHeight, heightDistanceRatio); double topMargin = Optics.GetColumnTopMargin(screenHeight, columnHeight, currentPlayer.PositionZ, currentPlayer.IsCrouch, currentPlayer.MouseLook); Rectangle rectangle = rectangleCache[columnId]; rectangle.X = columnXLeftMargin; rectangle.Y = (int)topMargin; rectangle.Height = (int)columnHeight; columnXLeftMargin += columnWidthPixel; double brightness = Optics.GetBrightness(Math.Min(screenHeight, columnHeight), screenHeight); double red, green, blue; map.GetColors(rayTracer[columnId].X, rayTracer[columnId].Y, brightness, out red, out green, out blue); if (echolocationCycle.IsHighlightedColumn(columnId)) { red = Math.Max(0, Math.Min(255, 256 - red)); green = Math.Max(0, Math.Min(255, 256 - green)); blue = Math.Max(0, Math.Min(255, 256 - blue)); this.echolocationBeeper.Beep(straightDistance, columnId, columnCount); } surface.Fill(rectangle, Color.FromArgb(255, (byte)(red), (byte)(green), (byte)(blue))); } }
public void Update(World world, RayTracer rayTracer, Surface surface) { surface.Blit(GetOrCreateMapSurface(world.Map)); foreach (AbstractHumanoid sprite in world.SpritePool) { DrawSprite(sprite, world.SharedConsciousness.IsSpriteViewable(world.CurrentPlayer, sprite, world.Map, rayTracer.Fov), surface); } DrawRayTracer(world.Map, rayTracer, surface); }
private void DrawRayTracer(AbstractMap map, RayTracer rayTracer, Surface surface) { int positionX; int positionY; foreach (RayTracerPoint rayTracerPoint in rayTracer) { positionX = (int)(rayTracerPoint.X / precision); positionY = (int)(rayTracerPoint.Y / precision); if (PointLoader.IsPositionValid(positionX, positionY)) { surface.Draw(PointLoader.GetPoint(positionX, positionY), Color.White); } } }
public AppController() { mainSurface = Video.SetVideoMode(screenWidth, screenHeight, false, false, isFullScreen, true); idealRayTracerResolution = RayTracer.GetValidResolution(idealRayTracerResolution, screenWidth); rayTracer = new RayTracer(idealRayTracerResolution, fov, rayDistanceResolution); this.echolocationBeeper = new EcholocationBeeper(new SoundBackgroundBeeper()); world = new World(random, monsterCount); ai = new Ai(random, world.SpritePool.Count); this.echolocationCycle = new EcholocationCycle(targetFps, echolocationCycleLengthMs, idealRayTracerResolution, isEcholocationBounceBack, echolocationScanPointCount, isEcholocationMirrorScanPoint, 1.0); gameViewer = new GameViewer3D(mainSurface, screenWidth, screenHeight, rayTracer.ColumnCount, world.SpritePool, rayTracer.Fov, random, world.Map, isSoundOn, echolocationCycle, echolocationBeeper); screenCenterPosition = new Point(screenWidth / 2, screenHeight / 2); }
public override void Update(World world, RayTracer rayTracer) { int receivedAttackCycle = world.CurrentPlayer.ReceivedAttackCycle.GetCycleState(); if (receivedAttackCycle > 0 && (receivedAttackCycle == 0 || (random.Next(6) == 0))) { mainSurface.Fill(Color.Red); } else { int gradientOffset = (int)(world.CurrentPlayer.MouseLook * screenHeight) - screenHeight / 2; mainSurface.Blit(gradient.Surface, PointLoader.GetPoint(0, gradientOffset)); columnViewer.Update(world.CurrentPlayer, rayTracer, world.Map, mainSurface); if (isMiniMapOn) { minimap.Update(world, rayTracer, mainSurface); } } mainSurface.Update(); }
public abstract void Update(World world, RayTracer rayTracer);