counts = Timer.new()
counts:start()



while place == "plutanium___" do

CurrentTime = counts:time()
pad = Controls.read()
screen:clear()
screen:blit(BG[9].x, BG[9].y, BG[9].pic)
screen:blit(BG[10].x, BG[10].y, BG[10].pic)
screen:blit(BG[7].x, BG[7].y, BG[7].pic)
screen:blit(240, 135, image[player_direction])

if pad:l() and oldpad:l() ~= pad:l() then
dofile("./start_pressed.lua")
end
if pad:left() then
	
	moveleft()
	Player[1].x = Player[1].x +1
	chars[1].x = chars[1].x +1
	Player[1].x = Player[1].x +1
      chars[1].x = chars[1].x +1
      for move_slides = 1, 10 do
       BG[move_slides].x = BG[move_slides].x +1
    
      end
--pidgey house
if BG[9].x == 77 and BG[9].y >= -43 and BG[9].y<= 53 then
leftmoveboundry()
end
--upper left house
if BG[9].x == 99 and BG[9].y >= 78 then
leftmoveboundry()
end
--water spout 
if BG[9].x == -48 and BG[9].y >= -22 and BG[9].y <= 39 then
leftmoveboundry()
end

--pokemon center
if BG[9].x == -326 and BG[9].y >= 80 then
leftmoveboundry()
end
--flower container (middle)
if BG[9].x == -242 and BG[9].y >= 9 then
leftmoveboundry()
end
-- wooden house
if BG[9].x == -432 and BG[9].y >= -12 and BG[9].y <= 86 then
leftmoveboundry()
end
--flower container (right)
if BG[9].x == -472 and BG[9].y <= -61 then
leftmoveboundry()
end
--lady
if BG[9].x == -589 and BG[9].y >= 8 and BG[9].y <= 44 then
leftmoveboundry()
end
--kid/skitty
if BG[1].x == -631 and BG[9].y >= 8 and BG[9].y <= 63 then
leftmoveboundry()
end
if BG[9].x == 239 then

place = "route1______"
dofile("./Route1.lua")
end
end
if pad:right() then
	moveright()	
	Player[1].x = Player[1].x -1
      chars[1].x = chars[1].x -1
      for move_slides = 1, 10 do
       BG[move_slides].x = BG[move_slides].x -1
      end  
--pidgey house
if BG[9].x ==187 and BG[9].y >= -43 and BG[9].y<= 53 then
rightmoveboundry()
end
-- upper left house
if BG[9].x == 198 and BG[9].y >= 78 then
rightmoveboundry()
end
-- water spout
if BG[9].x == 17 and BG[9].y >= -22 and BG[9].y <= 39 then
rightmoveboundry()
end
-- pokemon center
if BG[9].x == -128 and BG[9].y >= 80 then
rightmoveboundry()
end
-- flower container(middle)
if BG[9].x == -194 and BG[9].y >= 9 then
rightmoveboundry()
end
-- wooden house
if BG[9].x == -335 and BG[9].y >= -12 and BG[9].y <= 86 then
rightmoveboundry()
end
--flower container(right)
if BG[9].x == -374 and BG[9].y <= -61 then
rightmoveboundry()
end
-- right house
if BG[9].x == -636 and BG[9].y >= -91 and BG[9].y <= -11 then
rightmoveboundry()
end
-- flower pots
if BG[9].x == -591 and BG[9].y >= -91 and BG[9].y <= -59 then
rightmoveboundry()
end
-- lady
if BG[9].x == -553 and BG[9].y >= 8 and BG[9].y <= 44 then
rightmoveboundry()
end
-- kid/skitty
if BG[9].x == -595 and BG[9].y >= 8 and BG[9].y <= 63 then
rightmoveboundry()
end


end

if pad:up() then
	moveup()
	Player[1].y = Player[1].y +1
   chars[1].y = chars[1].y +1
   
   for move_slides = 1, 10 do
    BG[move_slides].y = BG[move_slides].y +1 
   end
--pidgey house
if BG[9].y == -43 and BG[9].x >=77 and BG[9].x <= 187 then
upmoveboundry()
end
--upper left house
if BG[9].y == 78 and BG[9].x >= 99 and BG[9].x <= 198 then
upmoveboundry()
end
--water spout
if BG[9].y == -22 and BG[9].x >= -48 and BG[9].x <= 17 then
upmoveboundry()
end
-- pokemon center
if BG[9].y == 80 and BG[9].x >= -326 and BG[9].x <= -128 then
upmoveboundry()
end
-- flower container(middle)
if BG[9].y == 9 and BG[9].x >= -242 and BG[9].x <= -194 then
upmoveboundry()
end
--wooden house
if BG[9].y == -12 and BG[9].x >= -432 and BG[9].x <= -335 then
upmoveboundry()
end
-- right house
if BG[9].y == -91 and BG[9].x >= -719 and BG[9].x <= -636 then
upmoveboundry()
end
--flower pots
if BG[9].y == -91 and BG[9].x <= -591 and BG[9].x >= 719 then
upmoveboundry()
end
--lady
if BG[9].y == 8 and BG[9].x >= -589 and BG[9].x <= -553 then
upmoveboundry()

end
--kid/skitty
if BG[9].y == 8 and BG[9].x >= -631 and BG[9].x <= -595 then
upmoveboundry()
end
if BG[9].x <=-185 and BG[9].x >=-194 and BG[9].y == 79 then
place = "Pcenter_____"
dofile("./pokemoncenter.lua")
end
end
if pad:down() then
	movedown()	
	chars[1].y = chars[1].y -1
   for move_slides = 1, 10 do
    BG[move_slides].y = BG[move_slides].y -1
    Player[1].y = Player[1].y -1
    
   end


-- pidgey house
if BG[9].y == 53 and BG[9].x >=77 and BG[9].x <= 187 then
downmoveboundry()
end
-- water spout
if BG[9].y == 39 and BG[9].x >= -48 and BG[9].x <= 17 then
downmoveboundry()
end
-- wooden house
if BG[9].y == 86 and BG[9].x >= -432 and BG[9].x <= -335 then
downmoveboundry()
end
--right house
if BG[9].y == -11 and BG[9].x >= -719 and BG[9].x <= -636 then
downmoveboundry()
end
--flower container (right)
if BG[9].y == -61 and BG[9].x >= -472 and BG[9].x <=-374 then
downmoveboundry()
end
--flower pots
if BG[9].y == -59 and BG[9].x <= -591 and BG[9].x >= 719 then
downmoveboundry()
end
--lady
if BG[9].y == 44 and BG[9].x >= -589 and BG[9].x <= -553 then
downmoveboundry()
end
--kid/skitty
if BG[9].y == 63 and BG[9].x >= -631 and BG[9].x <= -595 then
downmoveboundry()
end


end


screen:print(100,210, BG[9].x.. "  " .. BG[9].y, blue)

screen.waitVblankStart()
screen.flip()
oldpad = pad
end