Code_maker

2D minecraft - CODEA

Apr 21st, 2015
323
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. --# Main
  3. -- 2D minecraft
  4. p = vec2(400, 185)
  5. sun = vec2()
  6. pi = false
  7. cloud = vec2(math.random(100.50,800.50),700)
  8.  
  9. --MOB COORDS--
  10. zombie = vec2(math.random(100, 700), 185)
  11. ZOM = {}
  12. zomPic = "Documents:Zombie" --IMG LINK: http://i.imgur.com/UtQnc.png
  13. --NAME THE IMAGE Zombie
  14.  
  15. --PASSIVE MOB COORDS--
  16. pig = vec2(math.random(100, 700), 185)
  17. PIG = {}
  18. pigPic = "Documents:Pig" --IMG LINK: http://towardsmecca.com/wp-content/uploads/2010/10/minecraft_pig.jpg
  19. --NAME THE IMAGE Pig
  20.  
  21.  
  22.  
  23. --http://www.minecraftopia.com/images/blocks/redstone_dust.png
  24. --NAME THAT IMAGE redstone
  25. --Features:
  26. --[[
  27. Sun
  28. cloud
  29. steve
  30. controls
  31. day and night cycle
  32. smaller D-PAD
  33. better Steve skin
  34. borders at the edge of the blocks(it sends you back to the middle)
  35. bigger worlds(still working on code for the camera to move with you :) )
  36. survival mode
  37. lives
  38. sounds when you go off the edge
  39. deaths
  40. 5% speed
  41. hotbar(still needs a little work though, this means mining coming soon!)
  42. NameTags
  43. pause menu(A little work still on it to pause.)
  44. name tag color
  45. sprinting
  46. tint packs(tints everything 1 color)
  47. apple(the red circle and it restores your lives back to 10 and in a later update when you touch it and eat it, it will be removed)
  48. crafting()
  49. neather(pretty simple... you can add more if you want to...)
  50. apple pickup sounds
  51. blocks
  52. building
  53. cursor at touch
  54. XP(gives you 3 more lava for the moment..,)
  55. bioms(plains and mesa wich are both flat for now, im hoping in 0.6.2 i will add roofed forest bioms and possiblys swamps or jungles)
  56. trees(they will be minable in a future update, this means more blocks coming soon!)
  57. start screen
  58. survival mode option
  59. creative mode option
  60. creative mode flying
  61. ores(coal,iron,gold,diamond,redstone,emerald)
  62. picks(iron,gold,diamond,emerald)
  63. moving clouds
  64. now, you can close the command bar.
  65. commands
  66. pig
  67. zombie
  68. redstone
  69. piston
  70. ]]--
  71.  
  72. --Blocks:
  73. --[[
  74. grass
  75. obsidian
  76. neather back
  77. neatherrack
  78. orange stained clay(uncraftible but can be found in the mesa biom)
  79. ]]--
  80.  
  81. --Items:
  82. --[[
  83. lava
  84. water
  85. neather igniter
  86. water
  87. seeds
  88. coal
  89. iron
  90. diamond
  91. gold
  92. emerald
  93. redstone(mineble but no use yet...)
  94. in game recorder
  95. ]]--
  96.  
  97. --Experamrntal
  98. --[[
  99. more blocks
  100. agressive mobs
  101. passive mobs
  102. ]]--
  103.  
  104. --tools:
  105. --[[
  106. hoe
  107. picks
  108. ]]--
  109.  
  110. --Update thoughts:
  111. --[[
  112. mining
  113. ather
  114. better animations
  115. TNT
  116. fire
  117. flint and steel
  118. stars
  119. moon
  120. more foods
  121. mannualy building
  122. random terrain structures
  123. player y 0 and below
  124. speaking (with text)
  125. ]]--
  126.  
  127. --Bug fixes:
  128. --[[
  129.  
  130. ]]--
  131.  
  132. --New features:
  133. --[[
  134. zombie at night
  135. pig all the time.
  136. redstone
  137. pistons
  138. commands
  139. changed the creator's name to mine because i dont have a company
  140. switched the version to Beta in the start screen
  141. ]]--
  142.  
  143. --Inspired by:
  144. --©Mojang™
  145.  
  146. --This program built by:
  147. --Marco V.
  148.  
  149. --Credit:
  150. --©Mojang AB™
  151.  
  152. --Full credit:
  153. --Markus Alexej Persson (thotherwise known as Notch)
  154.  
  155. function setup()
  156.    
  157.   displayMode(FULLSCREEN)
  158. parameter.text("Username", "Steve") --CHANGE IF YOU WANT TO HAVE A DIFFERENT USERNAME!
  159. parameter.color("NameTagColor", 255)
  160. parameter.boolean("BlueTintPack", false)
  161. parameter.boolean("GetFPS", false)
  162. print("Please parten all the bugs there might be. This game is still in Alpha.")
  163. Version = "0.8.0"
  164. reco = false
  165. paused=false
  166. bioms = {1, 2}
  167. terrainGeneration = bioms[math.random(1,2)]
  168. next = 0
  169. crafting = false
  170. bulding = false
  171. netherActive = false
  172. neather = false
  173. inven = false
  174.  
  175.     rsw = math.random(100, 300)
  176.     rsh = math.random(50, 100)
  177.    
  178.     lava = 3
  179.     obsidian = 0
  180.     neatherIgniters = 1
  181.     water = 1
  182.     neatherBack = 0
  183.     seeds = 1
  184.     hoeWood = 1
  185.     pistons = readLocalData("pistons", 0)
  186.     redstone = readLocalData("redstone", 30)
  187.     RedTorch = readLocalData("RedTorch", 3)
  188.     XP = 0.0
  189. lvl = readLocalData("pLvl", 0)
  190.     appleSpawn = 0
  191.     gold = {}
  192.     iron = {}
  193.     diamond = {}
  194.     coal = {}
  195.     emerald = {}
  196.    
  197.  
  198.     table.insert(iron, 1)
  199.     table.insert(PIG, 1)
  200.    
  201.     --Thankfully the resources in 1 world are limited. if not, you would fill up the local storage quick and crash your game! no more local storage saves, now we do the project ;)
  202.     co = readLocalData("COA",0)
  203.     go = readLocalData("GOL",0)
  204.     ir = readLocalData("IRO",0)
  205.     di = readLocalData("DIA",0)
  206.     em = readLocalData("EME",0)
  207.     re = readLocalData("RED",0)
  208.    
  209.  
  210. lives = readLocalData("lives", 10)
  211.     supportedOrientations(LANDSCAPE_ANY)
  212.     ores = 1,2,3,4,5
  213.     ore_names = "coal","iron","gold","diamond","emerald","redstone"
  214.     hand = 0
  215.     wood_pick = 0
  216.     stone_pick = 1
  217.     iron_pick = 2
  218.     gold_pick = 3
  219.     diamond_pick = 4
  220.     emerald_pick = 5
  221.     tool = hand
  222. STM = 700
  223. --Mining varables
  224.     if tool == wood_pick then
  225.         SMT = 450
  226.         elseif tool == stone_pick then
  227.         SMT = 400
  228.         elseif tool == iron_pick then
  229.         STM = 330
  230.         elseif tool == gold_pick then
  231.         STM = 160
  232.         elseif tool == diamond_pick then
  233.         STM = 180
  234.         elseif tool == emerald_pick then
  235.         STM = 50
  236.     end
  237. c = false
  238.  
  239. tre = vec2(math.random(300,600), 0)
  240.  
  241. mobs = {1,2}
  242. if neather == true then
  243. mtype = mobs[2]
  244. end
  245. chatCmds = false
  246. chatCmdsSurv = false
  247. fireball = 0
  248. end
  249.  
  250. function draw()
  251.     background(0, 0, 0, 255)
  252. saveLocalData("pistons", pistons)
  253. saveLocalData("IRO",ir)
  254. saveLocalData("GOL",go)
  255. saveLocalData("RED",re)
  256. saveLocalData("DIA",di)
  257. saveLocalData("COA",co)
  258. saveLocalData("EME",em)
  259. saveLocalData("redstone", redstone)
  260. saveLocalData("RecTorch", RedTorch)
  261.  
  262.  Start:draw()
  263.    
  264. end
  265. function touched(t)
  266.    
  267.        if t.x >949 and t.x <1004 and t.y >494 and t.y <504 then
  268.         p.x = p.x + 5
  269.      
  270.         end
  271.         if t.x >0 and t.x <23 and t.y >494 and t.y <504 then
  272.             p.x = p.x - 5
  273.            
  274.         end
  275.     --Sprint Left
  276.     if t.x >0 and t.x <23 and t.y >294 and t.y <304 then
  277.         p.x = p.x - 10
  278. end
  279.     --Sprint Right
  280.     if t.x >949 and t.x <1004 and t.y >294 and t.y <304 then
  281.         p.x = p.x + 10
  282.        
  283.     end
  284.    
  285.    
  286.    
  287.     --Sneak Right
  288.     if t.x >949 and t.x <1004 and t.y >394 and t.y <404 then
  289.         p.x = p.x + 1
  290.      
  291.     end
  292.     --Sneak Left
  293.     if t.x >0 and t.x <27 and t.y >394 and t.y <404 then
  294.         p.x = p.x - 1
  295.        
  296.     end
  297.     if p.x >=599 and p.x <=607 then
  298.     addHealth()
  299.    
  300. end
  301.  
  302. --Fly in creative(you may edit it for flying in survival)
  303. if cre == true then
  304. if t.x >=500 and t.x <=551 and t.y >=500 and t.y <=551 then
  305. p.y = p.y + 10
  306. end
  307. if t.x >=500 and t.x <=551 and t.y >=450 and t.y <=501 then
  308. p.y = p.y - 10
  309.     end
  310.     end
  311.    
  312. end
  313.  
  314. function craftObsidian()
  315.     obsidian = obsidian + 3
  316.     lava = 0
  317.     XP = XP + 0.6
  318. end
  319.  
  320. function craftNeatherback()
  321.     water = 0
  322.     neatherBack = 1
  323.     XP = XP + 0.6
  324. end
  325.  
  326. function XPNewLava()
  327.     sound(SOUND_POWERUP, 7443)
  328.     lava = 3
  329.     lvl = lvl + 1
  330.     table.insert(coal, 1)
  331.     XP = 0
  332. end
  333.  
  334. function addHealth()
  335.    
  336.         sound(SOUND_PICKUP, 2626)
  337.         lives = 10
  338.         XP = XP + 1
  339. end
  340.  
  341. function light()
  342. tint(255, 0, 0, 255)
  343. end
  344.  
  345. function craftPiston()
  346. ir = ir - 5
  347. redstone = redstone - 3
  348. pistons = pistons + 1
  349. end
  350.  
  351. function pstn()
  352. alert("This will be finished in the next update! Thanks for playing my game!!!", "Coming soon!")
  353. end
  354. --# Play
  355. Play = class()
  356.  
  357.  
  358. function Play:draw()  
  359.    
  360.    
  361.     background(0, 5, sun.y, 255)
  362.     saveLocalData("pLvl", lvl)
  363.    
  364.  
  365.    
  366.    
  367.     if BlueTintPack == true then
  368.         tint(0, 16, 255, 255)
  369.     else
  370.         tint(255, 255, 255, 255)
  371.     end
  372.    
  373.  
  374.     if sun.y >= 750 then
  375.     background(0, 0, 0, 255)
  376.    table.insert(ZOM, 1)
  377.     sun.y = -500
  378.     zombie.x = zombie.x + 1
  379.     if zombie.x <=80 then
  380.     zombie.x = zombie.x + 2
  381.     end
  382.     if zombie.x >=700 then
  383.       zombie.x = zombie.x - 2
  384.         end
  385.     if p.x == zombie.x then
  386.     lives = lives - 1
  387.     end
  388.     elseif sun.y >=185 then
  389.     table.remove(ZOM)
  390. end
  391.  
  392. if sun.y >=30 then
  393.     --background(119, 119, 225, 255)
  394. end
  395.     fill(255, 255, 255, 255)
  396.     text("Player Level: "..lvl,300, 700)
  397. --Cursor
  398. fill(127, 127, 127, 120)
  399. ellipse(CurrentTouch.x, CurrentTouch.y, 30)
  400.  
  401.  
  402. FPS = 1/DeltaTime
  403.  
  404.  
  405.  
  406. --FPS
  407. if GetFPS == true then
  408.     fontSize(15)
  409.         text("FPS:" ..FPS, 50, 100)
  410.    
  411. end
  412.  
  413.  
  414.      --Cloud
  415.  
  416.         fill(255, 255, 255, 65)
  417.     rect(cloud.x, cloud.y, rsw, 50)
  418.   cloud.x = cloud.x - 1
  419. if cloud.x <=0 then
  420. cloud = vec2(math.random(500,1000),700)
  421. end
  422.     for k,v in ipairs(iron) do
  423.     fill(103, 103, 103, 255)
  424.     rect(300 * k, 400, 60, 60)
  425.         fill(205, 146, 91, 255)
  426.     ellipse(330 * k, 430, 20)
  427.     end  
  428.     for k,v in ipairs(ZOM) do
  429.     sprite(zomPic, zombie.x, zombie.y, 100, 130)
  430.     end
  431.     for k,v in ipairs(PIG) do
  432.     sprite(pigPic, pig.x, pig.y)
  433.     end
  434.   if pi == true and CurrentTouch.tapCount >=3 then
  435. table.remove(iron)
  436. ir = ir + math.random(2,4)
  437. pi = false
  438. end
  439.    
  440.     fill(0, 0, 0, 255)
  441.     fontSize(20)
  442.     text("XP:", 200, 630)
  443.     --XP Bar
  444.     fill(0, 255, 0, 255)
  445.     rect(200, 600, XP, 20)
  446. pig.x = pig.x + 2
  447. if pig.x >=1000 then
  448. pig.x = 100
  449. end
  450.  
  451. if chatCmdsSurv == true then
  452.     showKeyboard()
  453.     fill(255, 255, 255, 255)
  454.     stroke(127, 127, 127, 255)
  455.     strokeWidth(5)
  456.     rect(0, 700, 1000, 100)
  457.     noStroke()
  458.     noStroke()
  459.     noStroke()
  460.     --Help keeps the game clean with 3 noStroke()
  461.     textMode(CORNER)
  462.     buf = keyboardBuffer()
  463.    
  464.     if buf then
  465.         fill(0, 0, 0, 255)
  466.     text( buf, 10, 750)
  467.     end
  468.     if buf == "/health me 10" then
  469.   lives = 10
  470.     end
  471.     if buf == "/timeset morning" then
  472.     sun.y = 0
  473.     end
  474.     if buf == "/timeset night" then
  475.     sun.y =800
  476.     end
  477.     if buf == "/timeset day" then
  478.     sun.y = HEIGHT/2
  479.     end
  480.     if buf == "/gamemode c" then
  481.     pla = false
  482.     cre = true
  483.     PlayC:draw()
  484.     end
  485.     fill(255, 0, 0, 255)
  486.     rect(600, 700, 100, 100)
  487.    
  488.     if CurrentTouch.x >= 600 and CurrentTouch.x <=700 and CurrentTouch.y >= 700 and CurrentTouch.y <=800 then
  489. hideKeyboard()
  490. chatCmdsSurv = false
  491.     end
  492. end
  493. --Grass bottom
  494. if terrainGeneration == 1 then
  495.     fill(116, 73, 31, 255)
  496. for i = 1,100 do
  497.   rect(100 * i, 0, 100, 100)
  498.     end
  499.     fill(113, 81, 31, 255)
  500.     rect(560, 125, 50, 50)
  501.     rect(560, 175.1, 50, 50)
  502.     rect(560, 225.1, 50, 50)
  503.     fill(74, 255, 0, 255)
  504.     rect(509, 225.1, 50, 50)
  505.     rect(609, 225.1, 50, 50)
  506.     rect(559, 275.1, 50, 50)
  507. elseif terrainGeneration == 2 then
  508.     fill(255, 152, 0, 255)
  509.     for i = 1,100 do
  510.         rect(100 * i, 0, 100, 100)
  511.     end
  512. end
  513.  
  514. if XP >= 100 then
  515.     XPNewLava()
  516.    
  517. end
  518.  
  519. --Username tag
  520. fill(NameTagColor)
  521. text("" ..Username, p.x , 255)
  522.  
  523.     --Steve!
  524.     sprite("Documents:Steve", p.x, 185, 100, 110)
  525.     --Head
  526.  -- fill(180, 154, 80, 255)
  527.     --rect(p.x, 250, 70, 70)
  528.     --Body
  529. --    fill(0, 0, 255, 255)
  530.  
  531. if p.x >1000 then
  532. p.x = 400
  533.  saveLocalData("lives", lives)
  534.    
  535.     for i = 1,1 do
  536.         sound(SOUND_HIT, 41660)
  537.         lives = lives - 1
  538.     end
  539. end
  540. --Text button
  541. fill(127, 127, 127, 255)
  542. rect(900, 700, 50, 50)
  543. fontSize(25)
  544. fill(255, 255, 255, 255)
  545. text("📝", 925, 725)
  546. if CurrentTouch.x >= 894 and CurrentTouch.x <=954 and CurrentTouch.y >= 694 and CurrentTouch.y <=754 then
  547. chatCmdsSurv = true
  548. end
  549.  
  550. --Build button
  551. fill(30, 0, 255, 79)
  552. rect(100, 500, 70, 70)
  553. fill(255, 255, 255, 255)
  554. text("Build", 135, 535)
  555. --Build button touch quards
  556. if CurrentTouch.x >=94 and CurrentTouch.x <=174 and CurrentTouch.y >494 and CurrentTouch.y <574 then
  557.     building = true
  558. end
  559.  
  560. if building == true then
  561.     background(111, 108, 108, 255)
  562.        fill(127, 127, 127, 105)
  563.     rect(200, 600, 100, 70)
  564.     rect(400, 600, 100, 70)
  565.     fill(255, 0, 0, 123)
  566.     rect(600, 200, 100, 100)
  567.     fill(255)
  568.     text("Exit", 650, 250)
  569. if CurrentTouch.x >594 and CurrentTouch.x <704 and CurrentTouch.y >194 and CurrentTouch.y <304 then
  570.     building = false
  571. end
  572.    if obsidian >= 3 then
  573.     fill(255)
  574.     text("Neather Portal", 250, 630)
  575.     if CurrentTouch.x >194 and CurrentTouch.x <304 and CurrentTouch.y >594 and CurrentTouch.y <674 then
  576.     obsidian = 0
  577.     neatherIgniters = 0
  578.  
  579.         neatherActive = true
  580.         building = false
  581.         end
  582.     end
  583. if pistons >=1 and RedTorch >=1 then
  584. fill(255)
  585. text("Piston Contraption", 450, 630)
  586. if CurrentTouch.x >=400 and CurrentTouch.x <=500 and CurrentTouch.x >=600 and CurrentTouch.y <=670 then
  587. pistons = pistons - 1
  588. RedTorch = RedTorch - 1
  589. pstn()
  590.         end
  591.     end
  592. end
  593.  
  594. if neatherActive == true then
  595. fill(0, 0, 0, 255)
  596. rect(95, 115, 100, 100)
  597. fill(212, 0, 255, 255)
  598. rect(95, 165, 100, 50)
  599. if p.x >=95 and p.x <=105 then
  600.     neather = true
  601.     end
  602. end
  603.  
  604. --NEATHER--
  605. --NEATHER--
  606. --NEATHER--
  607.  
  608. if neather == true then
  609.     background(230, 21, 21, 255)
  610.           sprite("Documents:Steve", p.x, 185, 100, 110)
  611.         --Neatherrack
  612.         for i = 1,10 do
  613.         fill(179, 51, 51, 255)
  614.         rect(100 * i, 0, 100, 130)
  615.         sun.y = -400
  616.         end
  617. if neatherBack >0 then
  618.     next = next + 3
  619.     if next%40==0 then
  620.         fill(230, 0, 255, 255)
  621.     end
  622.     if next%80==0 then
  623.     fill(0, 255, 255, 255)
  624. end
  625. --GHAST--
  626.     rect(700, 110, 100, 100)
  627.     fill(255, 255, 255, 255)
  628.     rect(400, 500, 300, 300)
  629.     fill(0, 0, 0, 255)
  630.     rect(450, 650, 50, 50)
  631.     rect(650, 650, 50, 50)
  632.     rect(550, 550, 70, 70)
  633.    
  634.    
  635.     if p.x >694 and p.x <804 then
  636.         neather = false
  637.         end
  638.     end
  639. end
  640.  
  641. if p.x <100 then
  642.     p.x = 400
  643.    
  644.         sound(SOUND_HIT, 41660)
  645.         lives = lives - 1
  646. end
  647. fill(127, 127, 127, 90)
  648. rect(300, 300, 70, 70)
  649. fill(255, 255, 255, 255)
  650. text("Craft", 330, 330)
  651.  
  652.  
  653. if CurrentTouch.x >294 and CurrentTouch.x <374 and CurrentTouch.y >294 and CurrentTouch.y <374 then
  654.     crafting = true
  655. end
  656.  
  657. if crafting == true then
  658.       background(123, 104, 30, 255)
  659.      fill(255, 0, 0, 123)
  660.     rect(600, 200, 100, 100)
  661.     fill(255)
  662.     text("Exit", 650, 250)
  663. if CurrentTouch.x >594 and CurrentTouch.x <704 and CurrentTouch.y >194 and CurrentTouch.y <304 then
  664.     crafting = false
  665. end
  666.     if lava >= 3 then
  667.         fill(0, 0, 0, 255)
  668.         rect(500, 500, 100, 100)
  669.         fill(255, 255, 255, 255)
  670.         text("OBSIDIAN", 500, 400)
  671.         fill(127, 127, 127, 102)
  672.         rect(600, 400, 70, 70)
  673.         fill(255, 255, 255, 255)
  674.         text("CraftObsidian", 630, 430)
  675.        
  676.        
  677.        if CurrentTouch.x >594 and CurrentTouch.x <674 and CurrentTouch.y >394 and CurrentTouch.y <474 then
  678.        
  679. craftObsidian()
  680. crafting = false
  681.  
  682.         end
  683.     end
  684.     if water >0 then
  685.         fill(0, 255, 255, 255)
  686.         rect(300, 500, 50, 50)
  687.         fontSize(10)
  688.         fill(255)
  689.         text("NEATHERBACK", 340, 400)
  690.         fill(127, 127, 127, 105)
  691.         rect(300, 380, 70, 70)
  692.         if CurrentTouch.x >294 and CurrentTouch.x <370 and CurrentTouch.y >374 and CurrentTouch.y <454 then
  693.             craftNeatherback()
  694.             crafting = false
  695.            
  696.         end
  697.     end
  698.         if redstone >=3 and ir >=5 then
  699.             fill(127, 127, 127, 255)
  700.             rect(400, 600, 100, 70)
  701.         fill(255, 255, 255, 255)
  702.         text("Piston", 450, 635)
  703. if CurrentTouch.x >=400 and CurrentTouch.x <=500 and CurrentTouch.y >=600 and CurrentTouch.y <=670 then
  704. craftPiston()
  705. crafting = false
  706. end
  707.     end
  708. end
  709. fontSize(20)
  710. pick = vec2(CurrentTouch.x,CurrentTouch.y)
  711. --Inventory/hotbar
  712. fill(127, 127, 127, 107)
  713. rect(700, 600, 70, 70)
  714. rect(800, 600, 70, 70)
  715. rect(900, 600, 70, 70)
  716. fontSize(30)
  717. fill(255, 255, 255, 255)
  718. text("...", 930, 630)
  719. if CurrentTouch.x >894 and CurrentTouch.x <974 and CurrentTouch.y >594 and CurrentTouch.y <674 then
  720.   inven = true
  721. end
  722.  
  723.  
  724. fill(127, 127, 127, 110)
  725.     rect(250, 500, 70, 70)
  726. fill(120, 76, 30, 255)
  727. ellipse(280, 530, 10, 40)
  728. fill(127, 127, 127, 255)
  729. rect(260, 545, 40, 15)
  730. if CurrentTouch.x >=250 and CurrentTouch.x <=320 and CurrentTouch.y >=500 and CurrentTouch.y <=570 then
  731. pi = true
  732. end
  733.  
  734. if pi == true then
  735. fill(127, 127, 127, 255)
  736. rect(CurrentTouch.x, CurrentTouch.y, 40, 15)
  737. end
  738.  
  739. if inven == true then
  740.       background(51, 51, 51, 255)
  741.     for i = 1,5 do
  742.         fill(127, 127, 127, 141)
  743.         rect(100 * i, 400, 90, 90)
  744.         if ir >=1 then
  745. fill(191, 191, 191, 255)
  746. rect(240, 440, 40, 10)
  747. text(""..ir, 220, 420)
  748. end
  749.     end
  750.  
  751. if RedTorch >=1 then
  752. fill(255, 0, 0, 255)
  753. rect(520, 420, 20, 20)
  754. fill(120, 91, 30, 255)
  755. rect(520, 400, 20, 30)
  756. end
  757.  
  758.     if seeds >=1 then
  759.         fill(57, 255, 0, 255)
  760.         rect(130, 450, 20, 20)
  761.         rect(100, 430, 20, 20)
  762.         rect(120, 430, 15, 20)
  763.     end
  764.     if redstone >=1 then
  765.     sprite("Documents:redstone", 340, 450, 50, 50)
  766.     fill(163, 155, 155, 255)
  767.     text("" ..redstone, 350, 420)
  768.     end
  769.     if pistons >=1 then
  770.     fill(109, 106, 106, 255)
  771.     rect(420, 410, 70, 70)
  772.     fill(189, 129, 18, 255)
  773.     rect(410, 410, 10, 70)
  774.     fill(174, 174, 174, 255)
  775.     text("" ..pistons, 450, 410)
  776.     end
  777.    
  778.     fill(255, 0, 0, 121)
  779.     rect(600, 200, 150, 150)
  780.     fill(255, 255, 255, 255)
  781.     text("Exit", 650, 250)
  782.     if CurrentTouch.x >594 and CurrentTouch.x <704 and CurrentTouch.y >194 and CurrentTouch.y <304 then
  783.         inven = false
  784.     end
  785. end
  786.  
  787. --player quards
  788. fontSize(20)
  789. fill(255, 255, 255, 255)
  790. text("X: " ..p.x, 400, 400)
  791. text("Y: " ..p.y, 500, 400)
  792. if neatherIgniters >0 then
  793.     fill(255, 108, 0, 255)
  794.     ellipse(820, 620, 30)
  795.     fill(255, 0, 0, 255)
  796.     rect(820, 625, 10, 10)
  797.     fill(255)
  798. text("" .. neatherIgniters, 855, 612)
  799. end
  800. if obsidian > 0 then
  801.     fill(0, 0, 0, 255)
  802.     rect(710, 610, 40, 40)
  803.     fill(255, 255, 255, 255)
  804.     fontSize(15)
  805.     text("" ..obsidian, 755, 612)
  806. end
  807.  
  808.  
  809. for i = 1,lives do
  810.     sprite("Planet Cute:Heart", 70 * i, 600, 50, 50)
  811. end
  812.  
  813. --Sun
  814. fill(243, 255, 0, 193)
  815. rect(600, 0 + sun.y, 300, 300)
  816.  
  817. sun.y = sun.y + 0.3
  818.  
  819. appleSpawn = appleSpawn + 1
  820. if appleSpawn >=500 then
  821.     fill(255, 0, 0, 255)
  822.     ellipse(600, 150, 40)
  823. end
  824.  
  825.     --Grass top
  826.    
  827. if terrainGeneration == 1 then
  828.     fill(0, 255, 0, 255)
  829.     rect(100, 100, 1000, 30)
  830.    
  831. elseif terrainGeneration == 2 then
  832.     fill(255, 152, 0, 255)
  833.     rect(100, 100, 1000, 30)
  834. end
  835.     --Controls
  836.     sprite("Cargo Bot:Command Left", 15, 500)
  837.    sprite("Cargo Bot:Command Right", 1000, 500)
  838.    tint(196, 30, 30, 255)
  839.     sprite("Cargo Bot:Command Left", 15, 300)
  840.   sprite("Cargo Bot:Command Right", 1000, 300)
  841. tint(0, 0, 255, 255)
  842. sprite("Cargo Bot:Command Right", 1000, 400)
  843. sprite("Cargo Bot:Command Left", 15, 400)
  844.  
  845.     if lives == 0 then
  846.         restart()
  847.     end
  848.     fill(127, 127, 127, 113)
  849. rect(830, 730, 50, 50)
  850. fill(255, 255, 255, 255)
  851. text("||", 850, 750)
  852. if CurrentTouch.x >=824 and CurrentTouch.x <=874 and CurrentTouch.y >=724 and CurrentTouch.y <=784 then
  853.     paused=true
  854.     end
  855.   -- table.insert(tree, 1) little buggy, see Main, line 304 for further details. :(
  856. if paused == true then
  857. background(127, 127, 127, 255)
  858. fill(255)
  859. text("Paused", 500, 600)
  860. fill(0, 0, 0, 255)
  861. rect(500,500, 100, 50)
  862. rect(500, 350, 100, 50)
  863. fill(255, 255, 255, 255)
  864. text("Resume", 550,530)
  865. text("Quit to Title", 545, 370)
  866. if CurrentTouch.x >=500 and CurrentTouch.x <=600 and CurrentTouch.y >=494 and CurrentTouch.y <=554 then
  867. paused = false
  868.     end
  869. if CurrentTouch.x >=500 and CurrentTouch.x <=600 and CurrentTouch.y >=344 and CurrentTouch.y <=404 then
  870. paused = false
  871. pla = false
  872. Start:draw()
  873.     end
  874.     end
  875.     function keyboard(key)
  876.    if key == RETURN then
  877.        hideKeyboard()
  878.     end
  879. end
  880. end
  881.  
  882. function Play:touched(touch)
  883. if touch.x >=694 and touch.y <=754 then
  884.    
  885.     end
  886. end
  887.  
  888.  
  889.  
  890. --# PlayC
  891. PlayC = class()
  892.  
  893.  
  894. function PlayC:draw()  
  895.    
  896.    
  897.     background(0, 0, 0, 255)
  898.     saveLocalData("pLvl", lvl)
  899.    
  900.  
  901.    
  902.    
  903.     if BlueTintPack == true then
  904.         tint(0, 16, 255, 255)
  905.     else
  906.         tint(255, 255, 255, 255)
  907.     end
  908.  
  909.  
  910.     if sun.y >= 750 then
  911.     background(0, 0, 0, 255)
  912.  
  913.     sun.y = -500
  914. end
  915.  
  916. if sun.y >=30 then
  917.     background(119, 119, 225, 255)
  918. end
  919.     fill(255, 255, 255, 255)
  920.     text("Player Level: "..lvl,300, 700)
  921. --Cursor
  922. fill(127, 127, 127, 120)
  923. ellipse(CurrentTouch.x, CurrentTouch.y, 30)
  924.  
  925.  
  926. FPS = 1/DeltaTime
  927.  
  928.  
  929.  
  930. --FPS
  931. if GetFPS == true then
  932.     fontSize(15)
  933.         text("FPS:" ..FPS, 50, 100)
  934.    
  935. end
  936. --Text button
  937. fill(127, 127, 127, 255)
  938. rect(900, 700, 50, 50)
  939. fontSize(25)
  940. fill(255, 255, 255, 255)
  941. text("📝", 925, 725)
  942. if CurrentTouch.x >=894 and CurrentTouch.x <=954 and CurrentTouch.y >=694 and CurrentTouch.y <=754 then
  943. chatCmds = true
  944. end
  945.      --Cloud
  946.  
  947.         fill(255, 255, 255, 65)
  948.     rect(400, 650, rsw, 50)
  949.    
  950.    
  951.     fill(0, 0, 0, 255)
  952.     fontSize(20)
  953.     text("XP:", 200, 630)
  954.     --XP Bar
  955.     fill(0, 255, 0, 255)
  956.     rect(200, 600, XP, 20)
  957.  
  958.  
  959. --Grass bottom
  960. if terrainGeneration == 1 then
  961.     fill(116, 73, 31, 255)
  962. for i = 1,100 do
  963.   rect(100 * i, 0, 100, 100)
  964.     end
  965.     fill(113, 81, 31, 255)
  966.     rect(560, 125, 50, 50)
  967.     rect(560, 175.1, 50, 50)
  968.     rect(560, 225.1, 50, 50)
  969.     fill(74, 255, 0, 255)
  970.     rect(509, 225.1, 50, 50)
  971.     rect(609, 225.1, 50, 50)
  972.     rect(559, 275.1, 50, 50)
  973. elseif terrainGeneration == 2 then
  974.     fill(255, 152, 0, 255)
  975.     for i = 1,100 do
  976.         rect(100 * i, 0, 100, 100)
  977.     end
  978.     fill(255,152,0,255)
  979.     rect(700, 100, 100, 100)
  980. end
  981.  
  982. if XP >= 100 then
  983.     XPNewLava()
  984.    
  985. end
  986.  
  987. if chatCmds == true then
  988.     showKeyboard()
  989.     fill(255, 255, 255, 255)
  990.     stroke(127, 127, 127, 255)
  991.     strokeWidth(5)
  992.     rect(0, 700, 1000, 100)
  993.     noStroke()
  994.     noStroke()
  995.     noStroke()
  996.     --Help keeps the game clean with 3 noStroke()
  997.     textMode(CORNER)
  998.     buf = keyboardBuffer()
  999.    
  1000.     if buf then
  1001.         fill(0, 0, 0, 255)
  1002.     text( buf, 10, 750)
  1003.     end
  1004.     if buf == "/health me 10" then
  1005.   lives = 10
  1006.     end
  1007.     if buf == "/timeset morning" then
  1008.     sun.y = 0
  1009.     end
  1010.     if buf == "/timeset night" then
  1011.     sun.y =800
  1012.     end
  1013.     if buf == "/timeset day" then
  1014.     sun.y = 300
  1015.     end
  1016.     if buf == "/gamemode s" then
  1017.     pla = true
  1018.     cre = false
  1019.     Play:draw()
  1020.     end
  1021.     fill(255, 0, 0, 255)
  1022.     rect(600, 700, 100, 100)
  1023.    
  1024.     if CurrentTouch.x >= 600 and CurrentTouch.x <=700 and CurrentTouch.y >= 700 and CurrentTouch.y <=800 then
  1025. hideKeyboard()
  1026. chatCmds = false
  1027. end
  1028.     end
  1029.  
  1030. --Username tag
  1031. fill(NameTagColor)
  1032. text("" ..Username, p.x , 255)
  1033.  
  1034.     --Steve!
  1035.     sprite("Documents:Steve", p.x, p.y, 100, 110)
  1036.     --Head
  1037.  -- fill(180, 154, 80, 255)
  1038.     --rect(p.x, 250, 70, 70)
  1039.     --Body
  1040. --    fill(0, 0, 255, 255)
  1041.  
  1042. if p.x >1000 then
  1043.     --saveProjectData("health", 1)
  1044.    
  1045.     for i = 1,1 do
  1046.         sound(SOUND_HIT, 41660)
  1047.     end
  1048. end
  1049.  
  1050. --Build button
  1051. fill(30, 0, 255, 79)
  1052. rect(100, 500, 70, 70)
  1053. fill(255, 255, 255, 255)
  1054. text("Build", 135, 535)
  1055. --Build button touch quards
  1056. if CurrentTouch.x >=94 and CurrentTouch.x <=174 and CurrentTouch.y >494 and CurrentTouch.y <574 then
  1057.     building = true
  1058. end
  1059.  
  1060. if building == true then
  1061.     background(111, 108, 108, 255)
  1062.        fill(127, 127, 127, 105)
  1063.     rect(200, 600, 100, 70)
  1064.     fill(255, 0, 0, 123)
  1065.     rect(600, 200, 100, 100)
  1066.     fill(255)
  1067.     text("Exit", 650, 250)
  1068. if CurrentTouch.x >594 and CurrentTouch.x <704 and CurrentTouch.y >194 and CurrentTouch.y <304 then
  1069.     building = false
  1070. end
  1071.    if obsidian == 3 then
  1072.     fill(255)
  1073.     text("Neather Portal", 250, 630)
  1074.     if CurrentTouch.x >194 and CurrentTouch.x <304 and CurrentTouch.y >594 and CurrentTouch.y <674 then
  1075.     obsidian = 0
  1076.     neatherIgniters = 0
  1077.  
  1078.         neatherActive = true
  1079.         building = false
  1080.         end
  1081.     end
  1082. end
  1083.  
  1084. if neatherActive == true then
  1085. fill(0, 0, 0, 255)
  1086. rect(95, 115, 100, 100)
  1087. fill(212, 0, 255, 255)
  1088. rect(95, 165, 100, 50)
  1089. if p.x >=95 and p.x <=105 then
  1090.     neather = true
  1091.     end
  1092. end
  1093.  
  1094.  
  1095.  
  1096. if neather == true then
  1097.     background(230, 21, 21, 255)
  1098.           sprite("Documents:Steve", p.x, 185, 100, 110)
  1099.         --Neatherrack
  1100.         for i = 1,10 do
  1101.         fill(179, 51, 51, 255)
  1102.         rect(100 * i, 0, 100, 130)
  1103.         sun.y = -400
  1104.         end
  1105. if neatherBack >0 then
  1106.     next = next + 3
  1107.     if next%40==0 then
  1108.         fill(230, 0, 255, 255)
  1109.     end
  1110.     if next%40==0 then
  1111.     fill(0, 255, 255, 255)
  1112. end
  1113.     rect(700, 110, 100, 100)
  1114.     if p.x >694 and p.x <804 then
  1115.         neather = false
  1116.         end
  1117.     end
  1118. end
  1119.  
  1120. if p.x <100 then
  1121.  
  1122.    
  1123.         sound(SOUND_HIT, 41660)
  1124. end
  1125. fill(127, 127, 127, 90)
  1126. rect(300, 300, 70, 70)
  1127. fill(255, 255, 255, 255)
  1128. text("Craft", 330, 330)
  1129.  
  1130.  
  1131. if CurrentTouch.x >294 and CurrentTouch.x <374 and CurrentTouch.y >294 and CurrentTouch.y <374 then
  1132.     crafting = true
  1133. end
  1134.  
  1135. if crafting == true then
  1136.       background(123, 104, 30, 255)
  1137.      fill(255, 0, 0, 123)
  1138.     rect(600, 200, 100, 100)
  1139.     fill(255)
  1140.     text("Exit", 650, 250)
  1141. if CurrentTouch.x >594 and CurrentTouch.x <704 and CurrentTouch.y >194 and CurrentTouch.y <304 then
  1142.     crafting = false
  1143. end
  1144.     if lava >= 3 then
  1145.         fill(0, 0, 0, 255)
  1146.         rect(500, 500, 100, 100)
  1147.         fill(255, 255, 255, 255)
  1148.         text("OBSIDIAN", 500, 400)
  1149.         fill(127, 127, 127, 102)
  1150.         rect(600, 400, 70, 70)
  1151.         fill(255, 255, 255, 255)
  1152.         text("CraftObsidian", 630, 430)
  1153.        
  1154.        
  1155.        if CurrentTouch.x >594 and CurrentTouch.x <674 and CurrentTouch.y >394 and CurrentTouch.y <474 then
  1156.        
  1157. craftObsidian()
  1158. crafting = false
  1159.  
  1160.         end
  1161.     end
  1162.     if water >0 then
  1163.         fill(0, 255, 255, 255)
  1164.         rect(300, 500, 50, 50)
  1165.         fontSize(10)
  1166.         fill(255)
  1167.         text("NEATHERBACK", 340, 400)
  1168.         fill(127, 127, 127, 105)
  1169.         rect(300, 380, 70, 70)
  1170.         if CurrentTouch.x >294 and CurrentTouch.x <370 and CurrentTouch.y >374 and CurrentTouch.y <454 then
  1171.             craftNeatherback()
  1172.             crafting = false
  1173.            
  1174.         end
  1175.     end
  1176. end
  1177. fontSize(20)
  1178.  
  1179. --Inventory/hotbar
  1180. fill(127, 127, 127, 107)
  1181. rect(700, 600, 70, 70)
  1182. rect(800, 600, 70, 70)
  1183. rect(900, 600, 70, 70)
  1184. fontSize(30)
  1185. fill(255, 255, 255, 255)
  1186. text("...", 930, 630)
  1187. if CurrentTouch.x >894 and CurrentTouch.x <974 and CurrentTouch.y >594 and CurrentTouch.y <674 then
  1188.   inven = true
  1189. end
  1190.  
  1191.  
  1192. fill(127, 127, 127, 110)
  1193.     rect(250, 500, 70, 70)
  1194.    
  1195.  
  1196.  
  1197. if inven == true then
  1198.       background(51, 51, 51, 255)
  1199.     for i = 1,5 do
  1200.         fill(127, 127, 127, 141)
  1201.         rect(100 * i, 400, 90, 90)
  1202.     end
  1203.    
  1204.     if seeds >=1 then
  1205.         fill(57, 255, 0, 255)
  1206.         rect(130, 450, 20, 20)
  1207.         rect(100, 430, 20, 20)
  1208.         rect(120, 430, 15, 20)
  1209.     end
  1210.    
  1211.    
  1212.     fill(255, 0, 0, 121)
  1213.     rect(600, 200, 150, 150)
  1214.     fill(255, 255, 255, 255)
  1215.     text("Exit", 650, 250)
  1216.     if CurrentTouch.x >594 and CurrentTouch.x <704 and CurrentTouch.y >194 and CurrentTouch.y <304 then
  1217.         inven = false
  1218.     end
  1219. end
  1220.  
  1221. --player quards
  1222. fontSize(20)
  1223. fill(255, 255, 255, 255)
  1224. text("X: " ..p.x, 400, 400)
  1225. text("Y: " ..p.y, 500, 400)
  1226. if neatherIgniters >0 then
  1227.     fill(255, 108, 0, 255)
  1228.     ellipse(820, 620, 30)
  1229.     fill(255, 0, 0, 255)
  1230.     rect(820, 625, 10, 10)
  1231.     fill(255)
  1232. text("" .. neatherIgniters, 855, 612)
  1233. end
  1234. if obsidian > 0 then
  1235.     fill(0, 0, 0, 255)
  1236.     rect(710, 610, 40, 40)
  1237.     fill(255, 255, 255, 255)
  1238.     fontSize(15)
  1239.     text("" ..obsidian, 755, 612)
  1240. end
  1241.  
  1242. for i = 1,lives do
  1243.     sprite("Planet Cute:Heart", 70 * i, 600, 50, 50)
  1244. end
  1245.  
  1246. --Sun
  1247. fill(243, 255, 0, 193)
  1248. rect(600, 0 + sun.y, 300, 300)
  1249.  
  1250. sun.y = sun.y + 0.3
  1251.  
  1252. appleSpawn = appleSpawn + 1
  1253. if appleSpawn >=500 then
  1254.     fill(255, 0, 0, 255)
  1255.     ellipse(600, 150, 40)
  1256. end
  1257.  
  1258.     --Grass top
  1259.    
  1260. if terrainGeneration == 1 then
  1261.     fill(0, 255, 0, 255)
  1262.     rect(100, 100, 1000, 30)
  1263.    
  1264. elseif terrainGeneration == 2 then
  1265.     fill(255, 152, 0, 255)
  1266.     rect(100, 100, 1000, 30)
  1267. end
  1268.     --Controls
  1269.     sprite("Cargo Bot:Command Left", 15, 500)
  1270.    sprite("Cargo Bot:Command Right", 1000, 500)
  1271.    tint(196, 30, 30, 255)
  1272.     sprite("Cargo Bot:Command Left", 15, 300)
  1273.   sprite("Cargo Bot:Command Right", 1000, 300)
  1274. sprite("Cargo Bot:Command Grab", 500,450)
  1275. tint(0, 0, 255, 255)
  1276. sprite("Cargo Bot:Command Right", 1000, 400)
  1277. sprite("Cargo Bot:Command Left", 15, 400)
  1278. translate(500, 500)
  1279. tint(255, 0, 0, 255)
  1280. rotate(180)
  1281. sprite("Cargo Bot:Command Grab", 0, 0)
  1282.     if lives == 0 then
  1283.         restart()
  1284.     end
  1285.     fill(127, 127, 127, 113)
  1286. rect(830, 730, 50, 50)
  1287. fill(255, 255, 255, 255)
  1288. text("||", 850, 750)
  1289. if CurrentTouch.x >=824 and CurrentTouch.x <=874 and CurrentTouch.y >=724 and CurrentTouch.y <=784 then
  1290.     background(127, 127, 127, 0)
  1291.     fill(198, 193, 193, 255)
  1292.     text("Paused", 400, 600)
  1293.     fill(255, 255, 255, 255)
  1294. text("Touch to resume", 500, 500)
  1295.     end
  1296.    
  1297.    
  1298. end
  1299.  
  1300. function PlayC:touched(touch)
  1301.  
  1302. end
  1303.  
  1304. --# Start
  1305. Start = class()
  1306.  
  1307. function Start:setup()
  1308. pla = false
  1309. cre = false
  1310. end
  1311.  
  1312. function Start:draw()
  1313.    background(135, 100, 59, 255)
  1314. fontSize(75)
  1315. fill(48, 255, 0, 255)
  1316. text("Minecraft Codea Edition", 500, 650)
  1317. fill(127, 127, 127, 255)
  1318. fontSize(25)
  1319. rect(500, 450, 150, 90)
  1320. fill(255, 255, 255, 255)
  1321. text("Survival", 570, 490)
  1322. fill(127, 127, 127, 255)
  1323. rect(500, 300, 150, 90)
  1324. fill(255, 255, 255, 255)
  1325. text("Creative", 570, 340)
  1326. fill(127)
  1327. rect(500, 100, 100, 100)
  1328. fill(255)
  1329. text("Record", 550, 150)
  1330.  
  1331. fill(104, 45, 45, 255)
  1332. text("Beta "..Version, 100, 100)
  1333. fill(71, 172, 69, 255)
  1334. text("Created By: \n Marco V.", 170, 200)
  1335. if CurrentTouch.x >=500 and CurrentTouch.x <=650 and CurrentTouch.y >=450 and CurrentTouch.y <=590 then
  1336. pla = true
  1337.     end
  1338. if CurrentTouch.x >=500 and CurrentTouch.x <=650 and CurrentTouch.y >=300 and CurrentTouch.y <=390 then
  1339. cre = true
  1340. end
  1341. if pla == true then
  1342. Play:draw()
  1343.     end
  1344. if cre == true then
  1345. PlayC:draw()
  1346.     end
  1347.  
  1348. end
  1349.  
  1350. function Start:touched(touch)
  1351.    if touch.x >=494 and touch.x <=604 and touch.y >=94 and touch.y <=204 then
  1352.     startRecording()
  1353.     end
  1354.     if touch.tapCount >=3 then
  1355.     stopRecording()
  1356.     end
  1357. end
RAW Paste Data