public void draw() { // Clear the renderer SDL.SDL_RenderClear(Engine.renderer); // Render the background SDL.SDL_RenderCopy(Engine.renderer, am.GetAsset("back"), IntPtr.Zero, IntPtr.Zero); // Render the map // Camera offset int cx, cy; cx = (int)(harambe.getX() + (harambe.getWidth() / 2)) - Engine.GetContextWidth() / 2; if (cx < 0) { cx = 0; } cy = (int)(harambe.getY() + (harambe.getHeight() / 2)) - (height * TILE_SIZE) + Engine.GetContextHeight() / 2; Console.WriteLine("cy: {0}", cy); if (cy > 0) { cy = 0; } // Iterate over the mapdata SDL.SDL_Rect r = new SDL.SDL_Rect(); r.w = TILE_SIZE; r.h = TILE_SIZE; for (int mx = 0; mx < width; mx++) { for (int my = 0; my < height; my++) { // Calculate render coordinates r.x = mx * TILE_SIZE - cx; r.y = (Engine.GetContextHeight() - (height * TILE_SIZE)) + (my * TILE_SIZE) - cy; // Render the tile // TODO: Change this to render based on the tilemap if (mapdata[my * width + mx] == 1) { SDL.SDL_RenderCopy(Engine.renderer, am.GetAsset("tile"), IntPtr.Zero, ref r); } } } // Render the player float x, y; x = harambe.getX(); y = harambe.getY(); r.x = (int)x - cx; r.y = (Engine.GetContextHeight() - (height * TILE_SIZE)) + (int)y - cy; r.w = 128; r.h = 128; //SDL.SDL_RenderCopy(Engine.renderer, am.GetAsset("player1"), IntPtr.Zero, ref r); SDL.SDL_SetRenderDrawColor(Engine.renderer, 255, 0, 0, 255); SDL.SDL_RenderFillRect(Engine.renderer, ref r); SDL.SDL_SetRenderDrawColor(Engine.renderer, 255, 255, 255, 255); // Present SDL.SDL_RenderPresent(Engine.renderer); }