Ejemplo n.º 1
0
        public void Render(IntPtr rendererPtr, GameBase game)
        {
            surface = SDL_ttf.TTF_RenderText_Solid(fontPtr, text, textColor);
            texture = SDL.SDL_CreateTextureFromSurface(rendererPtr, surface);

            int w, h;

            SDL.SDL_QueryTexture(texture, out _, out _, out w, out 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);
        }
Ejemplo n.º 2
0
        public void Render(IntPtr rendererPtr, GameBase game)
        {
            // Edge wrap
            dstRect.x = (int)car.Position.X % game.WindowWidth;
            dstRect.y = (int)car.Position.Y % game.WindowHeight;

            // fix negatives
            if (dstRect.x < 0)
            {
                dstRect.x += game.WindowWidth;
            }

            if (dstRect.y < 0)
            {
                dstRect.y += game.WindowHeight;
            }

            // wrap when half off screen
            dstRect.x -= halfCarLen;
            dstRect.y -= halfCarLen;

            SDL.SDL_RenderCopyEx(rendererPtr, carTexture, IntPtr.Zero, ref dstRect,
                                 car.RotationDegrees, ref center, SDL.SDL_RendererFlip.SDL_FLIP_NONE);
        }