### Create new camera with world boundaries Source: https://github.com/kikito/gamera/blob/master/README.md Initialize a new Gamera camera instance with specified world boundaries. The parameters define the left, top, width, and height of the world. This is the primary setup step required before using the camera. ```lua local cam = gamera.new(0,0,2000,2000) ``` -------------------------------- ### Convert world coordinates to screen coordinates in Lua Source: https://context7.com/kikito/gamera/llms.txt Demonstrates conversion of world coordinates to screen coordinates using the camera's toScreen method. Includes a practical example of drawing minimap indicators that show entity positions and camera viewport. Requires Gamera library and Love2D framework. The example shows how to maintain UI elements independent of camera transformations. ```lua local gamera = require 'gamera' local cam = gamera.new(0, 0, 2000, 2000) cam:setPosition(500, 500) -- Example: Draw minimap indicators function love.draw() -- Draw main game view cam:draw(function(l, t, w, h) -- Draw world drawEntities() end) -- Draw minimap (not affected by camera) local minimapX, minimapY = 650, 50 local minimapScale = 0.1 love.graphics.setColor(0, 0, 0, 0.5) love.graphics.rectangle('fill', minimapX, minimapY, 200, 200) -- Draw entity positions on minimap for _, entity in ipairs(entities) do local screenX, screenY = cam:toScreen(entity.x, entity.y) local minimapDotX = minimapX + entity.x * minimapScale local minimapDotY = minimapY + entity.y * minimapScale love.graphics.setColor(1, 0, 0) love.graphics.circle('fill', minimapDotX, minimapDotY, 3) end -- Draw camera viewport indicator on minimap local camX, camY = cam:getPosition() local vl, vt, vw, vh = cam:getVisible() love.graphics.setColor(1, 1, 0) love.graphics.rectangle('line', minimapX + vl * minimapScale, minimapY + vt * minimapScale, vw * minimapScale, vh * minimapScale) end ``` -------------------------------- ### Query camera window boundaries Source: https://github.com/kikito/gamera/blob/master/README.md Get the current screen window boundaries used by the camera. Returns left, top, width, and height values representing the display area. This corresponds to the area set by setWindow or the full screen by default. ```lua cam:getWindow() -- returns the l,t,w,h of the screen window ``` -------------------------------- ### Convert screen coordinates to world coordinates in Lua Source: https://context7.com/kikito/gamera/llms.txt Shows how to convert screen coordinates to world coordinates using the camera's toWorld method. Includes examples of mouse click handling in world space and camera panning through mouse dragging. Requires the Gamera library and Love2D framework. The coordinate transformation accounts for camera scale and position. ```lua local gamera = require 'gamera' local cam = gamera.new(0, 0, 2000, 2000) cam:setPosition(500, 500) cam:setScale(2.0) -- Example: Mouse click in world space function love.mousepressed(mx, my, button) local worldX, worldY = cam:toWorld(mx, my) -- Check if clicked on any game objects for _, entity in ipairs(entities) do if entity:containsPoint(worldX, worldY) then entity:onClick() end end print(string.format("Clicked screen (%d, %d) -> world (%.2f, %.2f)", mx, my, worldX, worldY)) end -- Example: Drag-to-pan camera local dragging = false local lastMouseX, lastMouseY function love.mousepressed(x, y, button) if button == 2 then -- Right mouse button dragging = true lastMouseX, lastMouseY = x, y end end function love.mousemoved(x, y, dx, dy) if dragging then local worldDX = dx / cam:getScale() local worldDY = dy / cam:getScale() local camX, camY = cam:getPosition() cam:setPosition(camX - worldDX, camY - worldDY) end end function love.mousereleased(x, y, button) if button == 2 then dragging = false end end ``` -------------------------------- ### Query world boundaries with camera in Lua Source: https://context7.com/kikito/gamera/llms.txt Shows how to retrieve and use world boundaries defined in the camera. Includes examples of checking if entities are within world bounds and respawning entities that leave the world. Uses the getWorld method to retrieve boundary information. Requires the Gamera library for Love2D game development. ```lua local gamera = require 'gamera' local cam = gamera.new(0, 0, 2000, 2000) local left, top, width, height = cam:getWorld() print(string.format("World: left=%d, top=%d, width=%d, height=%d", left, top, width, height)) -- Output: World: left=0, top=0, width=2000, height=2000 -- Example: Check if entity is within world bounds function isInWorld(entity) local wl, wt, ww, wh = cam:getWorld() return entity.x >= wl and entity.x <= wl + ww and entity.y >= wt and entity.y <= wt + wh end -- Example: Respawn entities that leave the world for _, entity in ipairs(entities) do if not isInWorld(entity) then entity:respawn(1000, 1000) end end ``` -------------------------------- ### Query camera scale Source: https://github.com/kikito/gamera/blob/master/README.md Get the current zoom scale factors for the camera. Returns separate scaleX and scaleY parameters that determine the camera's magnification level. The default scale is 1.0 for no transformation. ```lua cam:getScale() -- returns the current scaleX and scaleY parameters ``` -------------------------------- ### Query Visible Area Source: https://context7.com/kikito/gamera/llms.txt This endpoint determines the axis-aligned bounding box of the currently visible world area. It demonstrates how to get the visible area and use it for efficient entity culling. It also provides an example of how the visible area might include more than strictly visible due to camera rotation. ```APIDOC ## GET /api/visible_area ### Description Get the axis-aligned bounding box of the currently visible world area. ### Method GET ### Endpoint /api/visible_area ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Request Example { "example": "N/A" } ### Response #### Success Response (200) - **left** (number) - Left coordinate of the visible area - **top** (number) - Top coordinate of the visible area - **width** (number) - Width of the visible area - **height** (number) - Height of the visible area #### Response Example { "left": 500.00, "top": 500.00, "width": 400.00, "height": 400.00 } ``` -------------------------------- ### Disable Camera Clamping Source: https://context7.com/kikito/gamera/llms.txt This endpoint demonstrates how to disable camera clamping, allowing the camera to show world boundaries by expanding the world. It provides two methods for toggling clamping dynamically and an example of zoom-based clamping. ```APIDOC ## POST /api/disable_clamping ### Description Allow camera to show world boundaries by expanding the world. ### Method POST ### Endpoint /api/disable_clamping ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Request Example { "example": "N/A" } ### Response #### Success Response (200) - None #### Response Example { "message": "Camera clamping disabled" } ``` -------------------------------- ### Rotate Gamera Camera View Source: https://context7.com/kikito/gamera/llms.txt Rotates the camera's view around its center point by a specified angle in radians. It includes examples for setting a fixed angle, animating the rotation over time, and retrieving the current rotation angle. ```lua local gamera = require 'gamera' local cam = gamera.new(0, 0, 2000, 2000) -- Rotate camera by 45 degrees (angle in radians) cam:setAngle(math.pi / 4) -- Rotate 90 degrees cam:setAngle(math.pi / 2) -- Example: Smooth rotation animation local currentAngle = 0 function love.update(dt) currentAngle = currentAngle + dt * 0.5 -- Rotate 0.5 radians per second cam:setAngle(currentAngle) end -- Reset rotation cam:setAngle(0) -- Get current rotation local angle = cam:getAngle() print("Current angle: " .. angle .. " radians") ``` -------------------------------- ### Query visible area corners Source: https://github.com/kikito/gamera/blob/master/README.md Get the exact corner coordinates of the rotated rectangle representing the camera's visible region. Returns eight values (x1,y1,x2,y2,x3,y3,x4,y4) representing the four corners of the visible area in world coordinates. ```lua cam:getVisibleCorners() -- returns the corners of the rotated rectangle ``` -------------------------------- ### Manual tile quad creation in Lua Source: https://context7.com/kikito/gamera/llms.txt Shows manual creation of tile quads with borders to prevent seams. Requires only LÖVE2D. Input is a tileset image with borders, output is seamless tile rendering. ```lua function love.load() local tileset = love.graphics.newImage('tiles_with_borders.png') -- For a 32x32 tile with 2px border, the quad is at (2,2) in image space -- and includes the center 32x32 pixels local grassQuad = love.graphics.newQuad(2, 2, 32, 32, tileset:getDimensions()) local dirtQuad = love.graphics.newQuad(38, 2, 32, 32, tileset:getDimensions()) -- Note: 38 = 2 (border) + 32 (tile) + 2 (border) + 2 (next border) end ``` -------------------------------- ### Create Gamera Camera Instance Source: https://context7.com/kikito/gamera/llms.txt Initializes a new Gamera camera object with specified world boundaries. The camera can also be created with negative boundaries, and by default, it uses the screen dimensions obtained from love.graphics.getWidth/Height(). ```lua local gamera = require 'gamera' -- Create a camera with world boundaries: left=0, top=0, width=2000, height=2000 local cam = gamera.new(0, 0, 2000, 2000) -- Example with negative boundaries (useful for centered coordinates) local centeredCam = gamera.new(-1000, -1000, 2000, 2000) -- By default, the camera uses the entire screen dimensions from love.graphics.getWidth/Height() ``` -------------------------------- ### Query Window Boundaries Source: https://context7.com/kikito/gamera/llms.txt This endpoint retrieves the screen window (viewport) dimensions, allowing you to access the width, height, left, and top coordinates. It demonstrates how to obtain the viewport and use it to draw a border around the camera viewport. ```APIDOC ## GET /api/window_boundaries ### Description Get the screen window (viewport) dimensions. ### Method GET ### Endpoint /api/window_boundaries ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Request Example { "example": "N/A" } ### Response #### Success Response (200) - **left** (number) - Left coordinate of the window - **top** (number) - Top coordinate of the window - **width** (number) - Width of the window - **height** (number) - Height of the window #### Response Example { "left": 100, "top": 50, "width": 640, "height": 480 } ``` -------------------------------- ### Mimic Camera Clamping with Bordered World in Gamera Source: https://github.com/kikito/gamera/blob/master/README.md This snippet demonstrates how to mimic camera clamping behavior by creating a larger world for the camera. By expanding the world boundaries beyond the scene, you can avoid black borders while still allowing the camera to move beyond the visible area. ```lua local cam = gamera.new(-200,-200,2200,2200) ``` ```lua local cam = gamera.new(0,0,2000,2000) ... -- the camera "clamps" when drawing cam:setWorld(-200,-200,2200,2200) ... -- Now the camera has a 200px border cam:setWorld(0,0,2000,2000) ... -- now it clamps again ``` -------------------------------- ### Require Gamera Library in LÖVE2D Source: https://github.com/kikito/gamera/blob/master/README.md This snippet shows how to include the Gamera library in your LÖVE2D project by using the `require` function. This allows you to access the camera functionality provided by the library. ```lua local gamera = require 'gamera' ``` -------------------------------- ### Drawing game objects through camera transformation in Lua Source: https://context7.com/kikito/gamera/llms.txt Demonstrates how to render game objects through the camera transformation using Gamera. Shows both named function and anonymous function approaches for drawing. The visible area parameters (left, top, width, height) help optimize rendering by only drawing what's visible. Performance may vary between named and anonymous function usage. ```lua local gamera = require 'gamera' local cam = gamera.new(0, 0, 2000, 2000) -- Example 1: Drawing with a named function local function drawWorld(l, t, w, h) -- l, t, w, h represent the visible area (left, top, width, height) -- Use these to optimize drawing - only draw what's visible love.graphics.setColor(0.2, 0.6, 0.2) love.graphics.rectangle('fill', 0, 0, 2000, 2000) -- Background -- Draw tiles only if they're in the visible area for x = math.floor(l/32), math.ceil((l+w)/32) do for y = math.floor(t/32), math.ceil((t+h)/32) do if tiles[x] and tiles[x][y] then love.graphics.draw(tiles[x][y], x*32, y*32) end end end -- Draw entities for _, entity in ipairs(entities) do if entity.x >= l and entity.x <= l+w and entity.y >= t and entity.y <= t+h then entity:draw() end end end function love.draw() cam:draw(drawWorld) -- Draw UI elements outside camera (not affected by camera transformation) love.graphics.print("Score: " .. score, 10, 10) end -- Example 2: Anonymous function (may have performance impact in extreme cases) cam:draw(function(l, t, w, h) love.graphics.circle('fill', 100, 100, 50) love.graphics.rectangle('fill', 200, 200, 100, 100) end) ``` -------------------------------- ### Fix tile seams with anim8 in Lua Source: https://context7.com/kikito/gamera/llms.txt Demonstrates using anim8 to create tile quads with borders to prevent visual seams. Requires anim8 and Gamera libraries. Input is a tileset image with borders, output is seamless tile rendering. ```lua local gamera = require 'gamera' local anim8 = require 'anim8' function love.load() love.graphics.setDefaultFilter('nearest', 'nearest') local cam = gamera.new(0, 0, 2000, 2000) -- Load tileset with 32x32 tiles that have 2px borders (so 36x36 in image) local tileset = love.graphics.newImage('tiles_with_borders.png') local w, h = tileset:getDimensions() -- Create grid with border parameter -- Parameters: tileWidth, tileHeight, imageWidth, imageHeight, left, top, border local grid = anim8.newGrid(32, 32, w, h, 0, 0, 2) -- Get quads for individual tiles local grassQuad = grid(1, 1)[1] -- First column, first row local dirtQuad = grid(2, 1)[1] -- Second column, first row local stoneQuad = grid(3, 1)[1] -- Third column, first row -- Draw tiles in game cam:draw(function(l, t, w, h) for x = 0, 62 do for y = 0, 62 do love.graphics.draw(tileset, grassQuad, x * 32, y * 32) end end }) end ``` -------------------------------- ### Configure Gamera World and Window Source: https://context7.com/kikito/gamera/llms.txt Allows updating the camera's world boundaries and setting a custom viewport (window) on the screen. This is useful for defining the total game area and restricting rendering to a specific screen region, such as for split-screen effects. ```lua local gamera = require 'gamera' local cam = gamera.new(0, 0, 2000, 2000) -- Update world boundaries after creation cam:setWorld(0, 0, 3000, 3000) -- Set a custom window (viewport) on the screen -- This restricts rendering to a specific area: left=100, top=50, width=640, height=480 cam:setWindow(100, 50, 640, 480) -- Example: Create a split-screen effect with two cameras local cam1 = gamera.new(0, 0, 2000, 2000) cam1:setWindow(0, 0, 400, 600) -- Left half local cam2 = gamera.new(0, 0, 2000, 2000) cam2:setWindow(400, 0, 400, 600) -- Right half ``` -------------------------------- ### Transform screen to world coordinates Source: https://github.com/kikito/gamera/blob/master/README.md Convert screen coordinates to world coordinates, accounting for window position, scale, rotation, and translation. Useful for implementing mouse interaction and UI elements that need to correspond to world positions. ```lua cam:toWorld(x,y) -- transforms screen coordinates into world coordinates ``` -------------------------------- ### Query Camera Window Boundaries (Lua) Source: https://context7.com/kikito/gamera/llms.txt Retrieves the screen window (viewport) dimensions set for the camera. This provides information about the visible portion of the screen. It uses the Gamera library to create and configure a camera, and then queries its window boundaries. ```Lua local gamera = require 'gamera' local cam = gamera.new(0, 0, 2000, 2000) cam:setWindow(100, 50, 640, 480) local left, top, width, height = cam:getWindow() print(string.format("Window: left=%d, top=%d, width=%d, height=%d", left, top, width, height)) ``` -------------------------------- ### Query camera world boundaries Source: https://github.com/kikito/gamera/blob/master/README.md Retrieve the current world boundaries of the camera. Returns the left, top, width, and height values that define the camera's world space. Useful for understanding the camera's operational limits. ```lua cam:getWorld() -- returns the l,t,w,h of the world ``` -------------------------------- ### Fix Blurry Graphics Source: https://context7.com/kikito/gamera/llms.txt This endpoint explains how to configure the LÖVE filter mode to prevent blur during transformations. It shows how to set the default filter globally and how to set it on a per-image basis. ```APIDOC ## POST /api/fix_blurry_graphics ### Description Configure LÖVE filter mode to prevent blur during transformations. ### Method POST ### Endpoint /api/fix_blurry_graphics ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Request Example { "example": "N/A" } ### Response #### Success Response (200) - None #### Response Example { "message": "Filter mode set to 'nearest'" } ``` -------------------------------- ### Transform world to screen coordinates Source: https://github.com/kikito/gamera/blob/master/README.md Convert world coordinates to screen coordinates, considering camera transformations. Useful for displaying world elements like minimap icons or UI overlays that need to reflect world positions on screen. ```lua cam:toScreen(x,y) -- transforms given a coordinate in the world, return the real coords it has on the screen ``` -------------------------------- ### Query camera position Source: https://github.com/kikito/gamera/blob/master/README.md Retrieve the current coordinates the camera is focused on. The returned values are corrected to prevent showing world boundaries when possible. This represents the camera's actual viewing position. ```lua cam:getPosition() -- returns the coordinates the camera is currently "looking at" ``` -------------------------------- ### Set camera window boundaries Source: https://github.com/kikito/gamera/blob/master/README.md Restrict the camera display area to a specific portion of the screen. By default, Gamera uses the whole screen, but this method allows defining a custom window area using left, top, width, and height parameters. ```lua cam:setWindow(0,0,800,600) ``` -------------------------------- ### Update camera world boundaries Source: https://github.com/kikito/gamera/blob/master/README.md Modify the world boundaries of an existing camera instance. This method allows dynamic adjustment of the camera's world limits after initialization. Takes left, top, width, and height parameters. ```lua cam:setWorld(0,0,2000,2000) ``` -------------------------------- ### Query Visible Area (Lua) Source: https://context7.com/kikito/gamera/llms.txt Determines the axis-aligned bounding box of the currently visible world area from the camera's perspective. This is useful for optimization, specifically culling entities that are not within the visible area. Relies on the Gamera library for camera creation and manipulation. ```Lua local gamera = require 'gamera' local cam = gamera.new(0, 0, 2000, 2000) cam:setPosition(500, 500) cam:setScale(2.0) local left, top, width, height = cam:getVisible() print(string.format("Visible area: l=%.2f, t=%.2f, w=%.2f, h=%.2f", left, top, width, height)) ``` -------------------------------- ### Draw camera-affected content Source: https://github.com/kikito/gamera/blob/master/README.md Render graphics that should be affected by camera transformations (scaling, rotation, translation). Takes a function parameter that receives the visible area coordinates (left, top, width, height) for drawing optimizations. ```lua local function drawCameraStuff(l,t,w,h) -- draw stuff that will be affected by the camera, for example: drawBackground(l,t,w,h) drawTiles(l,t,w,h) drawEntities(l,t,w,h) end ... -- pass your custom function to cam:draw when you want to draw stuff cam:draw(drawCameraStuff) ``` -------------------------------- ### Query Visible Corners Source: https://context7.com/kikito/gamera/llms.txt This endpoint retrieves the exact corners of the rotated visible rectangle. The corners are useful for advanced collision detection and drawing the exact visible area boundary. ```APIDOC ## GET /api/visible_corners ### Description Get the exact corners of the rotated visible rectangle. ### Method GET ### Endpoint /api/visible_corners ### Parameters #### Path Parameters - None #### Query Parameters - None #### Request Body - None ### Request Example { "example": "N/A" } ### Response #### Success Response (200) - **x1** (number) - X coordinate of corner 1 - **y1** (number) - Y coordinate of corner 1 - **x2** (number) - X coordinate of corner 2 - **y2** (number) - Y coordinate of corner 2 - **x3** (number) - X coordinate of corner 3 - **y3** (number) - Y coordinate of corner 3 - **x4** (number) - X coordinate of corner 4 - **y4** (number) - Y coordinate of corner 4 #### Response Example { "x1": 414.21, "y1": 414.21, "x2": 1585.79, "y2": 414.21, "x3": 1585.79, "y3": 1585.79, "x4": 414.21, "y4": 1585.79 } ``` -------------------------------- ### Set camera position Source: https://github.com/kikito/gamera/blob/master/README.md Move the camera to a specific location within the world boundaries. The method automatically respects window and world boundaries, preventing scrolling beyond world limits. Takes x and y coordinates as parameters. ```lua cam:setPosition(100, 200) ``` -------------------------------- ### Query visible camera area Source: https://github.com/kikito/gamera/blob/master/README.md Obtain the world area currently visible through the camera, accounting for rotation, scale, and translation. Returns left, top, width, and height values that match the parameters passed to the draw callback function. ```lua cam:getVisible() -- returns the l,t,w,h of what is currently visible in the world ``` -------------------------------- ### Draw with anonymous function Source: https://github.com/kikito/gamera/blob/master/README.md Alternative method for rendering camera-affected content using an anonymous function. This approach may have performance implications in extreme cases compared to using named functions. The function receives visible area parameters. ```lua cam:draw(function(l,t,w,h) -- draw camera stuff here end) ``` -------------------------------- ### Disable Camera Clamping (Lua) Source: https://context7.com/kikito/gamera/llms.txt Allows the camera to show world boundaries by expanding the world, effectively removing the clamping behavior. This provides the ability to view areas outside the initial world boundaries and is demonstrated dynamically via toggling the world boundaries. ```Lua local gamera = require 'gamera' -- Option 1: Create camera with border from the start local cam = gamera.new(-200, -200, 2400, 2400) -- Now the "real" world is 0,0,2000,2000 but camera can show 200px of black border -- Option 2: Toggle clamping dynamically local cam = gamera.new(0, 0, 2000, 2000) cam:setPosition(1000, 1000) -- Enable "free" camera (can see borders) function enableFreeCam() cam:setWorld(-200, -200, 2400, 2400) end -- Disable "free" camera (clamps to world) function disableFreeCam() cam:setWorld(0, 0, 2000, 2000) end -- Example: Zoom-based clamping function love.update(dt) local scale = cam:getScale() if scale < 0.8 then -- When zoomed out, allow seeing borders cam:setWorld(-300, -300, 2600, 2600) else -- When zoomed in, clamp to world cam:setWorld(0, 0, 2000, 2000) end end ``` -------------------------------- ### Control Gamera Camera Position Source: https://context7.com/kikito/gamera/llms.txt Sets the camera's view to focus on specific world coordinates. The library automatically clamps the position to ensure it stays within the defined world boundaries, preventing the display of areas outside the game world. ```lua local gamera = require 'gamera' local cam = gamera.new(0, 0, 2000, 2000) -- Set camera to look at position (500, 600) cam:setPosition(500, 600) -- Example: Follow a player character function love.update(dt) local playerX, playerY = player:getPosition() cam:setPosition(playerX, playerY) end -- The camera automatically clamps to world boundaries cam:setPosition(-100, -100) -- Will clamp to keep world visible local x, y = cam:getPosition() -- x, y will be clamped values, not -100, -100 ``` -------------------------------- ### Disable Image Blurring in LÖVE2D Source: https://github.com/kikito/gamera/blob/master/README.md This snippet demonstrates how to disable the default image blurring filter in LÖVE2D to achieve sharper images. It involves setting the default filter to 'nearest' globally or for individual images. This is useful for pixel-art games where blurring is undesirable. ```lua love.graphics.setDefaultFilter( 'nearest', 'nearest' ) ``` ```lua local img = love.graphics.newImage('imgs/player.png') img:setFilter('nearest', 'nearest') ``` -------------------------------- ### Query Visible Corners (Lua) Source: https://context7.com/kikito/gamera/llms.txt Obtains the exact corners of the rotated visible rectangle. This is essential for advanced collision detection and drawing operations that require precise boundary information. Utilizes the Gamera library to position and rotate the camera. ```Lua local gamera = require 'gamera' local cam = gamera.new(0, 0, 2000, 2000) cam:setPosition(500, 500) cam:setAngle(math.pi / 4) -- 45 degree rotation local x1, y1, x2, y2, x3, y3, x4, y4 = cam:getVisibleCorners() print(string.format("Corner 1: (%.2f, %.2f)", x1, y1)) print(string.format("Corner 2: (%.2f, %.2f)", x2, y2)) print(string.format("Corner 3: (%.2f, %.2f)", x3, y3)) print(string.format("Corner 4: (%.2f, %.2f)", x4, y4)) ``` -------------------------------- ### Prevent Tile Seams with Borders in Gamera Source: https://github.com/kikito/gamera/blob/master/README.md This snippet explains how to prevent tile seams by adding a border around each tile quad. By filling the borders with the tile's color, the seams become less noticeable. This approach utilizes anim8 for managing quad coordinates and borders. ```lua local anim8 = require 'anim8' ... local tiles = love.graphics.newImage('tiles.png') local w,h = tiles:getDimensions() local g = anim8.newGrid(32, 32, w, h, 0, 0, 2) -- tileWidth, tileHeight, imageW, imageH, left, top, border local earth = g(1,1)[1] -- Get the first column, first row 32x32 quad, including border local water = g(2,1)[1] -- Get the second column, first row quad ``` -------------------------------- ### Fix Blurry Graphics (Lua) Source: https://context7.com/kikito/gamera/llms.txt Configures the LÖVE filter mode to prevent blur during transformations, especially zooming and rotation. Setting the default filter to 'nearest' ensures pixel-perfect rendering. This avoids the blurring that can occur when using the default 'linear' filter. ```Lua -- Set at the start of love.load() before loading any images function love.load() -- Global setting for all new images love.graphics.setDefaultFilter('nearest', 'nearest') -- Now load images local gamera = require 'gamera' local cam = gamera.new(0, 0, 2000, 2000) local playerImage = love.graphics.newImage('player.png') local tileImage = love.graphics.newImage('tiles.png') -- These will use 'nearest' filter, preventing blur during zoom/rotation end -- Alternative: Set filter per image function love.load() local playerImage = love.graphics.newImage('player.png') playerImage:setFilter('nearest', 'nearest') local backgroundImage = love.graphics.newImage('background.png') -- This one might stay blurry (default 'linear' filter) local gamera = require 'gamera' cam = gamera.new(0, 0, 2000, 2000) end ``` -------------------------------- ### Adjust Gamera Camera Zoom Source: https://context7.com/kikito/gamera/llms.txt Modifies the camera's zoom level using a scale factor. A scale greater than 1 zooms in, while a scale less than 1 zooms out. This function also demonstrates how to retrieve the current zoom level and implement dynamic zooming based on user input. ```lua local gamera = require 'gamera' local cam = gamera.new(0, 0, 2000, 2000) -- Set scale to 2.0 (200% zoom - everything appears twice as large) cam:setScale(2.0) -- Set scale to 0.5 (50% zoom - see more of the world) cam:setScale(0.5) -- Example: Dynamic zoom based on mouse wheel local currentScale = 1.0 function love.wheelmoved(x, y) if y > 0 then currentScale = currentScale * 1.1 -- Zoom in elseif y < 0 then currentScale = currentScale / 1.1 -- Zoom out end cam:setScale(currentScale) end -- Get current scale local scale = cam:getScale() print("Current zoom level: " .. scale) ``` -------------------------------- ### Set camera zoom scale Source: https://github.com/kikito/gamera/blob/master/README.md Adjust the camera zoom level using a scale factor that affects both width and height. The default scale is 1.0 (no change). Gamera prevents zooming out beyond world edges, requiring expanded world boundaries for border visibility. ```lua cam:setScale(2.0) -- make everything twice as bigger. By default, scale is 1 (no change) ``` -------------------------------- ### Set camera rotation angle Source: https://github.com/kikito/gamera/blob/master/README.md Rotate the camera view by a specified angle in radians. This method adjusts both scale and position to prevent showing world borders. For unrestricted rotation, expand the world boundaries beforehand. ```lua cam:setAngle(newAngle) -- newAngle is in radians, by default the angle is 0 ``` -------------------------------- ### Query camera angle Source: https://github.com/kikito/gamera/blob/master/README.md Retrieve the current rotation angle of the camera in radians. This value determines the rotational transformation applied to the camera view. The default angle is 0 radians (no rotation). ```lua cam:getAngle() -- returns the current rotation angle, in radians ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.