̬̬̬̈̬̬̬̬̈̬̬̬̬̬̪쬪̬̬̬̪쬪UUU`fff``p`pvvv`gggUUUfffUUU`fff``p`pvvvpgggUUUfffpppppppppppwwwwwwwwwwww@0303 301 301 @3033!013 0 @DDD033332#2#2DDD333DDD033300 0  DDD333!1 @DDD03330 0 0 DDD3331C32#2 DDD033300 0  DDD33311 0  """"""""""""P`p`p`p`PUUU`ffffgvgvgUUUfff            """" """ """""""""     """"""    """""" """     """!"!""     """"""    """"""pppppwwwpwwwwwwwwwwwwwpwwwpwwwwwwwww pvvVgeeupvvV`wpepVvgepVVgPpv`epv`epv`ePWPgpVVgepVvpe`weggWVVvegg`veepVvgepVwPW`epv`epv`epvPwpVWgepVvpe`w33"0@"@  @   @0@"@"3@3  @0@""3333@""@0@ @ @ @   @0@"@"3@333"0@"@    @0@""33@   @0@"@"3@3 !223322!2 3#223"2 3#232!#23##!3" ##133 ##"!3##23!#232 3#2"322 3#2gu`UVgeP`pPU`Ppp``pPp`p  0 pvvVgeeupvvV !223322!    C4 DD DD C4 ! "" "" !     ,000000000000000000000000000000 uRD0&"uRD0&" uRD0&" %!%"%$$&"&$829U%!%"%$$&"&$829U%!%"%$$&"&$829U  Pb           hPb h h h h h H H H H H Hh        20 ?@@@DDDDDDDDDDDD@DDDDDDDDDDDDPPUUUUUUUUUUUUUUUUUU0330333333033333303333330333333``ffffff`ffffff`ffffff030330!01C01pf`` 33!201 301""""""`g``0101#  02  """"""pvpp 33 20 #00`g``010# 02  pvpvvvpvvv  2     `g`gggpggg  "   """"""  pwpp  "   !  pwpp  "   "  pwpp  "   !  pwpp   """""" """""" " """"""pwwwwwwpwwwwwwppwwwwww   """""""""""" """""""pwwwwwwpwwwwwwpwwwwww@DDDDD@@@D@DDDD@DD@DD@@@@DDDDDD@DD@@@DDDDDDDDDD@@@@DDDDDDD@@DDDDDD@@D@DDDDD@`f`f`ff`fffff`f`ff``ff`fffffff`fffff``fffffffff````````f```fffff`fff`ff`fffffffff```````ff`f`fffffff`f`ffffffff````f`ff`f```fff`fff```f``ff`ffffff`f``````ff`ff`ffff`fff``ff``f]---------------------------------------------------- -- title: microlife -- author: Orange Revolt -- desc: A sandbox microbial life simulator. -- script: lua FOOD = 1 --types of life constants. BACTR = 2 VORE = 3 VORE_CAN = 4 SFX_DECAY = 16 SFX_SPAWN = 20 LSTATE_HUNT = 1 LSTATE_FEED = 2 LSTATE_SPLIT = 3 LSTATE_DECAY = 4 LSTATE_CANFEED = 5 INIT_BACTR = 50 INIT_VORE = 20 SPLIT_MAX = 10 INIT_FOOD = 200 WORLD_TIME = 30 WORLD_SIZE = 4080 TITLE_SCREEN = 1 TUT_SCREEN = 2 PLAY_SCREEN = 3 scrState = 1 initWorld = false isMusPlay = false stats = { bc = 0, vc = 0, fc = 0 } dir = { --directions r = 1, br = 2, b = 3, dl = 4, l = 5, ul = 6, u = 7, ur = 8, } screen = {--viewport. vx = 0,--scroll counters. vy = 0, scrx = 0, --scroll direction scry = 0, scrtb = 5,--scroll time scrt = 5, offx = 0,--draw scroll offsets for sprites offy = 0, } world = { bgArr = {}, wTime = 30 } life = { i = {}, t = {},--type x = {},--positions y = {}, e = {},--energy s = {},--state d = {},--direction m = {}, --temp memory } objSL = 1 --Vars for object placement gMenu = false --Mouse related bools. rClicked = false lClicked = false scrolledY = false scrolledX = false mPrevX = 0 --To check if has mouse moved. if so turn off gamepad if on. mPrevY = 0 hideCursor = false focusFX = true gamePad = { padDetect = false, --Gamepad related vars. padRp = false, padLp = false, padUp = false, padDp = false, padAp = false, padBp = false, padXp = false, padYp = false, PADU = 0, PADD = 1, PADL = 2, PADR = 3, PADA = 4, PADB = 5, PADX = 6, PADY = 7, padMx = 8, padMy = 8, padTimer = 5, PADTIMER = 5 } function Init() if initWorld == false then for w = 1, (17 * 30) * 8, 1 do table.insert(world.bgArr,0) end for n = 1,INIT_FOOD,1 do table.insert(life.i,n) table.insert(life.t,FOOD) local tx = math.random(2,119) --2,29 local ty = math.random(2,67) --2,16 while world.bgArr[tx + (ty * 30)] ~= 0 do tx = math.random(2,119) ty = math.random(2,67) end table.insert(life.x,tx) table.insert(life.y,ty) table.insert(life.e,math.random(12,40)) table.insert(life.s,0) table.insert(life.d,math.random(1,8)) table.insert(life.m,0) world.bgArr[tx + (ty * 120)] = life.i[n] end for n = 1,INIT_BACTR,1 do table.insert(life.i,n + INIT_FOOD) table.insert(life.t,BACTR) local tx = math.random(2,119) local ty = math.random(2,67) while world.bgArr[tx + (ty * 120)] ~= 0 do tx = math.random(2,119) ty = math.random(2,67) end table.insert(life.x,tx) table.insert(life.y,ty) table.insert(life.e,math.random(12,40)) table.insert(life.s,LSTATE_HUNT) table.insert(life.d,math.random(1,8)) table.insert(life.m,0) end for n = 1,INIT_VORE,1 do table.insert(life.i,n + INIT_FOOD + INIT_BACTR) table.insert(life.t,VORE) local tx = math.random(2,119) local ty = math.random(2,67) while world.bgArr[tx + (ty * 120)] ~= 0 do tx = math.random(2,119) ty = math.random(2,67) end table.insert(life.x,tx) table.insert(life.y,ty) table.insert(life.e,math.random(20,60)) table.insert(life.s,LSTATE_HUNT) table.insert(life.d,math.random(1,8)) table.insert(life.m,0) end initWorld = true end end function SpawnObj(type,amount,x,y) for n = 1,amount,1 do table.insert(life.i,n + INIT_FOOD + INIT_BACTR + INIT_VORE) table.insert(life.t,type) local tx = x + math.random(-4,4) local ty = y + math.random(-4,4) local trys = 1 while (tx < 1 or tx > 119 or tx == 0) or (ty < 1 or ty > 67 or ty == 0) or world.bgArr[tx + (ty * 120)] ~= 0 do tx = math.random(-4,4) ty = math.random(-4,4) trys = trys + 1 if trys > 100 then return end end table.insert(life.x,tx) table.insert(life.y,ty) if type == BACTR then table.insert(life.e,math.random(12,40)) elseif (type == VORE or type == VORE_CAN) then table.insert(life.e,math.random(20,60)) end table.insert(life.s,LSTATE_HUNT) table.insert(life.d,math.random(1,8)) table.insert(life.m,0) end end function RemObj(ind) table.remove(life.i,ind) table.remove(life.t,ind) table.remove(life.x,ind) table.remove(life.y,ind) table.remove(life.e,ind) table.remove(life.s,ind) table.remove(life.d,ind) table.remove(life.m,ind) end function GetObjIndex(type,x,y) for z = 1,#life.t,1 do if type == life.t[z] and x == life.x[z] and y == life.y[z] then return z end end return -1 end function MoveAct(i,type) life.d[i] = math.random(1,8) if life.d[i] == 1 and life.t[i] == type and life.x[i] < 119 then life.x[i] = life.x[i] + 1 life.e[i] = life.e[i] - 1 elseif life.d[i] == 2 and life.t[i] == type and life.x[i] < 119 and life.y[i] < 67 then life.x[i] = life.x[i] + 1 life.y[i] = life.y[i] + 1 life.e[i] = life.e[i] - 1 elseif life.d[i] == 3 and life.t[i] == type and life.y[i] < 67 then life.y[i] = life.y[i] + 1 life.e[i] = life.e[i] - 1 elseif life.d[i] == 4 and life.t[i] == type and life.x[i] > 1 and life.y[i] < 67 then life.x[i] = life.x[i] - 1 life.y[i] = life.y[i] + 1 life.e[i] = life.e[i] - 1 elseif life.d[i] == 5 and life.t[i] == type and life.x[i] > 1 then life.x[i] = life.x[i] - 1 life.e[i] = life.e[i] - 1 elseif life.d[i] == 6 and life.t[i] == type and life.x[i] > 1 and life.y[i] > 1 then life.x[i] = life.x[i] - 1 life.y[i] = life.y[i] - 1 life.e[i] = life.e[i] - 1 elseif life.d[i] == 7 and life.t[i] == type and life.y[i] > 1 then life.y[i] = life.y[i] - 1 life.e[i] = life.e[i] - 1 elseif life.d[i] == 8 and life.t[i] == type and life.x[i] < 119 and life.y[i] > 1 then life.x[i] = life.x[i] + 1 life.y[i] = life.y[i] - 1 life.e[i] = life.e[i] - 1 end end function EatAct(eaterdx,amnt) local eatendx = life.m[eaterdx] if life.e[eatendx] > 0 then life.e[eaterdx] = life.e[eaterdx] + amnt life.e[eatendx] = life.e[eatendx] - amnt elseif life.e[eatendx] <= 0 then SpawnObj(life.t[eaterdx],math.random(1,SPLIT_MAX),life.x[eaterdx],life.y[eaterdx]) --sfx(-1) --sfx(SFX_SPAWN + life.t[eaterdx] - 1) life.s[eatendx] = LSTATE_DECAY life.s[eaterdx] = LSTATE_HUNT life.m[eaterdx] = 0 return end end function EatCanAct(eaterdx) for z = 1, #life.i, 1 do if life.x[z] == life.x[eaterdx] + 1 and life.y[z] == life.y[eaterdx] then life.e[eaterdx] = life.e[eaterdx] + life.e[z] life.e[z] = 0 life.s[z] = LSTATE_DECAY life.t[eaterdx] = VORE_CAN break elseif life.x[z] == life.x[eaterdx] - 1 and life.y[z] == life.y[eaterdx] then life.e[eaterdx] = life.e[eaterdx] + life.e[z] life.e[z] = 0 life.s[z] = LSTATE_DECAY life.t[eaterdx] = VORE_CAN break elseif life.x[z] == life.x[eaterdx] and life.y[z] == life.y[eaterdx] + 1 then life.e[eaterdx] = life.e[eaterdx] + life.e[z] life.e[z] = 0 life.s[z] = LSTATE_DECAY life.t[eaterdx] = VORE_CAN break elseif life.x[z] == life.x[eaterdx] and life.y[z] == life.y[eaterdx] - 1 then life.e[eaterdx] = life.e[eaterdx] + life.e[z] life.e[z] = 0 life.s[z] = LSTATE_DECAY life.t[eaterdx] = VORE_CAN break end end end function Draw() --Draw lifeform sprites. for i = 1, #life.t,1 do if life.t[i] == FOOD then spr(272 + (life.d[i] - 1), ((life.x[i] + screen.offx) - 1) * 8, ((life.y[i] + screen.offy) - 1) * 8,0,1,0) elseif life.t[i] == BACTR then spr(256 + (life.d[i] - 1), ((life.x[i] + screen.offx) - 1) * 8, ((life.y[i] + screen.offy) - 1) * 8,0,1,0) elseif life.t[i] == VORE then spr(288 + (life.d[i] - 1), ((life.x[i] + screen.offx) - 1) * 8, ((life.y[i] + screen.offy) - 1) * 8,0,1,0) elseif life.t[i] == VORE_CAN then spr(296 + (life.d[i] - 1), ((life.x[i] + screen.offx) - 1) * 8, ((life.y[i] + screen.offy) - 1) * 8,0,1,0) end end --Print energy vals for each bactr,vore,var_can life. for n = 1,#life.i,1 do if life.t[n] == BACTR or life.t[n] == VORE or life.t[n] == VORE_CAN then print(life.e[n],(life.x[n] + screen.offx) * 8, (life.y[n] + screen.offy) * 8,4) end end end function Food() for n = 1, #life.t,1 do if life.t[n] == FOOD then life.d[n] = math.random(1,8) end if life.t[n] == FOOD and life.s[n] == LSTATE_DECAY then world.bgArr[life.x[n] + (life.y[n] * 120)] = 0 RemObj(n) break end end end function Bactr() for n = 1, #life.i,1 do if life.t[n] == BACTR and life.e[n] == 0 and life.s[n] ~= LSTATE_DECAY and life.s[n] ~= LSTATE_FEED then life.s[n] = LSTATE_DECAY end if life.t[n] == BACTR and life.s[n] == LSTATE_DECAY then --sfx(-1) --sfx(SFX_DECAY + life.t[n] - 1) RemObj(n) break end if life.t[n] == BACTR and life.e[n] > 0 and world.bgArr[life.x[n] + (life.y[n] * 120)] ~= 0 and life.s[n] ~= LSTATE_FEED then life.s[n] = LSTATE_FEED end if life.t[n] == BACTR and life.e[n] > 0 and world.bgArr[life.x[n] + (life.y[n] * 120)] == 0 and life.s[n] ~= LSTATE_HUNT then life.s[n] = LSTATE_HUNT end if life.t[n] == BACTR and life.s[n] == LSTATE_FEED then for z = 1, #life.i,1 do if life.t[z] == FOOD and life.x[z] == life.x[n] and life.y[z] == life.y[n] then life.m[n] = z break end end if life.m[n] ~= 0 and life.x[n] == life.x[life.m[n]] and life.y[n] == life.y[life.m[n]] then EatAct(n,1) else life.s[n] = LSTATE_HUNT end end if life.t[n] == BACTR and life.s[n] == LSTATE_HUNT then MoveAct(n,life.t[n]) end end end function Vore() for n = 1, #life.i,1 do if (life.t[n] == VORE or life.t[n] == VORE_CAN) and life.e[n] == 0 and life.s[n] ~= LSTATE_DECAY and life.s[n] ~= LSTATE_FEED then life.s[n] = LSTATE_DECAY end if (life.t[n] == VORE or life.t[n] == VORE_CAN) and life.s[n] == LSTATE_DECAY then --sfx(-1) --sfx(SFX_DECAY + life.t[n] - 1) RemObj(n) break end if (life.t[n] == VORE or life.t[n] == VORE_CAN) and life.e[n] > 0 and world.bgArr[life.x[n] + (life.y[n] * 120)] ~= 0 and life.s[n] ~= LSTATE_FEED then life.s[n] = LSTATE_FEED end if life.t[n] == VORE and life.e[n] <= 10 and life.s[n] ~= LSTATE_FEED then EatCanAct(n) end if (life.t[n] == VORE or life.t[n] == VORE_CAN) and life.e[n] > 0 and world.bgArr[life.x[n] + (life.y[n] * 120)] == 0 and life.s[n] ~= LSTATE_HUNT then life.s[n] = LSTATE_HUNT end if (life.t[n] == VORE or life.t[n] == VORE_CAN) and life.s[n] == LSTATE_FEED then for z = 1, #life.i,1 do if life.t[z] == FOOD and life.x[z] == life.x[n] and life.y[z] == life.y[n] then life.m[n] = z end end if life.m[n] ~= 0 and life.x[n] == life.x[life.m[n]] and life.y[n] == life.y[life.m[n]] then EatAct(n,1) else life.s[n] = LSTATE_HUNT end end if (life.t[n] == VORE or life.t[n] == VORE_CAN) and life.s[n] == LSTATE_HUNT then MoveAct(n,life.t[n]) end end end function Scroll(x,y) if screen.scrt > 0 then screen.scrt = screen.scrt - 1 else if x == dir.r and screen.vx < (120 - 30) then screen.scrx = 1 screen.offx = screen.offx - 1 screen.vx = screen.vx + 1 print(screen.vx.." , "..screen.vy,1,24,4) elseif x == dir.l and screen.vx > 0 then screen.scrx = -1 screen.offx = screen.offx + 1 screen.vx = screen.vx - 1 print(screen.vx.." , "..screen.vy,1,24,4) else screen.scrx = 0 end if y == dir.d and screen.vy < (68 - 17) then screen.scry = 1 screen.offy = screen.offy - 1 screen.vy = screen.vy + 1 print(screen.vx.." , "..screen.vy,1,24,4) elseif y == dir.u and screen.vy > 0 then screen.scry = -1 screen.offy = screen.offy + 1 screen.vy = screen.vy - 1 print(screen.vx.." , "..screen.vy,1,24,4) else screen.scry = 0 end screen.scrt = screen.scrtb end end function PlaceObj(type,amount,x,y) for xi = 1, amount, 1 do table.insert(life.i, #life.i + xi) table.insert(life.t, type) table.insert(life.x, x) table.insert(life.y, y) if type == BACTR then table.insert(life.e,math.random(12,40)) table.insert(life.s, LSTATE_HUNT) elseif type == VORE then table.insert(life.e,math.random(20,60)) table.insert(life.s, LSTATE_HUNT) elseif type == VORE_CAN then table.insert(life.e,math.random(30,60)) table.insert(life.s, LSTATE_HUNT) elseif type == FOOD then table.insert(life.e,math.random(12,40)) table.insert(life.s, 0) world.bgArr[x + (y * 120)] = life.i[#life.i + xi] end table.insert(life.d, math.random(1,8)) table.insert(life.m, 0) end end displayT = 0 --placement function only global var. function Placement() if initWorld == true then local x,y,left,middle,right,scrollx,scrolly=mouse() if key(28) then objSL = 1 displayT = 0 displayT = 30 scrolledY = true elseif key(29) then objSL = 2 displayT = 0 displayT = 30 scrolledY = true elseif key(30) then objSL = 3 displayT = 0 displayT = 30 scrolledY = true elseif key(31) then objSL = 4 displayT = 0 displayT = 30 scrolledY = true end if scrolly == 1 and scrolledY == false or (btn(gamePad.PADY) and gamePad.padYp == false) then if objSL < 4 then objSL = objSL + 1 displayT = 0 displayT = 30 scrolledY = true gamePad.padYp = true end elseif scrolly == -1 and scrolledY == false or (btn(gamePad.PADB) and gamePad.padBp == false)then if objSL > 1 then objSL = objSL - 1 displayT = 0 displayT = 30 scrolledY = true gamePad.padBp = true end end if displayT > 0 then displayT = displayT - 1 if (gamePad.padDetect == false) then spr(480 + (objSL - 1), x + 8, y,0,1,0) else spr(480 + (objSL - 1), (gamePad.padMx + 1) * 8, gamePad.padMy * 8,0,1,0) end end if (left and lClicked == false) then PlaceObj(objSL,1,(x//8 + 1) + screen.vx,(y//8 + 1) + screen.vy) lClicked = true gamePad.padAp = true elseif (btn(gamePad.PADA) and gamePad.padAp == false) then PlaceObj(objSL,1,(gamePad.padMx + 1) + screen.vx,(gamePad.padMy + 1) + screen.vy) lClicked = true gamePad.padAp = true end if scrolly == 0 and scrolledY == true then scrolledY = false end end end function SimMenu() local x,y,left,middle,right,scrollx,scrolly=mouse() if ((right and rClicked == false) or (btn(gamePad.PADX) and gamePad.padXp == false)) and scrState == PLAY_SCREEN then stats.bc = 0 stats.vc = 0 stats.fc = 0 for z = 1, #life.i, 1 do if life.t[z] == BACTR then stats.bc = stats.bc + 1 elseif life.t[z] == VORE or life.t[z] == VORE_CAN then stats.vc = stats.vc + 1 elseif life.t[z] == FOOD then stats.fc = stats.fc + 1 end end gMenu = not gMenu rClicked = true gamePad.padXp = true end --scroll screen based on cursor location. if gMenu == false and scrState == PLAY_SCREEN then if (x//8 == 29 and y//8 > 1 and y//8 < 16) or (gamePad.padMx == 29 and gamePad.padMy > 1 and gamePad.padMy < 16) then Scroll(dir.r,0) elseif (x//8 == 0 and y//8 > 1 and y//8 < 16) or (gamePad.padMx == 0 and gamePad.padMy > 1 and gamePad.padMy < 16) then Scroll(dir.l,0) elseif (x//8 > 1 and x//8 < 29 and y//8 >= 16) or (gamePad.padMx > 1 and gamePad.padMx//8 < 29 and gamePad.padMy >= 16) then Scroll(0,dir.d) elseif (x//8 > 1 and x//8 < 29 and y//8 <= 0) or (gamePad.padMx > 1 and gamePad.padMx//8 < 29 and gamePad.padMy <= 0) then Scroll(0,dir.u) end end if gMenu == true then print("SUGAR COUNT: "..stats.fc,1,96,4) print("BACTR COUNT: "..stats.bc,1,104,4) print("VORE COUNT: "..stats.vc,1,112,4) print("WORLD SPEED:",1,1,4) print(WORLD_TIME,80,1,4) spr(496,104,0,0,1,0) spr(498,112,0,0,1,0) if ((x//8 == 14 and y//8 == 0 and left and lClicked == false) or (gamePad.padMx == 14 and gamePad.padMy == 0 and btn(gamePad.PADA) and gamePad.padAp == false)) and WORLD_TIME < 990 then WORLD_TIME = WORLD_TIME + 30 lClicked = true gamePad.padAp = true elseif ((x//8 == 13 and y//8 == 0 and left and lClicked == false) or (gamePad.padMx == 13 and gamePad.padMy == 0 and btn(gamePad.PADA) and gamePad.padAp == false)) and WORLD_TIME > 0 then WORLD_TIME = WORLD_TIME - 30 lClicked = true gamePad.padAp = true end print("SCROLL SPEED:",1,8,4) print(screen.scrtb,80,8,4) spr(496,104,8,0,1,0) spr(498,112,8,0,1,0) if ((x//8 == 14 and y//8 == 1 and left and lClicked == false) or(gamePad.padMx == 14 and gamePad.padMy == 1 and btn(gamePad.PADA) and gamePad.padAp == false)) and screen.scrtb < 60 then screen.scrtb = screen.scrtb + 5 lClicked = true gamePad.padAp = true elseif ((x//8 == 13 and y//8 == 1 and left and lClicked == false) or (gamePad.padMx == 13 and gamePad.padMy == 1 and btn(gamePad.PADA) and gamePad.padAp == false)) and screen.scrtb > 5 then screen.scrtb = screen.scrtb - 5 lClicked = true gamePad.padAp = true end if focusFX == true then spr(504,216,8,0,1,0) else spr(505,216,8,0,1,0) end print("FOCUS EFFECT:",138,8,4) if (x//8 == 27 and y//1 and left and lClicked == false) or (gamePad.padMx == 27 and gamePad.padMy == 1 and btn(gamePad.PADA) and gamePad.padAp == false) then focusFX = not focusFX lClicked = true gamePad.padAp = true end print("RESET WORLD:",138,1,4) spr(500,208,1,0,1,0) spr(501,216,1,0,1,0) if ((x//8 == 26 or x//8 == 27) and y//8 == 0 and left and lClicked == false) or ((gamePad.padMx == 26 or gamePad.padMx == 27) and gamePad.padMy == 0 and btn(gamePad.PADA) and gamePad.padAp == false) then ResetWorld() lClicked = true gamePad.padAp = true end print("INIT FOOD: "..INIT_FOOD,1,24,4) print("INIT BACTRS: "..INIT_BACTR,1,32,4) print("INIT VORES: "..INIT_VORE,1,40,4) spr(496,104,24,0,1,0) spr(498,112,24,0,1,0) spr(496,104,32,0,1,0) spr(498,112,32,0,1,0) spr(496,104,40,0,1,0) spr(498,112,40,0,1,0) if ((x//8 == 14 and y//8 == 3 and left and lClicked == false) or (gamePad.padMx == 14 and gamePad.padMy == 3 and btn(gamePad.PADA) and gamePad.padAp == false)) and INIT_FOOD < 1000 then INIT_FOOD = INIT_FOOD + 1 lClicked = true gamePad.padAp = true elseif ((x//8 == 13 and y//8 == 3 and left and lClicked == false) or (gamePad.padMx == 13 and gamePad.padMy == 3 and btn(gamePad.PADA) and gamePad.padAp == false)) and INIT_FOOD > 1 then INIT_FOOD = INIT_FOOD - 1 lClicked = true gamePad.padAp = true elseif ((x//8 == 14 and y//8 == 4 and left and lClicked == false) or (gamePad.padMx == 14 and gamePad.padMy == 4 and btn(gamePad.PADA) and gamePad.padAp == false)) and INIT_BACTR < 1000 then INIT_BACTR = INIT_BACTR + 1 lClicked = true gamePad.padAp = true elseif ((x//8 == 13 and y//8 == 4 and left and lClicked == false) or (gamePad.padMx == 13 and gamePad.padMy == 4 and btn(gamePad.PADA) and gamePad.padAp == false)) and INIT_BACTR > 1 then INIT_BACTR = INIT_BACTR - 1 lClicked = true gamePad.padAp = true elseif ((x//8 == 14 and y//8 == 5 and left and lClicked == false) or (gamePad.padMx == 14 and gamePad.padMy == 5 and btn(gamePad.PADA) and gamePad.padAp == false)) and INIT_VORE < 1000 then INIT_VORE = INIT_VORE + 1 lClicked = true gamePad.padAp = true elseif ((x//8 == 13 and y//8 == 5 and left and lClicked == false) or (gamePad.padMx == 13 and gamePad.padMy == 5 and btn(gamePad.PADA) and gamePad.padAp == false)) and INIT_VORE > 1 then INIT_VORE = INIT_VORE - 1 lClicked = true gamePad.padAp = true end end if not right and rClicked == true then rClicked = false end if not left and lClicked == true then lClicked = false end if scrolly == 0 and scrolledY == true then scrolledY = false end end function CursorEdit() local x,y,left,middle,right,scrollx,scrolly=mouse() if (peek(0x3FFB) == 128) then --hide mouse with empty. poke(0x3FFB,9) end if gamePad.padDetect == false then spr(511,x,y,0) end end function Gamepad() if gamePad.padTimer > 0 then gamePad.padTimer = gamePad.padTimer - 1 else if btn(0) and gamePad.padMy > 0 then gamePad.padDetect = true gamePad.padMy = gamePad.padMy - 1 elseif btn(1) and gamePad.padMy < 16 then gamePad.padDetect = true gamePad.padMy = gamePad.padMy + 1 elseif btn(2) and gamePad.padMx > 0 then gamePad.padDetect = true gamePad.padMx = gamePad.padMx - 1 elseif btn(3) and gamePad.padMx < 29 then gamePad.padDetect = true gamePad.padMx = gamePad.padMx + 1 end gamePad.padTimer = gamePad.PADTIMER end if gamePad.padAp == true and (not btn(gamePad.PADA)) then gamePad.padAp = false elseif gamePad.padYp == true and (not btn(gamePad.PADY)) then gamePad.padYp = false elseif gamePad.padBp == true and (not btn(gamePad.PADB)) then gamePad.padBp = false elseif gamePad.padXp == true and (not btn(gamePad.PADX)) then gamePad.padXp = false end if gamePad.padDetect == true then spr(511,gamePad.padMx * 8,gamePad.padMy * 8,0) end end function MouseDetect() local x,y,left,middle,right,scrollx,scrolly=mouse() if mPrevX ~= x and mPrevY ~= y then gamePad.padDetect = false mPrevX = x mPrevY = y end end function MouseActs() MouseDetect() if gMenu == false then Placement() end CursorEdit() end function ResetWorld() for n = 1,#life.i,1 do life.i[n] = nil life.t[n] = nil life.x[n] = nil life.y[n] = nil life.s[n] = nil life.m[n] = nil end for n = 1, #world.bgArr, 1 do world.bgArr[n] = nil end screen.vx = 0 screen.vy = 0 screen.scrx = 0 screen.scry = 0 screen.scrtb = 10 screenscrt = 10 screen.offx = 0 screen.offy = 0 initWorld = false gMenu = false Init() end sclC = 0 --scLCT = false scLV = 0 scLD = false function SCN(scaneline) if gMenu == false and focusFX == true then --poke(0x3FF9+1,scLV) if scLD == true and (scaneline <= 16 or scaneline >= 108) then if scaneline % 2 == 0 then poke(0x3FF9,-1) else poke(0x3FF9,1) end elseif scLD == false and (scaneline <= 16 or scaneline >= 108) then if scaneline % 2 == 0 then poke(0x3FF9,1) else poke(0x3FF9,-1) end end if scaneline > 16 and scaneline < 108 then poke(0x3FF9,0) end end end function TIC() cls() local x,y,left,middle,right,scrollx,scrolly=mouse() if scrState == TITLE_SCREEN then map(0,0,30,17) print("CLICK TO PLAY",80,64,4) print("A GAME BY ORANGE_REVOLT. V 1.1",40,96,6) if isMusPlay == false then music(0) isMusPlay = true end if (left and lClicked == false) or (gamePad.padDetect == true and btn(gamePad.PADA) and gamePad.padAp == false) then scrState = TUT_SCREEN lClicked = true gamePad.padAp = true end elseif scrState == TUT_SCREEN then map(30,0,30,17) if gamePad.padDetect == false then print("MOUSE & KEYBOARD CONTROLS",48,32,5) print("LEFT CLICK TO PLACE OBJECTS,AND KEYBOARD\nNUMS OR SCROLL WHEEL TO CHANGE OBJECT\nTYPE.\n\nRIGHT CLICK TO OPEN MENU, WHERE YOU MAY\nCONFIG GAME OR SEE STATS.\n\nMOVE MOUSE AT EDGE TO SCROLL MAP",8,48,4) else print("GAMEPAD CONTROLS",48,32,5) print("(A) TO PLACE OBJECTS,AND (Y) or (B)TO CHANGE\nOBJECT TYPE.\n\n(X) TO OPEN MENU, WHERE YOU MAY\nCONFIG GAME OR SEE STATS.\n\nMOVE POINTER AT EDGE TO SCROLL MAP",8,48,4) end if (left and lClicked == false) or (gamePad.padDetect == true and btn(gamePad.PADA) and gamePad.padAp == false) then Init() scrState = PLAY_SCREEN gamePad.padAp = true end end if initWorld == true and gMenu == false then map(30,0,30,17) if world.wTime > 0 then world.wTime = world.wTime - 1 else Bactr() Vore() Food() world.wTime = WORLD_TIME end Draw() end SimMenu() Gamepad() MouseActs() --scanline effect speed. higher val is slower. if sclC % 1 == 0 then scLD = not scLD end if sclC < 140 then sclC = sclC + 1 else sclC = 0 end end