Posted 02 June 2016 - 06:14 PM
How can I track when I run in to a piece of food or a can of soda?
// Made by Nolan Bukhart
init()
function init()
day = 1
food = 100
maxX = 58
maxY = 18
minX = 2
minY = 2
blackDisplay(day,food)
createGameBoard(maxX,maxY,minX,minY)
end
function createGameBoard(maxX,maxY,minX,minY)
//Images
playerimg = paintutils.loadImage("../Imgs/player")
enemy1img = paintutils.loadImage("../Imgs/enemy1")
enemy2img = paintutils.loadImage("../Imgs/enemy2")
foodimg = paintutils.loadImage("../Imgs/food")
sodaimg = paintutils.loadImage("../Imgs/soda")
//Setup the Colors
term.setBackgroundColor(colors.lime)
term.clear()
paintutils.drawBox(1,1,59,19,colors.gray)
numberOfSoda = Random.Range(1,3)
numberOfFood = Random.range(1,3)
sodaPlaced = 0
foodPlaced = 0
//Spawn Soda
while numberOfSoda => cansPlaced do
X = Random.Range(minX,maxX)
Y = Random.Range(minY,maxY)
paintutils.drawImage(X,Y,sodaimg)
cansPlaced = cansPlaced + 1
end
//Spawn Food
while numberOfFood => foodPlaced do
X = Random.Range(minX,maxX)
Y = Random.Range(minY,maxY)
paintutils.drawImage(X,Y,foodimg)
foodPlaced = foodPlaced + 1
end
//Spawn the Player
paintutils.drawImage(4,4,playerimg)
end
function blackDisplay(day, food)
term.setBackgroundColor(colors.black)
term.clear()
term.setCursorPos(24,9)
term.setTextColor(colors.white)
print("Day "..day)
term.setCursorPos(20,10)
print("Food left, "..food)
end