0,èÞ秬̿S,{%tE3H@ 0 then mY = 0 end if mY < -mYMax then mY = -mYMax end local scale = 1 for index, tLine in ipairs(lines) do scale =1 local offset = 0 local colour = 2 if index == 1 then scale = 2 offset = -10 colour = 3 end print(lines[index-1],2,((index+1)*8)+mY+offset,colour,0,scale) if manSprites[index]~=nil then spr(manSprites[index],0-manSprSize[index]*2+(6-manSprSize[index]),((index+1)*8)+mY+6,0,1,0,0,manSprSize[index],manSprSize[index]) end end --flag spr(448,95,480+mY,0,1,0,0,6,4) if (time()%500 > 250) then spr(11,220,120,0,1,0,0,1,1) spr(27,220,105,0,1,0,0,1,1) end if mY <= -10 then if btn(5) then gameState = gS_PlayGame end print("Press 'X' to Continue",105,130,1) end end function doPlayGame() if init ==false then initWallaby() initPlayer() init = true end cls(0) doGrass() drawWorld() doPlayer() movePlayerSpears() checkSpearCollision() doWallaby() drawWallaby() drawSpears() drawItems() end function throwSpear() local spear = {} if #spears <= MAX_PLAYER_SPEARS then -- ok to fire --local relSpawnPosition = -- player.position spear = { position = { x = player.position.x, y = player.position.y }, velocity = { speed = PLAYER_SPEAR_SPEED, direction = player.facing }, timer = 40 } table.insert(spears, spear) sfx(0,40,20,0,15,1) end end -- throw spear function movePlayerSpears() for index, spear in ipairs(spears) do --if spear.timer > 0 then if spear.velocity.direction == "east" then spear.position.x = spear.position.x + PLAYER_SPEAR_SPEED end if spear.velocity.direction == "west" then spear.position.x = spear.position.x - PLAYER_SPEAR_SPEED end if spear.velocity.direction == "north" then spear.position.y = spear.position.y - PLAYER_SPEAR_SPEED end if spear.velocity.direction == "south" then spear.position.y = spear.position.y + PLAYER_SPEAR_SPEED end -- end spear.timer = spear.timer - 1 if spear.timer <=0 then table.remove(spears,index) dropItemAt(i_Spear,spear.position.x,spear.position.y) end end -- for end function checkSpearCollision() for index, spear in ipairs(spears) do if distance(spear.position.x,spear.position.y,wallaby.position.x,wallaby.position.y)<4 then wallaby.state = wS_Die end end -- for end function drawSpears() for index, spear in ipairs(spears) do local spearSprite = 112 if spear.velocity.direction == "east" then spearSprite = 112 end if spear.velocity.direction == "west" then spearSprite = 113 end if spear.velocity.direction == "north" then spearSprite = 84 end if spear.velocity.direction == "south" then spearSprite = 100 end spr(spearSprite, spear.position.x-cx, spear.position.y-cy, 0) end -- for end -- function doCheckProgress() local px= player.position.x//8 local py = player.position.y//8 local cp = progressPoints[progress] if distance(cp.x,cp.y,px,py)<5 then progress = progress + 1 end end function dropItemAt(itemId,posX,posY) local item = {} if #items <= MAX_ITEMS then item = { id = itemId, position = { x = posX, y = posY }, timer = 4000 } table.insert(items, item) end end function drawItems() for index, item in ipairs(items) do local itemSprite = itemSprites[item.id] --if item.id == i_Yam then itemSprite = itemSprites[item.id] end --if item.id == i_Softwood then itemSprite = itemSprites[item.id] end --if item.id == i_Hardwood then itemSprite = itemSprites[item.id] end --if item.id == i_Boomerang then itemSprite = itemSprites[item.id] end --if item.id == i_Spear then itemSprite = itemSprites[item.id] end --if item.id == i_WBottle then itemSprite = itemSprites[item.id] end -- if item.id == i_SpinifexR then itemSprite = itemSprites[item.id] end --if item.id == i_WStomach then itemSprite = itemSprites[item.id] end spr(itemSprite, item.position.x-cx, item.position.y-cy, 0) end -- for end --i_Empty = 0 --i_Yam = 2 --i_Softwood = 4 --i_Hardwood = 6 --i_Boomerang = 8 --i_Spear = 10 --i_WBottle = 12 function scanline(row) if gameState == gS_ShowMap then if shake>0 then poke(0x3FF9,math.random(-shake//10,shake//10)) end end end function doShowMap() --getPlayerInput() if btn(5) then if (time()-timeSinceMapPressed)>500then timeSinceMapPressed = time() --memset(0x3FF9+1,0,2) gameState = gS_PlayGame end end if btn(4) then if (time()-timeSinceMapPressed)>500then timeSinceMapPressed = time() --memset(0x3FF9+1,0,2) gameState = gS_Manual end end if shake>0 then poke(0x3FF9+1,math.random(-shake//10,shake//10)) shake=shake-1 if shake==0 then memset(0x3FF9,0,2) end end cls(0) --print("PRESS ANY KEY TO GLITCH!",54,64) local m = mapDimensions[progress] map(210,-17,m.x,m.y,0,0) print("Press 'X' to Continue",105,120,1) print("Press 'Z' to view manual",105,130,1) -- spr(32,(playerShip.position.x)//8+12,(playerShip.position.y)//8+1,0) end function initPlayer() timeSinceMapPressed = time() timeSinceInteract = time() timeSinceRightItemUsed = time() timeSinceLeftItemUsed = time() timeSinceHandUsed= time() player.thirst = 0 player.hunger =0 player.position.x = sx player.position.y = sy local px= player.position.x local py = player.position.y cr(((px+4)//240)*240,((py+4)//136)*136) --player.currentRoom = getCurrentRoom(player.position.x,player.position.y) cx = player.currentRoom.x cy = player.currentRoom.y player.state = pS_Idle end function doPlayer() local playerDelta = distance( player.position.x,player.position.y, player.lastPosition.x,player.lastPosition.y) checkHandsUsed() doCheckProgress() getPlayerInput() addHungerThirst(player) drawPlayer(playerDelta) drawPlayerHUD() if player.thirst >50 then killPlayer() end end function doInteract() local px= player.position.x local py = player.position.y local grabbed = false if handsFull()==false then for index, item in ipairs(items) do if distance(item.position.x+4,item.position.y+4, player.position.x+4,player.position.y+4)<4 then addToHands(item.id) table.remove(items,index) grabbed = true end end if grabbed then return end if foodTiles:contains(mget((px+4)//8,(py+4)//8)) then mset((px+4)//8,(py+4)//8,6) addToHands(i_Yam) elseif mget((px+4)//8,(py+4)//8)==225 then mset((px+4)//8,(py+4)//8,6) addToHands(i_Softwood) elseif mget((px+4)//8,(py+4)//8)==99 then mset((px+4)//8,(py+4)//8,6) addToHands(i_Hardwood) elseif mget((px+4)//8,(py+4)//8)==70 then mset((px+4)//8,(py+4)//8,6) addToHands(i_SpinifexR) elseif mget((px+4)//8,(py+4)//8)==97 then mset((px+4)//8,(py+4)//8,6) addToHands(i_Boomerang) end else sfx(0,40,30,0,12) end end function addToHands(item) if player.lHand==i_Empty then player.lHand = item sfx(1,"B-6",30,0,12) return elseif player.rHand==i_Empty then player.rHand = item sfx(1,"B-6",30,0,12) return end end function useHand(side) if side =="left" then if player.lHand~=i_Empty then lHandRecentlyUsed = true timeSinceHandUsed = time() -- else --if time()-timeSinceInteract > 200 then sfx(2,"B-6",30,0,12) --end end end if side == "right" then if player.rHand~=i_Empty then rHandRecentlyUsed = true timeSinceHandUsed = time() --useItem(player.rHand) --player.rHand= i_Empty else --if time()-timeSinceInteract > 200 then sfx(2,"B-6",30,0,12) --end end end end function checkHandsUsed() if lHandRecentlyUsed and rHandRecentlyUsed and time()-timeSinceHandUsed < 100 then --craft local comboString = tostring(player.lHand)..","..tostring(player.rHand) local comboItem = getItemFromComboString(comboString) if comboItem ~=0 then player.rHand= i_Empty -- lHandRecentlyUsed = false player.lHand= comboItem -- rHandRecentlyUsed = false player.hunger = player.hunger + 2 player.thirst = player.thirst + 2 end lHandRecentlyUsed = false rHandRecentlyUsed = false end if lHandRecentlyUsed==true and time()-timeSinceHandUsed >100 then if btn(6) then --holding dropItemAt(player.lHand,player.position.x,player.position.y) player.lHand= i_Empty else--pressed if useableItems:contains(player.lHand) then useItem(player.lHand) player.lHand= i_Empty else sfx(2,"B-6",30,0,12) end end lHandRecentlyUsed = false end if rHandRecentlyUsed==true and time()-timeSinceHandUsed >100 then if btn(7) then --holding dropItemAt(player.rHand,player.position.x,player.position.y) player.rHand= i_Empty else --pressed if useableItems:contains(player.rHand) then useItem(player.rHand) player.rHand= i_Empty else sfx(2,"B-6",30,0,12) end end rHandRecentlyUsed = false end end function getItemFromComboString(comboString) if comboString == "4,6" or comboString=="6,4" then return i_Spear end if comboString == "14,16" or comboString=="16,14" then return i_WBottle end return 0 end function useItem(item) if item == i_Yam then sfx(1,"B-6",30,0,12) player.hunger = 0 end if item == i_Spear then sfx(1,"B-6",30,0,12) throwSpear() end end function handsFull() local result = false if player.lHand~=i_Empty and player.rHand~=i_Empty then result = true end return result end function killPlayer() initPlayer() end function drawWorld() map(cx//8,cy//8,31,18, -cx+((cx//8)*8),-cy+((cy//8)*8),0) end function cr(nx,ny) if nx==cx and ny==cy then return end cx=nx cy=ny end function drawPlayerHUD() local tval = (player.thirst)//6 if tval > 5 then tval = 5 end local tiddalik = tiddaliks[tval] if tval == 4 and (time()%500 > 250) then poke4(PALETTE_MAP * 2 + white, red) -- swap the colors end if tval == 5 and (time()%500 > 250) then poke4(PALETTE_MAP * 2 + white, red) -- swap the colors end -- draw the sprite spr(tiddalik,0,13.5*8,0,1,0,0,4,4) poke4(PALETTE_MAP * 2 + white, white) -- swap them back local hval = (player.hunger)//6 if hval > 3 then hval = 3 end local crocodile = crocodiles[hval] if hval == 3 and (time()%500 > 250) then poke4(PALETTE_MAP * 2 + white, red) -- swap the colors end --if hval == 5 and (time()%500 > 250) then -- poke4(PALETTE_MAP * 2 + white, red) -- swap the colors --end -- draw the sprite spr(crocodile,20,13*8,0,1,0,0,4,4) poke4(PALETTE_MAP * 2 + white, white) -- swap them back spr(384,200,14.4*8,0,1,0,0,2,2)--left hand print ("A",206,16.4*8,3) if player.lHand~=i_Empty then local iSprite = itemSprites[player.lHand] spr(iSprite,204,15*8,0,1,0,0,1,1) end spr(384,220,14.4*8,0,1,1,0,2,2)--right hand print ("S",226,16.4*8,3) if player.rHand~=i_Empty then local iSprite = itemSprites[player.rHand] spr(iSprite,224,15*8,0,1,0,0,1,1) end end function drawPlayer(playerDelta) if player.state == pS_Idle then spr(42,player.position.x-cx,player.position.y-cy,0,1,0,0) end if player.state == pS_Interacting then spr(26,player.position.x-cx,player.position.y-cy,0,1,0,0) end if player.state == pS_Running then if playerDelta >0 then if player.leftFoot==true then spr(41,player.position.x-cx,player.position.y-cy,0,1,0,0) -- player.leftFoot =false else spr(57,player.position.x-cx,player.position.y-cy,0,1,0,0) -- player.leftFoot =true end -- print("HELLO WORLD!",84,84) player.changeFoot = player.changeFoot-1 if player.changeFoot <=0 then if player.leftFoot==true then player.leftFoot=false else player.leftFoot = true end -- player.leftFoot = bool.reverse(leftFoot) player.changeFoot = 5 end else--end delta >0 spr(25,player.position.x-cx,player.position.y-cy,0,1,0,0) end end if player.state == pS_Interacting then end local px= player.position.x local py = player.position.y cr(((px+4)//240)*240,((py+4)//136)*136) end function getPlayerInput() local lpx = player.position.x local lpy = player.position.y local speed = 1.0 local hval = (player.hunger)//6 if hval == 0 then hval = 1 end speed = speed /(hval/2) if speed > 1.0 then speed = 1.0 end -- local tVal = .015 player.state = pS_Idle if btn(0) then if not playerCollisionTiles:contains(mget(lpx//8,(lpy-1)//8)) and not playerCollisionTiles:contains(mget((lpx+7)//8,(lpy-1)//8)) then player.position.y=player.position.y-speed --player.thirst = player.thirst +tVal player.state = pS_Running player.facing="north" end end if btn(1) then if not playerCollisionTiles:contains(mget(lpx//8,(lpy+8)//8)) and not playerCollisionTiles:contains(mget((lpx+7)//8,(lpy+8)//8)) then player.position.y=player.position.y+speed player.state = pS_Running player.facing="south" end end if btn(2) then if not playerCollisionTiles:contains(mget((lpx-1)//8,(lpy)//8)) and not playerCollisionTiles:contains(mget((lpx-1)//8,(lpy+7)//8)) then player.position.x=player.position.x-speed player.state = pS_Running player.facing="west" end end if btn(3) then if not playerCollisionTiles:contains(mget((lpx+8)//8,(lpy)//8)) and not playerCollisionTiles:contains(mget((lpx+8)//8,(lpy+7)//8)) then player.position.x=player.position.x+speed player.state = pS_Running player.facing="east" end end if btn(4) then if (time()-timeSinceInteract)>200 then doInteract() timeSinceInteract = time() player.state = pS_Interacting end end if btn(5) then if gameState ==gS_PlayGame then if (time()-timeSinceMapPressed)>500then timeSinceMapPressed = time() gameState = gS_ShowMap shake = 30 mj=0 end end end if btn(6) then if (time()-timeSinceLeftItemUsed)>200 then useHand("left") timeSinceLeftItemUsed = time() end end if btn(7) then if (time()-timeSinceRightItemUsed)>200 then useHand("right") timeSinceRightItemUsed = time() end end --btn(4) ="z" --btn(5) == "x" --btn(6)="a" --btn(7) ="s" end function initWallaby() wallaby = { state = wS_SearchFood, position = { x = 0, y = 0 }, velocity = { speed = 0, direction = 0 }, hunger = 20, thirst =30, fear = 0, radius = 10, sprites = {52,53,68,69,85,85}, sprToUse = 52, active = false, changeDirectionTimer = 0, eatTimer =60, waryTimer = 120, direction = 0, alerted = false, alertDistance = 50, waterMem = {14,8}, foodFound = false, spawnTimer = math.random(100, 200), dropped = false } end -- function initWallaby function doGrass() for key,value in pairs(longGrass) do local mx = 0 local my = 0 longGrass[key] = longGrass[key] - 1 if longGrass[key] <=0 then --local xVal = true local xVal=true local gs = key for word in string.gmatch(gs, '[^,%s]+') do if xVal ==true then mx= tonumber(word) xVal = false else my = tonumber(word) end end mset(mx,my,54) longGrass[key]=nil --print(mx..","..my,10,60,12) end end end-- end doGrass function doWallaby() if not wallaby.active then wallaby.spawnTimer = wallaby.spawnTimer - 1 if wallaby.spawnTimer <= 0 then spawnWallaby() end end -- if not wallaby.active if wallaby.state == wS_SearchFood then doSearchFood() end if wallaby.state == wS_SearchWater then doSearchWater() end if wallaby.state == wS_Eat then doEat() end if wallaby.state == wS_Drink then doDrink() end if wallaby.state == wS_Flee then doFlee() end if wallaby.state == wS_Wary then doWary() end if wallaby.state == wS_Die then doDie() end --if wallaby.state == wS_Reset then -- doReset() end checkIfReset() wallaby.position = moveSpriteByVelocity(wallaby) addHungerThirst(wallaby) end -- doWallaby function checkIfReset() local px = player.position.x local py = player.position.y local wx = wallaby.position.x local wy = wallaby.position.y if distance(px,py,wx,wy)>200 and distance(100,80,px,py) > 200 then doReset() end end function doReset() spawnWallaby() end function addHungerThirst(object) local tVal = .004 -- thirst value local hVal = .002 -- hunger value local hasBottle = false local ox = object.position.x local oy = object.position.y if waterTiles:contains(mget((ox+4)//8,(oy+4)//8)) then object.thirst = object.thirst -1 hVal = 0 if object.thirst<0 then object.thirst = 0 end end if desertTiles:contains(mget((ox+4)//8,(oy+4)//8)) then hVal = .006 tVal = .1 end if object.state == pS_Running then tVal = tVal+.02 hVal = hVal+.005 end if player.lHand == 12 then hasBottle = true end if player.rHand == 12 then hasBottle = true end if hasBottle==true then tVal = tVal//3 end object.hunger = object.hunger + hVal object.thirst = object.thirst + tVal end -- add hunger thirst function doSearchFood() -- state 2 wallabyCheckPredator() wallaby.velocity.speed = .3 if mget(wallaby.position.x//8, wallaby.position.y//8)==54 then--LgGrass wallaby.state = wS_Eat end --if mget if wallaby.hunger >120 then if wallaby.foodFound ==false then --find average grass location local tX = 0 local tY = 0 local tCount = 0 local wX = wallaby.position.x local wY = wallaby.position.y local rX =0 local rY =0 for sX=wX//8-5,wX//8+5 do for sY=wY//8-5,wY//8+5 do if mget(sX,sY)==54 then tX = tX + sX tY = tY + sY tCount = tCount + 1 --mset(sX,sY,80) end -- mget end --for sY end --for sX if tCount ==0 then tCount =1 end rX = (tX//tCount) rY = (tY//tCount) rX = rX + math.random(-1,1) rY =rY + math.random(-1,1) --mset(rX,rY,96) setObjectDirection(wallaby,rX,rY) wallaby.foodFound=true end -- end foodFound end -- hunger > 300 wallaby.changeDirectionTimer = wallaby.changeDirectionTimer - 1 if wallaby.changeDirectionTimer <= 0 then wallaby.foodFound = false wallaby.changeDirectionTimer = 300 end -- if change direction end -- end doSearchFood function doSearchWater() wallaby.velocity.speed = .3 wallabyCheckPredator() if mget(wallaby.position.x//8, wallaby.position.y//8)==66 then--Water wallaby.state = wS_Drink end --if mget -- setObjectDirection(wallaby, wallaby.waterMem[1], wallaby.waterMem[2]) end--end doSearchWater function doFlee() if player.position.x< wallaby.position.x then wallaby.velocity.direction = 0 wallaby.velocity.speed = 2 end if player.position.x> wallaby.position.x then wallaby.velocity.direction = 1 wallaby.velocity.speed = 2 end if distance(wallaby.position.x, wallaby.position.y, player.position.x, player.position.y)> wallaby.alertDistance +10 then wallaby.state = wS_Wary wallaby.velocity.speed = 0 end end--end doFlee function doEat() wallaby.velocity.speed = 0 wallaby.eatTimer= wallaby.eatTimer -1 if wallaby.eatTimer <=0 then wallaby.eatTimer = 60 mset(wallaby.position.x//8, wallaby.position.y//8,6) wallaby.state = wS_Wary wallaby.velocity.direction = math.random(0,3) wallaby.velocity.speed = .2 wallaby.hunger = wallaby.hunger -20 longGrass[tostring(wallaby.position.x//8)..","..tostring(wallaby.position.y//8)]=2600+math.random(0,3000) end -- end if eatTimer <=0 end--end doEat function doDrink() wallaby.eatTimer= wallaby.eatTimer -1 wallaby.foodFound =false if wallaby.eatTimer <=0 then wallaby.eatTimer = 60 wallaby.thirst = 0 wallaby.hunger = wallaby.hunger//2 wallaby.state = wS_Wary wallaby.velocity.direction = math.random(0,3) wallaby.velocity.speed = .2 end -- end if eatTimer <=0 end function doDie() wallaby.velocity.speed = 0 if wallaby.dropped ==false then dropItemAt(16,wallaby.position.x+2,wallaby.position.y+2) wallaby.dropped= true end end function doWary() wallaby.velocity.speed = 0 wallaby.waryTimer =wallaby.waryTimer -1 if wallaby.waryTimer <=0 then if getWallabyPriority() == "hunger" then wallaby.state = wS_SearchFood wallaby.foodFound=false end if getWallabyPriority() == "thirst" then wallaby.state = wS_SearchWater end if getWallabyPriority() == "fear" then wallaby.state = wS_Flee end wallaby.waryTimer = 120 end wallabyCheckPredator() end function getWallabyPriority() if wallaby.thirst > wallaby.hunger and wallaby.thirst > wallaby.fear then if wallaby.thirst > 200 then return "thirst" else return "hunger" end elseif wallaby.fear > wallaby.thirst and wallaby.fear> wallaby.hunger then return "fear" else return "hunger" end end function wallabyCheckPredator() local alertDist = wallaby.alertDistance if wallaby.state == wS_EatDrink then alertDist = wallaby.alertDistance//2 end if distance(wallaby.position.x, wallaby.position.y, player.position.x, player.position.y)< alertDist then wallaby.state = wS_Flee end end function distance ( x1, y1, x2, y2 ) local dx = x1 - x2 local dy = y1 - y2 return math.sqrt ( dx * dx + dy * dy ) end function awayFrom2 ( x1, y1, x2, y2 ) local dx = x1 - x2 local dy = y1 - y2 return { dx, dy } end function drawWallaby() if wallaby.active then --drawVectorShape(wallaby) if wallaby.state == wS_SearchFood or wallaby.state == wS_SearchWater or wallaby.state == wS_Wary or wallaby.state == wS_Flee then if wallaby.velocity.direction == 0 then spToDraw =wallaby.sprites[1] -- spr(wallaby.sprites[1],wallaby.position.x,wallaby.position.y) end if wallaby.velocity.direction == 1 then spToDraw =wallaby.sprites[2] -- spr(wallaby.sprites[2],wallaby.position.x,wallaby.position.y) end end--end search food if wallaby.state == wS_Eat then if wallaby.velocity.direction >1 then wallaby.velocity.direction = math.random(0,1) end if wallaby.velocity.direction == 0 then spToDraw =wallaby.sprites[3] -- spr(wallaby.sprites[1],wallaby.position.x,wallaby.position.y) end if wallaby.velocity.direction == 1 then spToDraw =wallaby.sprites[4] -- spr(wallaby.sprites[2],wallaby.position.x,wallaby.position.y) end wallaby.velocity.speed = 0 end -- end state eat if wallaby.state == wS_Die then spToDraw = 85 end spr(spToDraw,wallaby.position.x-cx, wallaby.position.y-cy,0) -- print("WHunger:"..wallaby.hunger,5,5,12) -- print("WThirst:"..wallaby.thirst,5,15,12) -- print("STATE:"..wallaby.state,5,25,12) end -- if eat drink end -- drawWallaby function spawnWallaby() local direction =0-- math.random(0,3) -- 0 = left to right -- 1 = right to left local startX = 100 if direction == 1 then startX = SCREEN_MAX_X - 1 end wallaby.position = { x = startX, y = math.random(0,SCREEN_MAX_Y) } wallaby.velocity = { speed = .3, direction = 0 } wallaby.rotation = 0 wallaby.active = true wallaby.spawnTimer = 0 wallaby.direction = direction wallaby.changeDirectionTimer = 0 wallaby.sprites = {52,53,68,69} wallaby.state = wS_Wary wallaby.sprToUse = 52 wallaby.dropped = false end -- spawnWallaby function moveSpriteByVelocity(object) local sp = object.velocity.speed if object.velocity.direction == 0 then object.position.x = object.position.x+sp end if object.velocity.direction == 1 then object.position.x = object.position.x-sp end if object.velocity.direction == 2 then object.position.y = object.position.y+sp end if object.velocity.direction == 3 then object.position.y = object.position.y-sp end return object.position end function setObjectDirection(object,dirX,dirY) if math.abs((object.position.x//8)-dirX)>math.abs((object.position.y//8)-dirY) then if object.position.x//8 dirX then object.velocity.direction = 1 end end if math.abs((object.position.x//8)-dirX) dirY then object.velocity.direction = 3 end end if object.position.x//8 == dirX and object.position.y//8 == dirY then -- -- object.velocity.direction = math.random(0,3) if object.state == 2 then object.eatTimer = object.eatTimer - 1 if object.eatTimer <=0 then --local newDir = math.random(0,3) object.eatTimer = 60 --object.velocity.direction = newDir end -- object.thirst = object.thirst + 2 --local newDir = math.random(0,3) --for i = 1,60 do -- if newDir ~= object.velocity.direction then -- newDir = math.random(0,3) -- end --end -- object.state = wS_Wary end end end -- print(object.velocity.direction,50,50,12) end -- end setObjectDirection function distance( x1, y1, x2, y2 ) return math.sqrt( (x2-x1)^2 + (y2-y1)^2 ) end