public void Render(IntPtr rendererPtr, GameBase game)
        {
            dstRect.w = (int)(width * scale * actor.Shield.Radius);
            dstRect.h = (int)(height * scale * actor.Shield.Radius);

            center.x = (int)(dstRect.w);
            center.y = (int)(dstRect.h);

            dstRect.x = (int)(actor.Origin.X - center.x / 2 - Camera.Position.X);
            dstRect.y = (int)(actor.Origin.Y - center.y / 2 - Camera.Position.Y);


            SDL.SDL_RenderCopyEx(rendererPtr, texture, IntPtr.Zero, ref dstRect,
                                 0.0f, ref center, SDL.SDL_RendererFlip.SDL_FLIP_NONE);
        }
        public void Render(IntPtr rendererPtr, GameBase game)
        {
            // TODO: proper looping

            for (int x = -4; x < 4; x++)
            {
                for (int y = -4; y < 4; y++)
                {
                    dstRect.x = (int)(-Camera.Position.X * CAMERA_SCALE) + dstRect.w * x;
                    dstRect.y = (int)(-Camera.Position.Y * CAMERA_SCALE) + dstRect.h * y;

                    SDL.SDL_RenderCopyEx(rendererPtr, backgroundTexture, IntPtr.Zero, ref dstRect,
                                         0.0f, ref center, SDL.SDL_RendererFlip.SDL_FLIP_NONE);
                }
            }
        }
Beispiel #3
0
        public void Render(IntPtr rendererPtr, GameBase game)
        {
            surface = SDL_ttf.TTF_RenderText_Solid(fontPtr, text, textColor);
            texture = SDL.SDL_CreateTextureFromSurface(rendererPtr, surface);

            SDL.SDL_QueryTexture(texture, out _, out _, out int w, out int h);
            dstRect.x = 0;
            dstRect.y = 0;
            dstRect.w = w;
            dstRect.h = h;

            SDL.SDL_RenderCopy(rendererPtr, texture, IntPtr.Zero, ref dstRect);

            SDL.SDL_DestroyTexture(texture);
            SDL.SDL_FreeSurface(surface);
        }
        public override void Render(IntPtr rendererPtr, GameBase game)
        {
            dstRect.w = width * SCALE;
            dstRect.h = height * SCALE;

            center.x = width / 2 * SCALE;
            center.y = height / 2 * SCALE;

            srcRect.x = 0;
            srcRect.y = 0;
            srcRect.w = SPRITE_PIXELS;
            srcRect.h = SPRITE_PIXELS;

            dstRect.x = (int)(actor.Position.X - Camera.Position.X);
            dstRect.y = (int)(actor.Position.Y - Camera.Position.Y);

            SetSrcRect();

            SDL.SDL_RenderCopyEx(rendererPtr, SpriteSheet, ref srcRect, ref dstRect,
                                 actor.RotationDegrees, ref center, SDL.SDL_RendererFlip.SDL_FLIP_NONE);
        }
 public abstract void Render(IntPtr rendererPtr, GameBase game);
Beispiel #6
0
        public static void Update(Vector2 followTarget, GameBase gameBase, float deltaTime)
        {
            Vector2 targetPosition = new Vector2(followTarget.X - gameBase.WindowWidth / 2.0f, followTarget.Y - gameBase.WindowHeight / 2.0f);

            Position = Vector2.Lerp(Position, targetPosition, 0.8f * deltaTime);
        }