Advertisement
thewmatt

Fish Simulator Game

Aug 27th, 2014
1,672
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.40 KB | None | 0 0
  1. --Config
  2. local k = 37
  3. local FishSimulatorVersion = "1.7.2"
  4. local fishX = 10
  5. local fishY = 10
  6. local fishHealth = 40
  7. local fishLt = "(O<"
  8. local fishRt = ">O)"
  9. local fishX2 = 12
  10. local fishY2 = 12
  11. local fishX3 = 6
  12. local fishY3 = 7
  13. local fishX4 = 14
  14. local fishY4 = 13
  15.  
  16. --Extra Variables
  17. local reset = 19
  18. local feed = 33 -- the key id for the F key
  19. local h = colors.green -- h is the variable for the color of the health number
  20. local fishLook = true -- true means left false means right
  21. local fishLook2 = false
  22. local fishLook3 = true
  23. local fishLook4 = false
  24. FishScreen = {
  25.   {
  26.     0,
  27.     0,
  28.     0,
  29.     0,
  30.     0,
  31.     0,
  32.     0,
  33.     0,
  34.     0,
  35.     0,
  36.     0,
  37.     0,
  38.     0,
  39.     0,
  40.     0,
  41.     0,
  42.     0,
  43.     0,
  44.     32,
  45.     0,
  46.     0,
  47.     0,
  48.     32,
  49.     0,
  50.     0,
  51.     0,
  52.     0,
  53.     0,
  54.     32,
  55.     0,
  56.     0,
  57.     0,
  58.     32,
  59.   },
  60.   {
  61.     0,
  62.     0,
  63.     0,
  64.     0,
  65.     0,
  66.     0,
  67.     0,
  68.     0,
  69.     0,
  70.     0,
  71.     0,
  72.     0,
  73.     0,
  74.     0,
  75.     0,
  76.     0,
  77.     0,
  78.     0,
  79.     0,
  80.     8192,
  81.     0,
  82.     32,
  83.     0,
  84.     0,
  85.     0,
  86.     0,
  87.     0,
  88.     0,
  89.     32,
  90.     0,
  91.     0,
  92.     0,
  93.     0,
  94.     32,
  95.   },
  96.   {
  97.     0,
  98.     0,
  99.     0,
  100.     0,
  101.     0,
  102.     0,
  103.     0,
  104.     0,
  105.     0,
  106.     0,
  107.     0,
  108.     0,
  109.     0,
  110.     0,
  111.     0,
  112.     0,
  113.     0,
  114.     0,
  115.     0,
  116.     8192,
  117.     0,
  118.     8192,
  119.     0,
  120.     0,
  121.     0,
  122.     0,
  123.     0,
  124.     0,
  125.     8192,
  126.     0,
  127.     0,
  128.     0,
  129.     0,
  130.     8192,
  131.   },
  132.   {
  133.     0,
  134.     0,
  135.     0,
  136.     0,
  137.     0,
  138.     0,
  139.     0,
  140.     0,
  141.     0,
  142.     0,
  143.     0,
  144.     0,
  145.     0,
  146.     0,
  147.     0,
  148.     0,
  149.     0,
  150.     0,
  151.     0,
  152.     0,
  153.     8192,
  154.     0,
  155.     0,
  156.     0,
  157.     0,
  158.     0,
  159.     0,
  160.     0,
  161.     0,
  162.     8192,
  163.     0,
  164.     0,
  165.     8192,
  166.   },
  167.   {
  168.     0,
  169.     0,
  170.     0,
  171.     0,
  172.     0,
  173.     0,
  174.     0,
  175.     0,
  176.     0,
  177.     0,
  178.     0,
  179.     0,
  180.     0,
  181.     0,
  182.     0,
  183.     0,
  184.     0,
  185.     0,
  186.     0,
  187.     0,
  188.     8192,
  189.     0,
  190.     0,
  191.     0,
  192.     0,
  193.     0,
  194.     0,
  195.     0,
  196.     0,
  197.     8192,
  198.     0,
  199.     0,
  200.     8192,
  201.   },
  202.   {
  203.     16,
  204.     16,
  205.     16,
  206.     16,
  207.     16,
  208.     16,
  209.     16,
  210.     16,
  211.     16,
  212.     16,
  213.     16,
  214.     16,
  215.     16,
  216.     16,
  217.     16,
  218.     16,
  219.     16,
  220.     16,
  221.     16,
  222.     16,
  223.     16,
  224.     16,
  225.     16,
  226.     16,
  227.     16,
  228.     16,
  229.     16,
  230.     16,
  231.     16,
  232.     16,
  233.     16,
  234.     16,
  235.     16,
  236.     16,
  237.     16,
  238.     16,
  239.     16,
  240.     16,
  241.     16,
  242.     16,
  243.     16,
  244.     16,
  245.     16,
  246.     16,
  247.     16,
  248.     16,
  249.     16,
  250.     16,
  251.     16,
  252.     16,
  253.     16,
  254.   },
  255. }
  256. --Functions
  257. function lose(death)
  258. term.setCursorPos(5,5)
  259. term.setBackgroundColor(colors.lightBlue)
  260.     print(death)
  261.     sleep(1)
  262.     term.clear()
  263.     term.setTextColor(1)
  264.         term.setCursorPos(1,1)
  265.         print("Restart? (Y/N)")
  266.         while true do
  267.         E,K = os.pullEvent("key")
  268.         y = 21
  269.         n = 49
  270.         if K == y then
  271.         shell.run("pastebin run 5x9Uu1pr")
  272.         error()
  273.         elseif K == n then
  274.         term.setBackgroundColor(colors.black)
  275.         term.clear()
  276.         term.setCursorPos(1,1)
  277.         sleep(1)
  278.         shell.run("shell")
  279.         error()
  280.         end
  281.         end
  282. end
  283. function reset()
  284. FmoveA = false
  285. term.setCursorPos(3,3)
  286. print("Resetting Fish Positions")
  287. fishX = 10
  288. fishY = 10
  289. fishX2 = 12
  290. fishY2 = 12
  291. fishX3 = 14
  292. fishY3 = 13
  293. fishLook = true -- true means left false means right
  294. fishLook2 = false
  295. fishLook3 = true
  296. fishLook4 = false
  297. end
  298. function fishFeed()
  299.     term.setCursorPos(5,5)
  300.     term.setBackgroundColor(colors.lightBlue)
  301.     print("Feeding Your Fish!")
  302.     fishHealth = fishHealth+1.5
  303.         if fishHealth < 10 then
  304. h = colors.red
  305. elseif fishHealth < 20 then
  306. h = colors.orange
  307.     elseif fishHealth > 30 then
  308. h = colors.green
  309. elseif fishHealth > 20 then
  310. h = 1
  311. elseif fishHealth < 10 then
  312. h = colors.red
  313. end
  314. if fishHealth > 40 then
  315.  
  316.         end
  317.     if fishHealth < .5 then
  318.     lose("Your Fish Starved To Death!")
  319. end
  320. end
  321. function fishMove()
  322.   term.setBackgroundColor(colors.lightBlue)
  323.   term.clear()
  324.   term.setCursorPos(1,1)
  325.   term.setTextColor(1)
  326.   term.write("Fish's Life: ")
  327.   term.setTextColor(h)
  328.   term.write(fishHealth)
  329.   term.setCursorPos(fishX,fishY)
  330.   term.setTextColor(colors.black)
  331.   term.setBackgroundColor(fishC1)
  332.   if fishLook then
  333.     term.write(fishLt)
  334.     else if fishLook == false then
  335.           term.write(fishRt)
  336.     end
  337.   end
  338. term.setCursorPos(fishX3,fishY3)
  339.   term.setTextColor(colors.black)
  340.   term.setBackgroundColor(fishC3)
  341.   if fishLook3 then
  342.     term.write(fishLt)
  343.     else
  344.           term.write(fishRt)    
  345. end
  346. term.setCursorPos(fishX2,fishY2)
  347.   term.setTextColor(colors.black)
  348.   term.setBackgroundColor(fishC2)
  349.   if fishLook2 then
  350.     print(fishLt)
  351.     else
  352.           print(fishRt)    
  353. end
  354.  if FmoveA then
  355. move3 = math.random(4)
  356.     if move3 == 1 then
  357.           fishX3 = fishX3-1
  358.           fishLook3 = true
  359.           elseif move3 == 2 then
  360.           fishX3 = fishX3+1
  361.           fishLook3 = false
  362.           elseif move3 == 3 then
  363.           fishY3 = fishY3-1
  364.           elseif move3 == 4 then
  365.           fishY3 = fishY3+1
  366. end
  367. move2 = math.random(4)
  368.     fishHealth = fishHealth - .5
  369.     if move2 == 1 then
  370.           fishX2 = fishX2-1
  371.           fishLook2 = true
  372.           elseif move2 == 2 then
  373.           fishX2 = fishX2+1
  374.           fishLook2 = false
  375.           elseif move2 == 3 then
  376.           fishY2 = fishY2-1
  377.           elseif move2 == 4 then
  378.           fishY2 = fishY2+1
  379. end
  380.     move = math.random(4)
  381.     if move == 1 then
  382.           fishX = fishX-1
  383.           fishLook = true
  384.           elseif move == 2 then
  385.           fishX = fishX+1
  386.           fishLook = false
  387.           elseif move == 3 then
  388.           fishY = fishY-1
  389.           elseif move == 4 then
  390.           fishY = fishY+1
  391.   --Health ColorChangers
  392. if fishHealth < 5 then
  393. h = colors.red
  394. elseif fishHealth < 10 then
  395. h = colors.orange
  396.     elseif fishHealth > 15 then
  397. h = colors.green
  398. elseif fishHealth > 9 then
  399. h = 1
  400. elseif fishHealth < 5 then
  401. h = colors.red
  402. end
  403. if fishHealth > 40 then
  404.         lose("Your Fish Was Overfed!")
  405.         end  
  406.  if fishHealth < .5 then
  407.     lose("Your Fish Starved To Death!")
  408. end
  409.    end
  410. end
  411.   paintutils.drawImage(FishScreen,1,14)
  412.   term.setBackgroundColor(colors.lightBlue)
  413. FmoveA = true
  414.   end
  415. --Startup Screen
  416. function sScreen()
  417. fishC1 = 2^math.random(14)
  418. fishC2 = 2^math.random(14)
  419. fishC3 = 2^math.random(14)
  420. term.setBackgroundColor(colors.lightBlue)
  421. term.setTextColor(colors.black)
  422. term.clear()
  423. paintutils.drawImage(FishScreen,1,14)
  424. paintutils.drawImage(FishScreen,1,14)
  425. term.setCursorPos(1,1)
  426. term.setBackgroundColor(colors.lightBlue)
  427. print("Fish Simulator v. "..FishSimulatorVersion)
  428. term.setCursorPos(fishX,fishY)
  429. term.setBackgroundColor(fishC1)
  430. print(fishLt)
  431. term.setBackgroundColor(fishC2)
  432. term.setCursorPos(fishX2,fishY2)
  433. print(fishRt)
  434. term.setBackgroundColor(fishC3)
  435. term.setCursorPos(fishX3,fishY3)
  436. print(fishLt)
  437. term.setBackgroundColor(colors.lightBlue)
  438. sleep(.50)
  439. term.setCursorPos(1,2)
  440. print("Fire An Event To Begin.")
  441. os.pullEvent()
  442. fishMove()
  443. --Run Code
  444. local id = os.startTimer(1)
  445. while true do
  446.   local event = {os.pullEvent()}
  447.   if event[ 1 ] == "timer" and event[ 2 ] == id then
  448.     fishMove()
  449.     id = os.startTimer(1)
  450.   elseif event[ 1 ] == "key" and event[ 2 ] == feed then
  451.     fishFeed()
  452.   elseif event[ 1 ] == "monitor_touch" then
  453.     fishFeed()
  454.   elseif event[ 1 ] == "key" and event[ 2 ] == 19 then
  455. reset()
  456.   elseif event[ 1 ] == "key" and event[ 2 ] == k then
  457.     lose("You Killed Your Fish!")
  458.   end
  459. end
  460. end
  461. sScreen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement