0,]']>S}Wu}p8d%qy)6o;]AsHYq3?pqqqqqqqqrNNNNNONNNNNNNNNNNpqqqqqqqqr!"#$%12345123451234512345123451234512345pqqqqqqqqrpqqqqqqqqr{{{{{{{{{{{{{{{{{{{{pqqqqqqqqr pqqqqqqqqrNNNNNNNNONNNNNONNpqqqqqqqqr12345ABCDEABCDEABCDEABCDEABCDEABCDEABCDEpqqqqqqqqrpqqqqqqqqr{{{{{{{{{{{{{{{{{{pqqqqqqqqr pqqqqqqqqrNNNONNNNNOONNNNNNNpqqqqqqqqrABCDEQRSTUQRSTUQRSTUQRSTUQRSTUQRSTUQRSTUpqqqqqqqqrpqqqqqqqqr{{{{{{{{{{{{{{{{{{pqqqqqqqqrpqqqqqqqqrNNNNNNNNNNNNNNNNNpqqqqqqqqrQRSTUpqqqqqqqqrpqqqqqqqqr{{{{{{{{{{{{{{{{pqqqqqqqqrpqqqqqqqqrNNNNNNNNNNNNNNNNNNpqqqqqqqqrpqqqqqqqqrpqqqqqqqqr{{{{{{{{{{{{{{{{{{pqqqqqqqqr<=pqqqqqqqqrNNNNNNNNNNNOONNNNNpqqqqqqqqr!"#$%!"#$%!"#$%!"#$%!"#$%!"#$%!"#$%pqqqqqqqqrpqqqqqqqqr{|}{{{{{{{{{{{{{{{{{pqqqqqqqqr,pqqqqqqqqrNNNNNNNNNNNOOONNNNpqqqqqqqqr!"#$%12345123451234512345123451234512345pqqqqqqqqrpqqqqqqqqr{{{{{{{{{{{{{{{{pqqqqqqqqrpqqqqqqqqrNONNNNONNNOOOONNNpqqqqqqqqr12345ABCDEABCDEABCDEABCDEABCDEABCDEABCDEpqqqqqqqqrpqqqqqqqqr{{{{{{{{{{{{{{{{{{{{pqqqqqqqqr <=.pqqqqqqqqrNONNNNNNNNNOOOONNNpqqqqqqqqrABCDEQRSTUQRSTUQRSTUQRSTUQRSTUQRSTUQRSTUpqqqqqqqqrpqqqqqqqqr{{{{{{{{{{{{{{{{{pqqqqqqqqr-->pqqqqqqqqrNNNNNNNNNNNOOONNNNpqqqqqqqqrQRSTUpqqqqqqqqrpqqqqqqqqr{{{{{{{{{{{{{{{{{{pqqqqqqqqrLpqqqqqqqqrNNNNONNNNNNOONNNNNpqqqqqqqqrpqqqqqqqqrpqqqqqqqqr{{{{{{{{{{{{{{{{{{pqqqqqqqqrMpqqqqqqqqrNNNNONNNONNNNNNNNpqqqqqqqqr!"#$%!"#$%!"#$%!"#$%!"#$%!"#$%!"#$%pqqqqqqqqrpqqqqqqqqr{{{{{{{{{{{{{{{{{{pqqqqqqqqrpqqqqqqqqrNNNNONNNNONNNNNNNNpqqqqqqqqr!"#$%12345123451234512345123451234512345pqqqqqqqqrpqqqqqqqqr{{{{{{{{{{{{{{{{{{pqqqqqqqqrL/pqqqqqqqqrNNNNONNNNNONNNNNNNpqqqqqqqqr12345ABCDEABCDEABCDEABCDEABCDEABCDEABCDEpqqqqqqqqrpqqqqqqqqr{{{{{{{{{{{{{{{{{pqqqqqqqqr<=/./MpqqqqqqqqrNNNNNNNNNNNNNNNNNpqqqqqqqqrABCDEQRSTUQRSTUQRSTUQRSTUQRSTUQRSTUQRSTU{{{{{{{{{{{{{{{{{{,->?noQRSTU!"#$%!"#$%!"#$%!"#$%!"#$%!"#$%!"#$%!"#$%1234512345123451234512345123451234512345ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEQRSTUQRSTUQRSTUQRSTUQRSTUQRSTUQRSTUQRSTU y.+(((((+./////////////////////'''' ' ' ' (((*+,-.///////////////>>>>==;; < ??????????????????????????>>>==<;;?????????????????QQQQRRTVWXWVUUUUUUUUUUVWYZ[]^_ 333???????????????????????????666??????????????????????????? N L I F D E E F G G H H I J K M M O O O O O O O O O O O O O ?;<<===>??????>>98521000000000d//.-,+*)((((((((//////////////         cccccAAA cccccAAA cccccAAA   cccccAAA  cccccAAA cccccAAA  `` ` ` ` @@@ 0T o o O O o o O O o o O O o o O OooOOooOOooO O o o OO o o O O o o O O o o OOooOOrr rrrr r r rrqqqqQ q qqqqQqQ cccccC cccccccccccccAAA cccc ccc   cccccccccAAAA ccccc  cccccccccccAAA2Aa$Bq(Aa$Bq(Aa,Bq0Aa4Bq0CCCD?fwwgfffffffffffffffffFfdfffffffffffffffffffffffffffffffffffffffffffffffffffffwwwgffffffffffffffffffFfffffffffffffffffffffffffffffffffffffffffffffffffffff3#jwwfvffffffffffffffffffdFfffffffffffffffffffwwfffffffffffffffffFDDfDdFDdfDdf6DDwffvfffffffffffffffffFfFfffffffffffffffffgfwffffffffffffffffFdfFdDffDFdffL4C$fffffffffffffffffffffFfdfffffffffffffffffvgfffffffffffffffFDdFDFfDdFDdfCCD$ffffffffffffffffffffFdfdfffffffffffffffflfwfffffffffffffffffDFdFFdfFdFfLCD$ffffffffffffffffffffffDFfffffffffffffffffvwfffffmfffffffffFDdfDdFDDfDdfC4C$ffffffffffffffffffffffffffffffffffffffflffwmwgffffmffffffffffffffffffffff6DDblffffffff,"""""""",""""""""ffffffffffffffffffffffffffffffffffffffflg|gfffmfffffffffffffffffffffff3#ffflffl,""",""",ffffffffffffffffffffffffffffffffffffffflf|gfffmfffffffffffffffffffffffffffffll"",,"",,ffffffffffffffffffffffffffffffffffffffflf|gWvfffmffffffffffffffffffffffffffflflffll"",,","",,fffffffffffffffffffffffffffffffffffffffluuffmffffffffffffffffffffffffffffffll",,",",,fffffffffffffffffffffffffffffffffffffffvwWgfffffffffffffffffffffffffffflffff""""",""""fffffffffffffffffffffffffffffffffffffffffmfmffffffffffffffffffffffffffflffffffff,"""""""",""""""""ffffffffffffffffffffffffffffffffffffffff3offffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff63offffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61f33fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61631fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6133333333ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff3333333333f&bffffffffffffffffffffff,"""""""","""""""",""""""""fffffffffffffffffeffffffffffffffffffffffffff333<3333fb&ffffffffffffffffffffff""""""""""""""""""""""""""""""fffffffffffffffffefffffffffffffffffffffffff633<33cfb&ffffffffffffffffffffff"""""""""""""""""""""""""""ffffffffffffffffVffffffffffffffffffffffffff6333333ffbffffffffffffffffffffff""""""""""""fffffffffffffffffffffffffffffffffffffffffff33333333f&fffffffffffffffffffffff"""""""""""""""""""""""""""fffffffffffffffffffffffffffffffffffffffffff33333333333bfffffffffffffffffffffff""""""""""""""""""""""""""""""ffffffffffffffffffffffffffffffffffffffffff633333333333bfffffffffffffffffffffff,"""""""","""""""",""""""""ffffffffffffffffffffffffffffffffffffffffff633333""3333"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff63333"332333"fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6333#333#333"fffffffffefffffffffffffffffffffffffffffffffffffffffffffffffffffff633323233233"fffffffffefffffffffffffffffffffffffffffffffffffffffffffffffffffff6333233#3233"ffffffffVffffffffffffffffffffffffffffffffffffffffffffffffffffffff6333#3333233"ffffffVfVfffffffffffffflfffffffflffffffff,""""""""fffffffffffffffffffffffffffffffffffffffffff3333""""333!"fffffffeVfffffffffffffflffffffflffll","",fffffffffffffffffffffffffffffffffffffffffff33333333333!"fffffffeVffffffffffffffffffflflfll"",,fffffffffffffffffffffffffffffffffffffffffff33333333333!bfffffffVVfffffffffffffflfffffflffl","",,fffffffffffffffffffffffffffffffffffffffffff3333333333"bfffffffVVVefffffffffffffffflflffl""",,fffffffffffffffffffffffffffffffffffffffffff6333333333!"ffffffffVVeffffffffffffflffffffflfffl""""ffffffffffffffffffffffffffffffffffffffffffff23333333"bfffffffffUfffffffffffffflfffffffflffffffff,""""""""ffffffffffffffffffffffffffffffffffffffffffff22!bfffffffffefffffffffffffffffffffffffffffffffffffffffffffffffffffffff2"2.nfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2"2.fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff2"2.nffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffnfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffnffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffnfffffffffffffffffffffffffflfffffffflfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff~wwwwwwwwflflflfffffffffffffffdDfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffw}w}}wwffflffffffffffffFfFFFfFdfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffwwwfllfllffffffffffffdddFfdffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff}wwffflfffffffffffffFFfdfdffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffwwwllflfffffffffffFFfdFfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffww}w}}wwlfffffffflfffffffffffffffffFFFfdfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff~wwwwwwwwfffffffffdFFFfdfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffddFFfFfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdfdffffffffffffffffffffffffVfffffffffffffffffffffffffffffffffffffffffffffffffffFfdffffffffffffffffffffffffVffffffffffffffffffffffffffffffffffffffffffffffffffffFfffffffffffffffffffffffffVffffffffffffffffffffffffffffffffffffffffffffffffffffdFffffffffffffffffffffffffVfffffffffffffffffffffffffffffffffffffffffffffffffffFfFffffffffffffffffffffffffVVefffffffffffffffffffffffffffffffffffflfffffffffffffffffffffffffffffffffffffffFfdffffffffffffffffffffffffVeffffffffffffffffffffffffffffffffffffflffffffffffffffffffffffffffffffffffffffFdfdffffffffffffffffffffffffUfffffffffffffffffffffffffffffffffffffflffffffffffffffffffffffffffffffffffffffffDFffffffffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdDffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffFfFFFfFdfffffffffffffffffffffffffffffffffffffffffffffffffffffefffffffffffffffffffffffffffffffffffffffffffdddFfdffffffffffffffffffffffffffffffffffffffffffffffffffefffffffffffffffffffffffffffffffffffffffffffFFfdfdffffffffffffffffffffffffffffffffffffffffffffffffffVfffffffffffffffffffffffffffffffffffffffffffFFfdFffffffffffffffffvfffffffffffffffffffffffffffffffffffffffffffVfffefffffffffffffffffffffffffffffffffffffffFFFfdffffffffffffffffvfffffffffffffffffffffffffffffffffffffffffffVeffefffffffffffffffffffffffffffffffffffffffdFFFfdfffffffffffffffvlffffffffffffffffffffffffffffffffffffffffVfVffffffffffffffffffffffffffffffffffffffffddFFfFfffffffffffffffvlffffffffffffffffffffffffffffffffffffffffVfVfffffffffffffffffffffffffffffffffffffffdFFfdFFfffffffffffffffwlfffffffffffffffffffffffffffffffffffffffffeVfffffffffffffffffffffffffffffffffffffffddFfddFfffffffffffffffwfffffffffffffffeVfffffffffffffffffffffffffffffffffffffffdddfdddffffffffffffffvwfffffffffffffffVVffffffffffffffffffffffffffffffffffffffffddffddffffffffffffffwgfffffffffffffffVVVeffffffffffffffffffffffffffffffffffffffddffddfffffffffffffvwwfffffffffffffffVVeffffffffffffffffffffffffffffffffffffffFFFfFFFfffffffffffffvwwffffffffffffffffUfffffffffffffffffffffffffffffffffffffffddfdddfdffffffffffffwffffffffffffffffffeffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffϪffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffϦffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffjffjfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff݈oefjffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffoefffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffoUfffffffjffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff݈ofvffffffffjffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffwfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffVfVfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeVfffffffffffffffffffjffffffffffffffffffffffffffffffffffffffffffffffffffffffffeVfffffffffffffffffffjjfjfjffffffffffffffffffffffffffffffffffffffffffffVVffffffffffffffffffffjfffffffffffffffffffffffffffffffffffffffffVVVeffff"/ffffffffffffffffffffffjfffffffffffffffffffffffffffffffffffffffVVefffffUUUUUUUUUUUUUUUUUUUUUUUUUUUU/,""fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffUffffff]UUUUUUUUUUUUUUUUUUUUUUUUUUUU/""fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffff]UUUUUUUUUUUUUUUUUUUUUUUUUUUU/"""ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffUUUUUUUUUUUUUUUUUUUUUUUUUUUU""ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffFfffffffff/"fffffffffffffffffffffffffffffffffjfffffffffffffffffffffffffffffffff6CffffffffffffffffffffffffffffffffffffffffffjjffffffffffffffffffffffffffffFDlfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6C3dffffffffffffffffffffffffffffffffffffffffffffffjfjffffffffffffffffffffffffffffffffUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUffffffffffffffffffffffffffffffffffffffffjjfffffffffffffffffffffffffffffff]UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff]UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffjffjffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffjfffffffffffffwfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffwfffffffff"ffffffffffffffffffffffffffffffffffffffffffffffffffffffjfjffffffvgffffffffUUUUUUUUUUUUUUUUUUUUUUUUUU/"3ffffffffffffffffffffffffffffffffffffffffffffffffffffffffjjffffffwffffffff]UUUUUUUUUUUUUUUUUUUUUUUUUU/23ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffwffffffff]UUUUUUUUUUUUUUUUUUUUUUUUUU/3CffffffffdDffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffUUUUUUUUUUUUUUUUUUUUUUUUUUCffffFfFFFfFdffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffdddFfdffffffffffffffffffffffffffffffffffffffffffffffffffffffjfffffffffffffffffFFfdfdfffffwffffffffffffffffffffffffffwwffffffffffffffffffffjjfffffffffffffFFfdFfffffffwffffffffffffffffffffffffvgfwffffffffffffffffffffjfffff/fffffFFFfdfffffffvgfffffffffffffffffffffffvfvgfffffffffffffffffffffffjjfffffffffffffff/?fffffdFFFfdfffffffwfffffffffffffffffffffffvffwffffffffffffffffffffffffffmffffffffffffffffffffddFFfFfffffffwfffffffffffffffffffffffvffwfffffffffffffffffffffffffffmfffffffffffffff??fffffdfddFFfffffffffffffffffffffffffffffffwgffwgffffffffffffffffffffffffffffffffffffffffffffff?fffffFfdddFfffffffffffffffffffffffffffffffwgfwwgfffffffffffffffffffffffffffffffffffffFfdddffffffffffffffffffffffffffffffvwfwwwgfffffffffffffffffffffffffffffffffffffdFfddffffffffffffffffffffffffffffffwgwwwfvffffffffffffffffffffffffffffffffffffFfFfddfffffffffffffffffffffffffffffvwwwwffvffffffffffffffffffffffffffffffffffffFfdFFFfffffffffffffffffffffffffffffvwwgfffffffffffffffffffffffffffffffffffffffFdfdddfdffffffffffffffffffffffffffffwffffffffffffffffffffffffffffffffffffffs-- title: Pet Simulator (WIP) -- author: ArcharGelod -- desc: pet simulator -- site: archargelod.itch.io -- license: GPL v3 -- version: 0.9 -- script: lua -- saveid: strauss width = 240 height = 136 state = "start" t = 0 --ticks time_old = 0 click_timer = 0 --menu vars menu_width = 80 menu_height = 14 menu_vert_gap = 6 menu_strings = { "Continue", "New Pet", "Stats", "Exit" } menu_origin = { x = 120 - menu_width / 2, y = 136 - menu_height * ( #menu_strings + 1 ) - 20 } menu_selected = 1 --TODO choose pet from bank at random at new_game pet_bank={ {256}, --piglet { }, { }, } --pet variables pet_name = "Gustavo" pet_state = "wait" pet_mood = "good" pet_position = { x = 90, y = 50 } pet_temp_position = { x = 0, y = 0 } pet_flip = 0 pet_size = { w = 4, h = 4 } pet_type = 1 pet_sprite = pet_bank[ pet_type ][ 1 ] pet_birthdate = 0 pet_timer_wait = 0 pet_timer_walk = 0 pet_timer_walk_max = 1 --helper variables helper_state = "disabled" helper_position = { x = 15, y = 60 } helper_flip = 0 helper_size = { w = 2, h = 2 } helper_sprite = 480 helper_timer_wait = 0 helper_timer_walk = 0 helper_timer_walk_max = 1 hats = { 0, 192, 194, 196, 198, 200, 202, 204, 206 } backgrounds = { 2, 3, 4, 5 } stat = { exp = { cur = 4000, max = 100000, level = 0 }, health = { cur = 4000, max = 100000, level = 0 }, sleep = { cur = 4000, max = 100000, level = 0 }, hunger = { cur = 4000, max = 100000, level = 0 }, hygiene = { cur = 4000, max = 100000, level = 0 }, coins = { cur = 10000, max = 999999 }, info = { level = 1 }, bg = { level = 1 }, hat = { level = 1 }, helper = { level = 0 }, shop_help = { level = 1 } } floor_poops = 0 floor_coins = 0 floor_coins_max = 1000 shop_id = 1 shop_buttons = { { id = 1, x = 5 , y = 8 , w = 3, h = 2, scale = 1, sprite = 6, string = "SLP:", value = stat.sleep, price = 5000 }, { id = 2, x = 29, y = 8 , w = 3, h = 2, scale = 1, sprite = 6, string = "HNG:", value = stat.hunger, price = 7000 }, { id = 3, x = 53, y = 8 , w = 3, h = 2, scale = 1, sprite = 6, string = "HYG:", value = stat.hygiene, price = 7000 }, { id = 4, x = 5 , y = 20, w = 3, h = 2, scale = 1, sprite = 6, string = "---:", value = nil, price = 99999 }, { id = 5, x = 29, y = 20, w = 3, h = 2, scale = 1, sprite = 6, string = "---:", value = nil, price = 99999 }, { id = 6, x = 53, y = 20, w = 3, h = 2, scale = 1, sprite = 6, string = "---:", value = nil, price = 99999 }, { id = 7, x = 5 , y = 32, w = 3, h = 2, scale = 1, sprite = 6, string = "BG:", value = stat.bg, price = 1000 }, { id = 8, x = 29, y = 32, w = 3, h = 2, scale = 1, sprite = 6, string = "HAT:", value = stat.hat, price = 1000 }, { id = 9, x = 53, y = 32, w = 3, h = 2, scale = 1, sprite = 6, string = "HLP:", value = stat.helper, price = 50000 }, { id = 10, x = 5 , y = 46, w = 3, h = 2, scale = 1, sprite = 6, string = "FOOD", value = nil, price = 150 }, { id = 11, x = 29, y = 46, w = 3, h = 2, scale = 1, sprite = 6, string = "SEDAT", value = nil, price = 300 }, { id = 12, x = 53, y = 46, w = 3, h = 2, scale = 1, sprite = 6, string = "HEAL", value = nil, price = 2000 }, } shop_buy_button = { x = 7, y = 58, w = 3, h = 2, scale = 3, sprite = 6, pressed = false } function upgrade_sleep() stat.sleep.max = stat.sleep.max + 10000 stat.sleep.level = stat.sleep.level + 1 end function upgrade_hunger() stat.hunger.max = stat.hunger.max + 10000 stat.hunger.level = stat.hunger.level + 1 end function upgrade_hygiene() stat.hygiene.max = stat.hygiene.max + 10000 stat.hygiene.level = stat.hygiene.level + 1 end function upgrade_helper() stat.helper.level = 1 helper_state = "wait" shop_buttons[9].price = 0 end function button_food() if pet_state ~= "dead" then stat.hunger.cur = stat.hunger.cur + 10000 if stat.hunger.cur > stat.hunger.max and math.random(0,4) == 0 then pet_mood = "sick" end pet_state = "wait" end end function button_sedat() if pet_state ~= "dead" then pet_state = "sleep" end end function button_heal() if pet_state ~= "dead" then stat.health.cur = stat.health.cur + 50000 if math.random(0,4) ~= 0 then pet_mood = "good" end pet_state = "wait" end end function button_back() local previous = stat.bg.level while stat.bg.level == previous do stat.bg.level = math.random( 1, #backgrounds ) end end function button_hat() local previous = stat.hat.level while stat.hat.level == previous do stat.hat.level = math.random( 1, #hats ) end end function level_up_upgrade() local rnd_stat = math.random(1,3) if rnd_stat == 1 then upgrade_sleep() upgrade_hunger() elseif rnd_stat == 2 then upgrade_hunger() upgrade_hygiene() elseif rnd_stat == 3 then upgrade_hunger() end stat.exp.cur = 0 sfx(32, "C-4", -1, 3) end button_actions = { [ 1 ] = upgrade_sleep, [ 2 ] = upgrade_hunger, [ 3 ] = upgrade_hygiene, [ 4 ] = button_food , [ 5 ] = button_food , [ 6 ] = button_food , [ 7 ] = button_back , [ 8 ] = button_hat , [ 9 ] = upgrade_helper , [ 10 ] = button_food , [ 11 ] = button_sedat, [ 12 ] = button_heal } function shop_buy() local price = shop_buttons[ shop_id ].price if stat.coins.cur >= price then stat.coins.cur = stat.coins.cur - price sfx( 28 ) return true end sfx( 29 ) return false end display_stats = { { stat = stat.exp, x = 4, y = 90 , w = 8, h = 1, sprite = 86 }, { stat = stat.health, x = 4, y = 101, w = 8, h = 1, sprite = 86 }, { stat = stat.sleep, x = 4, y = 109, w = 8, h = 1, sprite = 86 }, { stat = stat.hunger, x = 4, y = 117, w = 8, h = 1, sprite = 86 }, { stat = stat.hygiene, x = 4, y = 125, w = 8, h = 1, sprite = 86 } } function draw_game_ui() --shop buttons for i, val in pairs( shop_buttons ) do local sprite = val.sprite local text_ht = val.y + 2 local text_col = 12 if val.price <= stat.coins.cur then sprite = 38 end if i == shop_id then sprite = sprite + 3 text_ht = val.y + 3 text_col = 13 end spr( sprite, val.x, val.y, 11, val.scale, 0, 0, val.w, val.h ) print( val.string, val.x + 2, text_ht, text_col, false, 1, true ) if val.value ~= nil then print( val.value.level, val.x + 17, text_ht, text_col, false, 1, true ) end end --buy button local b = shop_buy_button local price = shop_buttons[ shop_id ].price local sprite = b.sprite local text = price.." C" local text_ht = b.y + 9 local text_col = 12 if price <= stat.coins.cur then sprite = 38 end if b.pressed then sprite = sprite + 3 text_col = 13 text_ht = text_ht + 3 end spr( sprite, b.x, b.y, 11, b.scale, 0, 0, b.w, b.h ) print( text, b.x + 9, text_ht, text_col, false, 2, true ) --stats and icons local icons = { 99, 100, 101, 102, 103 } for i, val in pairs( display_stats ) do local wt = val.w * 8 - 2 local ratio = math.ceil( val.stat.cur * wt / val.stat.max ) local col = 5 if ratio < ( wt / 100 * 5 ) then col = 1 elseif ratio < ( wt / 100 * 15 ) then col = 2 elseif ratio < ( wt / 100 * 30 ) then col = 3 elseif ratio < ( wt / 100 * 50 ) then col = 4 elseif ratio < ( wt / 100 * 75 ) then col = 6 end rect( val.x + 1, val.y, wt, 7, 8 ) rect( val.x + 1, val.y, ratio, 7, col ) spr( val.sprite, val.x, val.y, 11, 1, 0, 0, val.w, val.h ) spr( icons[ i ], val.x + val.w * 8, val.y, 11 ) end --coins print( stat.coins.cur, width - #tostring(stat.coins.cur) * 6 - 11, 3, 4 ) spr(117, width - 10, 2, 11, 1, 0, 0) end poops = {} function spawn_poop(x, y) table.insert( poops, { x = x, y = y } ) end drops = {} function spawn_drops(x, y) local variety = { 1, 1, 1, 1, 5, 5, 5, 10, 20, 30, 100} local amount = variety[ math.random( 1, #variety ) ] + math.random( 0, 9 ) table.insert( drops, { amount = amount, x = x, y = y } ) floor_coins = floor_coins + amount end emotions = { ["mood"] = { sprite = 132, time = 0, alt = 0 }, ["poop"] = { sprite = 176, time = 0, alt = 0 }, ["health"] = { sprite = 100, time = 0, alt = 0 }, ["sleep"] = { sprite = 101, time = 0, alt = 0 }, ["hunger"] = { sprite = 102, time = 0, alt = 0 }, ["hygiene"] = { sprite = 103, time = 0, alt = 0 } } function update_emotion( type, alt ) local sprite = emotions[ type ].sprite if type == "mood" then if pet_mood == "sick" then sprite = 131 elseif pet_mood == "sad" then sprite = 132 else sprite = 133 end end emotions[ type ].alt = alt emotions[ type ].sprite = sprite emotions[ type ].time = 80 end function timer_emotions() for i, val in pairs( emotions ) do val.time = val.time - 1 end end function draw_emotions() local sprite_bubble = 118 local offset_bubble = 20 local offset_emo = 26 local flip = 0 if pet_position.x > ( width - 80 ) / 2 + 66 then offset_bubble = -4 offset_emo = -2 flip = 1 end for key, val in pairs( emotions ) do if val.time <= 0 then goto skip end if val.time <= 8 then sprite_bubble = 120 end spr( sprite_bubble, pet_position.x + offset_bubble, pet_position.y - 8, 11, 1, flip, 0, 2, 2 ) if val.time <= 4 then goto skip end spr( val.sprite, pet_position.x + offset_emo, pet_position.y - 6, 11 ) if val.alt == 1 then spr( 115, pet_position.x + offset_emo, pet_position.y - 6, 11 ) elseif val.alt == 2 and math.ceil( t / 10 ) % 2 ~= 0 then spr( 116, pet_position.x + offset_emo, pet_position.y - 6, 11 ) end if flip == 1 then offset_bubble = offset_bubble - 12 offset_emo = offset_emo - 12 else offset_bubble = offset_bubble + 12 offset_emo = offset_emo + 12 end ::skip:: end end particles = {} function spawn_particles( n, x, y, col ) for i = 0, n do local vel = { x = ( math.random( 0, 1 ) * 2 - 1 ) * math.random(), y = -1 * math.random() } local time = 30 + math.random( 0, 20 ) table.insert( particles, { x = x, y = y, vel = vel, col = col, sprite = sprite, time = time } ) end end function update_particles() for i = #particles, 1, -1 do local val = particles[ i ] local vel = val.vel val.x = val.x + vel.x val.y = val.y + vel.y val.time = val.time - 1 vel.y = vel.y + 0.05 if val.time <= 3 then val.col = 12 end if val.time <= 0 then table.remove( particles, i ) end end end function draw_particles() for key, val in pairs( particles ) do pix( val.x, val.y, val.col ) end end function get_stat_avg() local health_ratio = math.ceil( stat.health.cur * 100 / stat.health.max ) local sleep_ratio = math.ceil( stat.sleep.cur * 100 / stat.sleep.max ) local hunger_ratio = math.ceil( stat.hunger.cur * 100 / stat.hunger.max ) local hygiene_ratio = math.ceil( stat.hygiene.cur * 100 / stat.hygiene.max ) local health_worth = 5 local hunger_worth = 3 return (( health_ratio * health_worth ) + sleep_ratio + ( hunger_ratio * hunger_worth ) + hygiene_ratio ) / 10 end function new_game() pet_state = "wait" pet_mood = "good" stat.health.cur = math.random( 80, 100 ) / 100 * stat.health.max stat.sleep.cur = math.random( 50, 100 ) / 100 * stat.sleep.max stat.hunger.cur = math.random( 50, 100 ) / 100 * stat.hunger.max stat.hygiene.cur = math.random( 50, 100 ) / 100 * stat.hygiene.max stat.exp.cur = 0 pet_birthdate = tstamp() pmem( 1, tstamp() ) end function save_game() pmem( 2 , stat.health.cur ) pmem( 3 , stat.sleep.cur ) pmem( 4 , stat.hunger.cur ) pmem( 5 , stat.hygiene.cur ) pmem( 6 , stat.exp.cur ) pmem( 7 , stat.coins.cur ) pmem( 8 , tstamp() ) pmem( 9 , #poops ) pmem( 10, floor_coins ) pmem( 11, stat.hat.level ) pmem( 12, stat.bg.level ) pmem( 13 , stat.health.level ) pmem( 14 , stat.sleep.level ) pmem( 15 , stat.hunger.level ) pmem( 16 , stat.hygiene.level ) pmem( 17 , stat.helper.level ) if pet_state == "sleep" then pmem( 13, 1 ) else pmem( 13, 0 ) end end function load_game() load_stats() load_upgrades() --load poop and money drops for i = 1, floor_poops do spawn_poop( math.random( 80, width - 8 ), math.random( 0, height - 8 ) ) end local saved_floor_coins = pmem( 10 ) while floor_coins < saved_floor_coins - 50 do spawn_drops( math.random( 80, width - 8 ), math.random( 0, height - 8 ) ) end --simulate game for the time it was closed local time_elapsed = tstamp() - pmem( 8 ) --local time_elapsed = 3600 --debug value for testing for i = 1, time_elapsed do simulate( false ) stat_limits() end end function load_stats() pet_birthdate = pmem( 1 ) stat.health.cur = pmem( 2 ) stat.sleep.cur = pmem( 3 ) stat.hunger.cur = pmem( 4 ) stat.hygiene.cur = pmem( 5 ) stat.exp.cur = pmem( 6 ) stat.coins.cur = pmem( 7 ) floor_poops = pmem( 9 ) stat.hat.level = pmem( 11 ) stat.bg.level = pmem( 12 ) if pmem( 13 ) == 1 then pet_state = "sleep" end end function load_upgrades() local lv_health = pmem (13) for i = 1, lv_health do end local lv_sleep = pmem (14) for i = 1, lv_sleep do upgrade_sleep() end local lv_hunger = pmem (15) for i = 1, lv_hunger do upgrade_hunger() end local lv_hygiene = pmem (16) for i = 1, lv_hygiene do upgrade_hygiene() end local lv_helper = pmem (17) for i = 1, lv_helper do upgrade_helper() end end function simulate( is_realtime ) if pet_state == "dead" then return end if is_realtime == true then if math.random( 0, 30 ) == 0 and floor_coins < floor_coins_max then spawn_drops( math.random( 80, width - 16 ), math.random( 0, height - 16 ) ) end else if math.random( 0, 600 ) == 0 and floor_coins < floor_coins_max then spawn_drops( math.random( 80, width - 16 ), math.random( 0, height - 16 ) ) end if math.random( 0, 2000 ) == 0 then spawn_poop( math.random( 80, width - 8 ), math.random( 0, height - 8 ) ) end end --lose stats over time stat.sleep.cur = stat.sleep.cur - 1 stat.hunger.cur = stat.hunger.cur - 1 stat.hygiene.cur = stat.hygiene.cur - 1 * math.min( #poops, 5 ) --lose health if stat.sleep.cur < stat.sleep.max / 3 then stat.health.cur = stat.health.cur - 1 else stat.health.cur = stat.health.cur + 1 end if stat.hunger.cur < stat.hunger.max / 3 then stat.health.cur = stat.health.cur - 3 else stat.health.cur = stat.health.cur + 2 end if stat.hygiene.cur < stat.hygiene.max / 3 then stat.health.cur = stat.health.cur - 2 end --gain experience if stat.health.cur > stat.health.max / 2 then stat.exp.cur = stat.exp.cur + 1 end --trigger sleep start and end if stat.sleep.cur < stat.sleep.max / 20 and pet_state ~= "sleep" then if math.random(0, 100) == 0 then pet_state = "sleep" end end if stat.sleep.cur >= stat.sleep.max / 100 * 70 and pet_state == "sleep" then if math.random(0, 10000) == 0 then pet_state = "wait" end end if stat.sleep.cur <= 0 then pet_state = "sleep" end if stat.sleep.cur >= stat.sleep.max and pet_state == "sleep" then pet_state = "wait" end --trigger sickness local avg = get_stat_avg() if pet_mood == "sick" then if avg > 50 and math.random(0, 100) == 0 then pet_mood = "good" end elseif avg < 50 then pet_mood = "sad" if math.random(0, 100000) == 0 then pet_mood = "sick" end else pet_mood = "good" end --lose stats from sickness if pet_mood == "sick" then update_emotion( "mood" ) stat.sleep.cur = stat.sleep.cur - 2 stat.health.cur = stat.health.cur - 2 end --gain or lose stats from states if pet_state == "sleep" then update_emotion( "sleep", 0 ) stat.sleep.cur = stat.sleep.cur + 6 stat.health.cur = stat.health.cur + 1 end --trigger death if stat.health.cur < 0 then pet_state = "dead" end --emotion indicators if is_realtime then if stat.health.cur < stat.health.max / 3 then update_emotion( "health", 2 ) end if stat.sleep.cur < stat.sleep.max / 3 and pet_state ~= "sleep" then update_emotion( "sleep", 2 ) end if stat.hunger.cur < stat.hunger.max / 3 then update_emotion( "hunger", 2 ) end if stat.hygiene.cur < stat.hygiene.max / 3 then update_emotion( "hygiene", 2 ) end if stat.sleep.cur >= stat.sleep.max / 100 * 98 then update_emotion( "sleep", 1 ) end if stat.hunger.cur >= stat.hunger.max / 100 * 98 then update_emotion( "hunger", 1 ) end if stat.hygiene.cur >= stat.hygiene.max / 100 * 98 then update_emotion( "hygiene", 1 ) end end end function stat_limits() if stat.health.cur < 0 then stat.health.cur = 0 end if stat.health.cur > stat.health.max then stat.health.cur = stat.health.max end if stat.sleep.cur < 0 then stat.sleep.cur = 0 end if stat.sleep.cur > stat.sleep.max then stat.sleep.cur = stat.sleep.max end if stat.hunger.cur < 0 then stat.hunger.cur = 0 end if stat.hunger.cur > stat.hunger.max then stat.hunger.cur = stat.hunger.max end if stat.hygiene.cur < 0 then stat.hygiene.cur = 0 end if stat.hygiene.cur > stat.hygiene.max then stat.hygiene.cur = stat.hygiene.max end if stat.exp.cur > stat.exp.max then stat.exp.cur = stat.exp.max end end function draw_game() local bg = backgrounds[ stat.bg.level ] map( 30 * bg, 0, 30, 17, 0, 0 ) rectb( 0, 0, width, height, 12 ) end function draw_shadows() elli( helper_position.x + 7, helper_position.y + 14, 6, 1, 14 ) elli( pet_position.x + 16, pet_position.y + 30, 14, 4, 14 ) end function draw_helper() local sprite = helper_sprite if helper_state == "walk" then sprite = sprite + ( math.ceil( t / 10 ) % 2 * 2 ) end --body spr( sprite, helper_position.x, helper_position.y, 11, 1, helper_flip, 0, helper_size.w, helper_size.h ) end function draw_pet() local sprite = pet_sprite local eyes_sprites = { 240, 242 } local eyes_sprite = eyes_sprites[ 1 ] local hat_sprite = hats[ stat.hat.level ] local hat_ht = pet_position.y - 9 if pet_state == "walk" then sprite = sprite + ( math.ceil( t / 10 ) % 2 * 4 ) hat_ht = pet_position.y - 9 + ( math.ceil( t / 10 ) % 2 * 2 ) end if pet_state == "sleep" or pet_state == "dead" then sprite = sprite + 8 hat_ht = pet_position.y - 5 end --body spr( sprite, pet_position.x, pet_position.y, 11, 1, pet_flip, 0, pet_size.w, pet_size.h ) --eyes if t % 300 < 10 then eyes_sprite = eyes_sprites[ 2 ] end if pet_state == "sleep" or pet_state == "dead" then eyes_sprite = eyes_sprites[ 2 ] end spr( eyes_sprite, pet_position.x + 8, hat_ht + 17, 11, 1, pet_flip, 0, 2, 1 ) --hat if stat.hat.level ~= 1 then spr( hat_sprite, pet_position.x + 8, hat_ht, 11, 1, pet_flip, 0, 2, 2 ) end --name local mx, my, lmb = mouse() if mx > pet_position.x and mx < pet_position.x + pet_size.w * 8 and my > pet_position.y and my < pet_position.y + pet_size.h * 8 then print(pet_name, pet_position.x+3, pet_position.y+28, 12, false, 1, true) end end function draw_poops() local sprite = 176 for i, val in pairs(poops) do spr( sprite, val.x, val.y, 11 ) end end function draw_drops() for i, val in pairs(drops) do local sprite = 144 if val.amount > 19 then sprite = 146 end if val.amount > 99 then sprite = 148 end spr( sprite, val.x, val.y, 11, 1, 0, 0, 2, 2 ) end end function show_debug_values() local col = 13 local health_ratio = math.ceil( stat.health.cur * 100 / stat.health.max ).."%" local sleep_ratio = math.ceil( stat.sleep.cur * 100 / stat.sleep.max ).."%" local hunger_ratio = math.ceil( stat.hunger.cur * 100 / stat.hunger.max ).."%" local hygiene_ratio = math.ceil( stat.hygiene.cur * 100 / stat.hygiene.max ).."%" print( "HP:"..stat.health.cur.." SLP:"..stat.sleep.cur.." FLN:"..stat.hunger.cur.." HYG:"..stat.hygiene.cur, 1, 1, col ) print( "HLT:"..health_ratio, 80, 8, col ) print( "SLP:"..sleep_ratio, 80, 16, col ) print( "FLN:"..hunger_ratio, 80, 24, col ) print( "HYG:"..hygiene_ratio , 80, 32, col ) print( "State:"..pet_state, 80, 48, col ) print( "Mood:"..pet_mood, 80, 56, col ) end function draw_menu() cls( 15 ) map( 0, 0, 36, 23, 0 - t / 2 % 40, 0 - t / 2 % 48 ) for i = 1, #menu_strings do local x = menu_origin.x local y = menu_origin.y + i * 10 + i * menu_vert_gap local col1 = 13 local col2 = 14 local col3 = 14 if i == menu_selected then col2, col3 = 12, 12 end rect( x, y, menu_width, menu_height, col1 ) rectb( x, y, menu_width, menu_height, col2 ) print( menu_strings[i], x + menu_width / 2 - ( #menu_strings[i] * ( 5 + 1 ) / 2 ), y + menu_height / 2 - 3, col3, true ) end end function choose_menu() local sound_select="C-4" --gamepad if btnp( 1 ) then menu_selected = menu_selected + 1 sfx( 0, sound_select ) end if btnp( 0 ) then menu_selected = menu_selected - 1 sfx( 0, sound_select ) end if menu_selected > #menu_strings then menu_selected = 1 end if menu_selected < 1 then menu_selected = #menu_strings end if btnp( 4 ) or keyp(50) then if menu_selected == 1 then state = "game" load_game() end if menu_selected == 2 then state = "game" new_game() end if menu_selected == 3 then state = "stats" end if menu_selected == 4 then exit() end end --mouse local mx, my, lmb = mouse() for i = 1, #menu_strings do local x1, x2 = menu_origin.x, menu_origin.x + menu_width local y1 = menu_origin.y + i * 10 + i * menu_vert_gap local y2 = y1 + menu_height if ( mx >= x1 and mx <= x2 ) and ( my >= y1 and my <= y2 ) then if menu_selected ~= i then menu_selected = i sfx( 0, sound_select ) end if lmb and menu_selected == 1 then state = "game" load_game() end if lmb and menu_selected == 2 then state = "game" new_game() end if lmb and menu_selected == 3 then state = "stats" end if lmb and menu_selected == 4 then exit() end end end end function controls() local mx,my,lmb = mouse() local selection = nil if state ~= "game" then return end --pause game if btnp( 6 ) then save_game() poops = {} stat.exp.level = 0 stat.health.level = 0 stat.sleep.level = 0 stat.hunger.level = 0 stat.hygiene.level = 0 state = "menu" end --pet if mx > pet_position.x and mx < pet_position.x + pet_size.w * 8 and my > pet_position.y and my < pet_position.y + pet_size.h * 8 then poke(0x3FFB, 129) if pet_state ~= "dead" then update_emotion( "mood", 0 ) if lmb then click_pet( mx, my ) elseif click_timer ~= 0 then click_timer = 0 pet_state = "wait" sfx(63) end end selection = "pet" end if selection ~= nil then return end --shop buttons for i, val in pairs( shop_buttons ) do if mx > val.x and mx < val.x + ( val.w * 8 - 2 ) * val.scale and my > val.y and my < val.y + ( val.h * 8 - 7 ) * val.scale and lmb then selection = i if lmb then click_timer = click_timer + 1 else click_timer = 0 end if click_timer > 1 then return end shop_id = i end end if selection ~= nil then return end --buy button local val = shop_buy_button if mx > val.x and mx < val.x + ( val.w * 8 - 2 ) * 3 and my > val.y and my < val.y + ( val.h * 8 - 7 ) * 3 and lmb then selection = "shop_buy_button" val.pressed = true if lmb then click_timer = click_timer + 1 else click_timer = 0 end if click_timer > 1 then return end if not shop_buy() then return end local action = button_actions[ shop_id ] action() return else val.pressed = false end if selection ~= nil then return end if lmb then click_timer = click_timer + 1 else click_timer = 0 end if click_timer > 1 then return end --money drops for i = #drops, 1, -1 do local val = drops[ i ] if mx > val.x and mx < val.x + 16 and my > val.y and my < val.y + 16 then if lmb then click_drop( i, mx, my ) end selection = i break end end if selection ~= nil then return end --poops for i = #poops, 1, -1 do local val = poops[ i ] if mx > val.x and mx < val.x + 8 and my > val.y and my < val.y + 8 then if lmb then click_poop( i, mx, my ) end selection = i break end end end function click_pet( mx, my ) pet_state = "being_pet" stat.hygiene.cur = stat.hygiene.cur + 150 if stat.hygiene.max - stat.hygiene.cur > 100 then spawn_particles( 1, mx, my, 14 ) end click_timer = click_timer + 1 if click_timer > 20 then click_timer = 1 end if click_timer > 1 and click_timer < 20 then return end if stat.exp.cur == stat.exp.max then level_up_upgrade() end sfx( 16, "G-8" ) end function click_drop( index, x, y ) local amount = drops[ index ].amount stat.coins.cur = stat.coins.cur + amount floor_coins = floor_coins - amount spawn_particles( amount, x, y, 4 ) table.remove( drops, index ) sfx( 1, "C-7" ) end function click_poop( index, x, y ) stat.coins.cur = stat.coins.cur + math.random( 0, 5 ) spawn_particles( 10, x, y, 1 ) table.remove( poops, index ) sfx( 2, "D-7") end function ai_pet() if pet_state == "wait" then pet_timer_wait = pet_timer_wait - 1 if pet_timer_wait > 0 then return end if math.random( 0, 20 ) == 0 then spawn_poop( pet_position.x + pet_size.w * 4, pet_position.y + pet_size.h * 4 ) update_emotion( "poop", 0) end pet_new_position = { x = math.random(80, width - pet_size.w * 8), y = math.random(0, height - pet_size.h * 8) } if pet_new_position.x > pet_position.x then pet_flip = 1 else pet_flip = 0 end pet_state = "walk" pet_timer_walk = 0 pet_timer_walk_max = distance( pet_position.x, pet_position.y, pet_new_position.x, pet_new_position.y ) elseif pet_state == "walk" then if pet_timer_walk == 0 then pet_temp_position = { x = pet_position.x, y = pet_position.y } end if pet_position.x ~= pet_new_position.x then pet_position.x = pet_temp_position.x + ((pet_new_position.x - pet_temp_position.x) / pet_timer_walk_max * pet_timer_walk) pet_position.y = pet_temp_position.y + ((pet_new_position.y - pet_temp_position.y) / pet_timer_walk_max * pet_timer_walk) end pet_timer_walk = pet_timer_walk + 1 if pet_timer_walk <= pet_timer_walk_max then return end pet_timer_wait = math.random(100,400) pet_state = "wait" end end function ai_helper() if helper_state == "disabled" then return end if helper_state == "wait" then helper_timer_wait = helper_timer_wait - 1 if helper_timer_wait > 0 then return end helper_new_position, helper_target_poop = closest_poop( helper_position ) if helper_new_position.x > helper_position.x then helper_flip = 1 else helper_flip = 0 end helper_state = "walk" helper_timer_walk = 0 helper_timer_walk_max = distance( helper_position.x, helper_position.y, helper_new_position.x, helper_new_position.y ) elseif helper_state == "walk" then if helper_timer_walk == 0 then helper_temp_position = { x = helper_position.x, y = helper_position.y } end if helper_position.x ~= helper_new_position.x then helper_position.x = helper_temp_position.x + ((helper_new_position.x - helper_temp_position.x) / helper_timer_walk_max * helper_timer_walk) helper_position.y = helper_temp_position.y + ((helper_new_position.y - helper_temp_position.y) / helper_timer_walk_max * helper_timer_walk) end helper_timer_walk = helper_timer_walk + 1 if helper_timer_walk <= helper_timer_walk_max then return end if helper_target_poop ~= nil then click_poop( helper_target_poop, helper_position.x, helper_position.y ) helper_target_poop = nil end helper_timer_wait = math.random(100,200) helper_state = "wait" end end function closest_poop( pos ) local x, y = pos.x, pos.y local lowest = 1000 local index = nil for i, val in pairs(poops) do local d = distance( x, y, val.x, val.y ) if d < lowest then lowest = d index = i end end if index == nil then return { x = 15, y = 60 } end return poops[index], index end function distance( x1, y1, x2, y2 ) return math.abs(x1 - x2) + math.abs( y1 - y2 ) end --MAIN PROGRAM function TIC() if state == "start" then --music( 0 ) state = "menu" elseif state == "menu" then choose_menu() draw_menu() elseif state == "stats" then state = "menu" elseif state == "game" then if tstamp() == time_old then goto skip end time_old = tstamp() simulate( true ) stat_limits() save_game() ::skip:: controls() stat_limits() ai_pet() ai_helper() timer_emotions() update_particles() draw_game() draw_shadows() draw_poops() draw_drops() draw_helper() draw_pet() draw_emotions() draw_particles() draw_game_ui() end t = t + 1 --show_debug_values() end