Advertisement
CuppyBoi

Temple Tombs Code

Jan 9th, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.66 KB | None | 0 0
  1. --temple tombs
  2. --by cupps
  3.  
  4. --to do list:
  5. --box pushing
  6.  
  7.  
  8. titlescreen=true
  9.  
  10. --player spawn
  11. function _init()
  12.  curlevel={
  13.  x = 0,
  14.  y = 0,
  15.  }
  16.     bud={
  17.  x=24,
  18.  y=64,
  19.  }
  20. end
  21.  
  22. --title screen stuff
  23. function title_screen()
  24.     _update=title_update
  25.  _draw=title_draw
  26. end
  27.  
  28. function mgetcurlev(x,y)
  29.  return mget(x+curlevel.x,
  30.              y+curlevel.y)
  31. end
  32.  
  33. function msetcurlev(x,y)
  34.  mset(x+curlevel.x,y+curlevel.y)
  35. end
  36.  
  37. --flag functions
  38. function flag(x,y)
  39.  local tilex=((x-(x%8))/8)
  40.  local tiley=((y-(y%8))/8)
  41.   if (mgetcurlev(tilex,tiley) == (1))then
  42.    if bud.direction == false then
  43.     curlevel.x+=16
  44.    if curlevel.x == 16 and curlevel.y == 0 then
  45.     bud.x=24
  46.     bud.y=96
  47.    end
  48.    if curlevel.x == 32 and curlevel.y == 0 then
  49.     bud.x=16
  50.     bud.y=104
  51.    end
  52.    if curlevel.x == 48 and curlevel.y == 0 then
  53.     bud.x=16
  54.     bud.y=48
  55.    end
  56.    if curlevel.x == 64 and curlevel.y == 0 then
  57.     bud.x=24
  58.     bud.y=24
  59.    end
  60.   end
  61.  end
  62. end
  63.  
  64. --coin functions
  65. function coin(x,y)
  66.  local tilex=((x-(x%8))/8)
  67.  local tiley=((y-(y%8))/8)
  68.  if (mgetcurlev(tilex,tiley) == (2))then
  69.   msetcurlev(tilex,tiley,0)
  70.   sfx(1)
  71.  end
  72. end
  73.  
  74. --wall functions
  75. function solid(x,y)
  76.  local tilex = ((x - (x % 8)) / 8)
  77.  local tiley = ((y - (y % 8)) / 8)
  78.  if (fget(mgetcurlev(tilex,tiley),0))then
  79.  return true
  80.   else
  81.  return false
  82.  end
  83. end
  84.  
  85. function _update()
  86. --title screen acrivation
  87.  if titlescreen == true then
  88.   if btn(2) then
  89.    titlescreen = false
  90.   end
  91.  else
  92.   if not bud.direction then
  93.     if (btnp(0)) bud.direction = "left" bud.sprite=15
  94.    if (btnp(1)) bud.direction = "right" bud.sprite=13
  95.    if (btnp(2)) bud.direction = "up" bud.sprite=14
  96.    if (btnp(3)) bud.direction = "down" bud.sprite=12
  97.     end
  98.     --movement
  99.   if bud.direction=="left" then
  100.     if(solid(bud.x-1,bud.y) == false) then
  101.      bud.x-=4
  102.     else
  103.      bud.direction = false
  104.     end
  105.    end
  106.   coin(bud.x,bud.y)
  107.   flag(bud.x,bud.y)
  108.   if bud.direction=="right" then
  109.    if(solid(bud.x+8,bud.y) == false) then
  110.     bud.x+=4
  111.    else
  112.     bud.direction = false
  113.    end
  114.   end
  115.   if bud.direction=="up" then
  116.    if(solid(bud.x,bud.y-1) == false) then
  117.     bud.y-=4
  118.    else
  119.     bud.direction = false
  120.    end
  121.   end
  122.   if bud.direction=="down" then
  123.    if(solid(bud.x,bud.y+8) == false) then
  124.     bud.y+=4
  125.    else
  126.     bud.direction = false
  127.    end
  128.   end
  129.  end
  130. end
  131.  
  132. function _draw()
  133. --titlescreen creating
  134.  if titlescreen == true then
  135.   cls()
  136.   map (112,48)
  137.   print("created by cupps",34,70,2)
  138.   print("press ⬆️ to start",32,96,7)
  139.  else
  140.   cls()
  141. --coordinate debug info
  142. --level 1 spawn
  143.   map(curlevel.x, curlevel.y)
  144.     spr(bud.sprite or 12,bud.x,bud.y)
  145.  end
  146. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement