display atlas
This commit is contained in:
		
							parent
							
								
									f92e88b554
								
							
						
					
					
						commit
						e75cc60376
					
				
					 8 changed files with 7 additions and 30 deletions
				
			
		
							
								
								
									
										2
									
								
								justfile
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								justfile
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -2,7 +2,7 @@ bin := "Rush.pdx"
 | 
			
		|||
 | 
			
		||||
alias b := build
 | 
			
		||||
build:
 | 
			
		||||
    pdc src {{ bin }}
 | 
			
		||||
    pdc --quiet --skip-unknown src {{ bin }}
 | 
			
		||||
 | 
			
		||||
alias s := simu
 | 
			
		||||
simu: build
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										
											BIN
										
									
								
								src/img/bg_atlas-table-32-32.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								src/img/bg_atlas-table-32-32.png
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 190 B  | 
							
								
								
									
										
											BIN
										
									
								
								src/img/bg_atlas.pxo
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								src/img/bg_atlas.pxo
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 5.2 KiB After Width: | Height: | Size: 1.1 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								src/img/player.pxo
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								src/img/player.pxo
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 Before Width: | Height: | Size: 133 B  | 
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										35
									
								
								src/main.lua
									
										
									
									
									
								
							
							
						
						
									
										35
									
								
								src/main.lua
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -6,48 +6,24 @@ import "CoreLibs/timer"
 | 
			
		|||
local gfx <const> = playdate.graphics
 | 
			
		||||
 | 
			
		||||
local playerSprite = nil
 | 
			
		||||
local atlas = nil
 | 
			
		||||
 | 
			
		||||
function myGameSetUp()
 | 
			
		||||
  local playerImage = gfx.image.new("img/player.png")
 | 
			
		||||
function gameInit()
 | 
			
		||||
  local playerImage = gfx.image.new("img/player")
 | 
			
		||||
  assert(playerImage)
 | 
			
		||||
 | 
			
		||||
  playerSprite = gfx.sprite.new(playerImage)
 | 
			
		||||
  playerSprite:moveTo(200, 120) -- (200,120) is the center of the Playdate screen
 | 
			
		||||
  playerSprite:add()
 | 
			
		||||
 | 
			
		||||
  -- We want an environment displayed behind our sprite.
 | 
			
		||||
  -- There are generally two ways to do this:
 | 
			
		||||
  -- 1) Use setBackgroundDrawingCallback() to draw a background image. (This is what we're doing below.)
 | 
			
		||||
  -- 2) Use a tilemap, assign it to a sprite with sprite:setTilemap(tilemap),
 | 
			
		||||
  --       and call :setZIndex() with some low number so the background stays behind
 | 
			
		||||
  --       your other sprites.
 | 
			
		||||
 | 
			
		||||
  -- local backgroundImage = gfx.image.new("Images/background")
 | 
			
		||||
  -- assert(backgroundImage)
 | 
			
		||||
 | 
			
		||||
  -- gfx.sprite.setBackgroundDrawingCallback(
 | 
			
		||||
  --   function(x, y, width, height)
 | 
			
		||||
  --     -- x,y,width,height is the updated area in sprite-local coordinates
 | 
			
		||||
  --     -- The clip rect is already set to this area, so we don't need to set it ourselves
 | 
			
		||||
  --     backgroundImage:draw(0, 0)
 | 
			
		||||
  --   end
 | 
			
		||||
  -- )
 | 
			
		||||
 | 
			
		||||
  local table = gfx.imagetable.new("img/tilemap-table-16-16.png")
 | 
			
		||||
  local map = gfx.tilemap.new()
 | 
			
		||||
  map:setImageTable(table)
 | 
			
		||||
  map:draw(0, 0)
 | 
			
		||||
  atlas = gfx.imagetable.new("img/bg_atlas")
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- Now we'll call the function above to configure our game.
 | 
			
		||||
-- After this runs (it just runs once), nearly everything will be
 | 
			
		||||
-- controlled by the OS calling `playdate.update()` 30 times a second.
 | 
			
		||||
 | 
			
		||||
myGameSetUp()
 | 
			
		||||
 | 
			
		||||
-- `playdate.update()` is the heart of every Playdate game.
 | 
			
		||||
-- This function is called right before every frame is drawn onscreen.
 | 
			
		||||
-- Use this function to poll input, run game logic, and move sprites.
 | 
			
		||||
gameInit()
 | 
			
		||||
 | 
			
		||||
function playdate.update()
 | 
			
		||||
  -- Poll the d-pad and move our player accordingly.
 | 
			
		||||
| 
						 | 
				
			
			@ -74,4 +50,5 @@ function playdate.update()
 | 
			
		|||
 | 
			
		||||
  gfx.sprite.update()
 | 
			
		||||
  playdate.timer.updateTimers()
 | 
			
		||||
  atlas:drawImage(1, 32, 32)
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue