Advertisement
Guest User

mapscreen.lua

a guest
Feb 28th, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.97 KB | None | 0 0
  1. local map = {}
  2.  
  3. SaveData[Level.filename()] = SaveData[Level.filename] or {}
  4. local LevelData = SaveData[Level.filename()]
  5. LevelData.mapVisibility = LevelData.mapVisibility or {}
  6. local mapBackground = Graphics.loadImage(Misc.resolveFile("MapBackground.png"))
  7.  
  8. local mapRooms = {}
  9. function map.setData(mapData)
  10.     mapRooms = mapData
  11. end
  12.  
  13. map.viewMap = false
  14.  
  15. function map.Update()
  16.     for k,v in ipairs(mapRooms) do
  17.         if not LevelData.mapVisibility[k] and v.hitbox:collide(player) then
  18.             LevelData.mapVisibility[k] = true
  19.         end
  20.     end
  21. end
  22.  
  23. function map.Draw()
  24.     if map.viewMap then
  25.         Misc.pause()
  26.         Graphics.drawImageWP(mapBackground,0,0,3.1)
  27.         for k,v in ipairs(mapRooms) do
  28.             if LevelData.mapVisibility[k] then
  29.                 Graphics.drawImageWP(v.image, v.position.x, v.position.y, 3.2)
  30.             end
  31.         end
  32.         if player.keys.run then
  33.             Misc.unpause()
  34.             map.viewMap = false
  35.         end
  36.     end
  37. end
  38.  
  39. return map
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement