예제 #1
0
        protected override void Render(Renderer renderer, Time time)
        {
            if (IsVisible && time.CheckEvery(DoDamageEvery))
                DoDamage();

            base.Render(renderer, time);
        }
예제 #2
0
 private void DrawImage(Time time)
 {
     var sprite = GetCurrentSprite(time);
     var heightSprite = 1.0f / Image.PixelSize.Height * sizeSprite.Height;
     var widthSprite = 1.0f / Image.PixelSize.Width * sizeSprite.Width;
     CalculateCornersAndPaint(sprite, widthSprite, heightSprite);
 }
예제 #3
0
 protected override void Render(Renderer renderer, Time time)
 {
     Rotation += rotationSpeed * time.CurrentDelta;
     DrawArea.Center += velocity * time.CurrentDelta;
     velocity.ReflectIfHittingBorder(DrawArea, renderer.Screen.Viewport);
     base.Render(renderer, time);
 }
예제 #4
0
 protected override void Render(Renderer renderer, Time time)
 {
     renderer.DrawLine(DrawArea.TopLeft, DrawArea.TopRight, Color);
     renderer.DrawLine(DrawArea.TopRight, DrawArea.BottomRight, Color);
     renderer.DrawLine(DrawArea.BottomRight, DrawArea.BottomLeft, Color);
     renderer.DrawLine(DrawArea.BottomLeft, DrawArea.TopLeft, Color);
 }
예제 #5
0
 protected override void Render(Renderer renderer, Time time)
 {
     MoveSprite();
     Color.AlphaValue = 1.0f - elapsed / timeout;
     base.Render(renderer, time);
     CheckIfTimeToDispose(time);
 }
예제 #6
0
 public LogoGame(Renderer render, Time time, Window window)
 {
     box = new ColoredRectangle(render, Point.Half, Size.Half, Color.Red);
     this.time = time;
     this.window = window;
     window.BackgroundColor = Color.CornflowerBlue;
 }
 protected override void Render(Renderer renderer, Time time)
 {
     var gravity = new Point(0.0f, 9.81f);
     if (DrawArea.Bottom < renderer.Screen.Bottom)
         velocity += gravity * 0.2f * time.CurrentDelta;
     base.Render(renderer, time);
 }
예제 #8
0
 protected override void Render(Renderer renderer, Time time)
 {
     var rotSpeed = RotationSpeed * time.CurrentDelta;
     if (Rotation < 0 - rotSpeed)
         Rotation += rotSpeed;
     base.Render(renderer, time);
 }
예제 #9
0
 protected override void Render(Renderer renderer, Time time)
 {
     screen = renderer.Screen;
     if (Rotation == 0.0f)
         DrawImage();
     else
         DrawImageWithRotation();
 }
예제 #10
0
        protected override void Render(Renderer renderer, Time time)
        {
            if (areCachedLinesOutOfDate)
                CacheLines();

            foreach (Line2D line in lines)
                renderer.DrawLine(TopLeft + line.StartPosition, TopLeft + line.EndPosition, Color);
        }
예제 #11
0
        protected override void Render(Renderer renderer, Time time)
        {
            if (areEllipsePointsOutOfDate)
                StoreEllipsePoints();

            for (int i = 1; i < ellipsePoints.Length; i++)
                renderer.DrawLine(Center + ellipsePoints[i - 1], Center + ellipsePoints[i], Color);
        }
예제 #12
0
 protected override void Render(Renderer renderer, Time time)
 {
     xPosition = xPosition.Clamp(renderer.Screen.Left + HalfWidth,
         renderer.Screen.Right - HalfWidth);
     var yPosition = renderer.Screen.GetInnerPoint(0.5f, 0.9f).Y;
     DrawArea = Rectangle.FromCenter(xPosition, yPosition, Width, Height);
     base.Render(renderer, time);
 }
예제 #13
0
 protected override void Render(Renderer renderer, Time time)
 {
     Color.AlphaValue = 1.0f - elapsed / timeout;
     base.Render(renderer, time);
     elapsed += time.CurrentDelta;
     if (elapsed >= timeout)
         Dispose();
 }
예제 #14
0
 public Game(Content content, Renderer renderer, Time time, Score score, RabbitsGrid rabbits)
 {
     gameOverImage = content.Load<Image>("GameOver");
     this.time = time;
     this.score = score;
     this.renderer = renderer;
     this.rabbits = rabbits;
     rabbits.InitializeRabbits();
 }
예제 #15
0
 private Point GetCurrentSprite(Time time)
 {
     frameOffset += time.CurrentDelta;
     if (frameOffset > spriteTime)
     {
         frameNumber = (frameNumber + 1) % frames.Length;
         frameOffset = 0;
     }
     return frames[frameNumber];
 }
예제 #16
0
 public RabbitsGrid(Content content, Renderer renderer, Time time, Score score)
     : base(GetColumns(renderer.Screen.Viewport), GetRows(renderer.Screen.Viewport))
 {
     rabbitImage = content.Load<Image>("Rabbit");
     deadRabbitImage = content.Load<Image>("DeadRabbit");
     malletHitSound = content.Load<Sound>("MalletHit");
     malletBloodImage = content.Load<Image>("BloodSplatter");
     this.renderer = renderer;
     this.score = score;
     this.time = time;
 }
        protected override void Render(Renderer renderer, Time time)
        {
            float frictionMultiplier = 1.0f - FrictionFactorPerSecond * time.CurrentDelta;
            velocity *= frictionMultiplier;
            rotationSpeed *= frictionMultiplier;
            Point remVelocity = velocity;
            base.Render(renderer, time);
            if (velocity == remVelocity)
                return;

            frictionMultiplier = 1.0f - FrictionFactorPerSecond * 0.5f;
            velocity *= frictionMultiplier;
        }
예제 #18
0
 private void RegisterInputCommands(InputCommands inputCommands, Time time)
 {
     inputCommands.Add(Key.CursorLeft, State.Pressed,
         () => xPosition -= PaddleMovementSpeed * time.CurrentDelta);
     inputCommands.Add(Key.CursorRight, State.Pressed,
         () => xPosition += PaddleMovementSpeed * time.CurrentDelta);
     inputCommands.Add(MouseButton.Left, State.Pressed,
         mouse => xPosition += mouse.Position.X - Position.X);
     inputCommands.Add(State.Pressed, touch => xPosition += touch.GetPosition(0).X - Position.X);
     inputCommands.Add(GamePadButton.Left, State.Pressed,
         () => xPosition -= PaddleMovementSpeed * time.CurrentDelta);
     inputCommands.Add(GamePadButton.Right, State.Pressed,
         () => xPosition += PaddleMovementSpeed * time.CurrentDelta);
 }
예제 #19
0
 protected override void Render(Renderer renderer, Time time)
 {
     Color = Color.GetRandomBrightColor();
     base.Render(renderer, time);
 }
예제 #20
0
 protected override void Render(Renderer renderer, Time time)
 {
     renderer.DrawRectangle(Rectangle.One, new Color(0, 0, 0, Color.AlphaValue));
     base.Render(renderer, time);
 }
예제 #21
0
 public Paddle(Content content, InputCommands inputCommands, Time time)
     : base(content.Load<Image>("Paddle"), Rectangle.FromCenter(Point.Half, Size.Zero))
 {
     RegisterInputCommands(inputCommands, time);
 }
예제 #22
0
 protected override void Render(Renderer renderer, Time time)
 {
     AreEllipsePointsOutOfDate();
     DrawInnerEllipse(renderer);
     DrawBorderEllipse(renderer);
 }
예제 #23
0
 protected override void Render(Renderer renderer, Time time)
 {
     HasBeenRendered = true;
 }
예제 #24
0
        protected override void Render(Renderer renderer, Time time)
        {
            if (isOnPaddle)
                UpdateOnPaddle();
            else
                UpdateInFlight(time.CurrentDelta);

            float aspect = renderer.Screen.ToPixelSpace(Size).AspectRatio;
            DrawArea = Rectangle.FromCenter(Position, new Size(Height / aspect, Height));
            base.Render(renderer, time);
        }
예제 #25
0
 protected override void Render(Renderer renderer, Time time)
 {
     renderer.DrawRectangle(DrawArea, Color);
 }
예제 #26
0
 public void Settle(Time time, float fallSpeed)
 {
     settling += MathExtensions.Min(fallSpeed * time.CurrentDelta, 1.0f);
     if (settling >= SettleTime && Affix != null)
         Affix();
 }
예제 #27
0
 public void Run(Time time, float fallSpeed)
 {
     Top += MathExtensions.Min(fallSpeed * time.CurrentDelta, 1.0f);
 }
예제 #28
0
        protected override void Render(Renderer renderer, Time time)
        {
            borders = renderer.Screen.Viewport;
            if (isOnPaddle)
                UpdateOnPaddle();
            else
                UpdateInFlight(time.CurrentDelta);

            DrawArea = Rectangle.FromCenter(Position, new Size(Height));
            base.Render(renderer, time);
        }
예제 #29
0
 protected override void Render(Renderer renderer, Time time)
 {
     foreach (Brick brick in Bricks)
         brick.Render(renderer);
 }
예제 #30
0
 protected override void Render(Renderer renderer, Time time)
 {
     ShowDollars(renderer.Screen.TopLeft + new Point(0.1f, 0.042f), CurrentMoney);
     ShowKills(renderer.Screen.Viewport.TopRight + new Point(-0.09f, 0.042f), CurrentKills);
 }