gender = 0
blue = Color.new(56,172,236)
System.usbDiskModeActivate()
white = Color.new(0,0,0)
textbox = Image.load("talkbox.png")
lawnguy = 0
houselasy = 0
bottomhousekid = 0
pikachu = 0
neptarentoend = 0
function moveup()
	counter = counter +1
	if counter >=20 or counter <=0 then
		counter = 0
	end
	if counter == 5 then
		player_direction = 5
	end
	if counter == 10 then
		player_direction = 4
	end
	if counter == 15 then
		player_direction = 6
	end
end
function movedown()
	counter = counter +1
	if counter >=25 or counter <=0 then
		counter = 0
	end
	if counter == 5 then
		player_direction = 2
	end
	if counter == 10 then
		player_direction = 1
	end
	if counter == 15 then
		player_direction = 3
	end

end
function moveright()
	counter = counter +1
	if counter >=20 or counter <=0 then
		counter = 0
	end
	if counter == 5 then
		player_direction = 11
	end
	if counter == 10 then
		player_direction = 10
	end
	if counter == 15 then
		player_direction = 12
	end
end
function moveleft()
	counter = counter +1
	if counter >=20 or counter <=0 then
		counter = 0
	end
	if counter == 5 then
		player_direction = 8
	end
	if counter == 10 then
		player_direction = 7
	end
	if counter == 15 then
		player_direction = 9
	end
end
function rightmoveboundry()
	Player[1].x = Player[1].x +1
   	chars[1].x = chars[1].x +1
	for bgs = 1, 10 do
	BG[bgs].x = BG[bgs].x +1
	end
	
end
function leftmoveboundry()
	Player[1].x = Player[1].x -1
   	chars[1].x = chars[1].x -1
	for bgs = 1, 10 do
	BG[bgs].x = BG[bgs].x -1
	end
	
end
function upmoveboundry()
Player[1].y = Player[1].y -1
	chars[1].y = chars[1].y -1
	for bgs = 1, 10 do
		BG[bgs].y = BG[bgs].y -1
	end
	
end
function downmoveboundry()
Player[1].y = Player[1].y +1
	chars[1].y = chars[1].y +1
	for bgs = 1, 10 do
	BG[bgs].y = BG[bgs].y +1
	end
	
end

BG = {}
BG[1] = {x = 0, y = 0, pic = Image.load("./towns/neptarento/Neptarento-1.png")}
BG[2] = {x = 0, y = 270, pic = Image.load("./towns/neptarento/Neptarento-2.png")}
BG[3] = {x = 480, y = 0, pic = Image.load("./towns/neptarento/Neptarento-3.png")}
BG[4] = {x = 480, y = 270, pic = Image.load("./towns/neptarento/neptarento-4.png")}
BG[5] = {x = 0, y = 0, pic = Image.load("./towns/neptarento/starterbottom.png")}
BG[6] = {x = 0, y = 0, pic = Image.load("./towns/neptarento/startershousebedroom.png")}
BG[7] = {x = 960, y = 350, pic = Image.load("./routes/Route1.png")}
BG[8] = {x = 0, y = 0, pic = Image.load("./towns/neptarento/neptarentobottomhouse.png")}
BG[9] = {x = 1440, y = 288, pic = Image.load("./towns/plutanium/plutanium.PNG")}
BG[10] = {x = 1920, y = 288, pic = Image.load("./towns/plutanium/plutaniumsection2.PNG")}
BG[11] = {X = 0, y = o, pic = Image.load("./towns/plutanium/Pcenter.png")}
BG[12] = {x = 0, y = 0, pic = Image.load("./towns/plutanium/pokemart.png")}
pichuguy = 0
pichu = 0
pokemon = {}
pokemon[1] ={ lv = 0, name = "n/a", exp = 0, STR = 0,AGI = 0, DEF = 0, SPA = 0,SPD = 0, MAX_HP= 0, C_HP = 0, pic = Image.load("none.png"), picB = Image.load("none.png")}
pokemon[2] = { lv = 0, name = "n/a", exp = 0, STR = 0,AGI= 0,  DEF = 0, SPA = 0,SPD = 0, MAX_HP= 0, C_HP = 0, pic = Image.load("none.png"), picB = Image.load("none.png")}
pokemon[3] ={ lv = 0, name = "n/a", exp = 0, STR = 0, AGI= 0, DEF = 0, SPA = 0,SPD = 0, MAX_HP= 0, C_HP = 0, pic = Image.load("none.png"), picB = Image.load("none.png")}
pokemon[4] ={ lv = 0, name = "n/a", exp = 0, STR = 0, AGI= 0, DEF = 0, SPA = 0,SPD = 0, MAX_HP= 0, C_HP = 0, pic = Image.load("none.png"), picB = Image.load("none.png")}
pokemon[5] ={ lv = 0, name = "n/a", exp = 0, STR = 0, AGI= 0, DEF = 0, SPA = 0,SPD = 0, MAX_HP= 0, C_HP = 0, pic = Image.load("none.png"), picB = Image.load("none.png")}
pokemon[6] ={ lv = 0, name = "n/a", exp = 0, STR = 0, AGI= 0, DEF = 0, SPA = 0,SPD = 0, MAX_HP= 0, C_HP = 0, pic = Image.load("none.png"), picB = Image.load("none.png")}
p_attacks = {}
p_attacks[101] = {name = "n/a",attribute = "n/a", power = 0, accuracy = 0}
p_attacks[102] = {name = "n/a",attribute = "n/a", power = 0, accuracy = 0}
p_attacks[103] = {name = "n/a",attribute = "n/a", power = 0, accuracy = 0}
p_attacks[104] = {name = "n/a",attribute = "n/a", power = 0, accuracy = 0}
p_attacks[201] = {name = "n/a",attribute = "n/a", power = 0, accuracy = 0}
p_attacks[202] = {name = "n/a",attribute = "n/a", power = 0, accuracy = 0}
p_attacks[203] = {name = "n/a",attribute = "n/a", power = 0, accuracy = 0}
p_attacks[204] = {name = "n/a",attribute = "n/a", power = 0, accuracy = 0}

chars = {}
items = {}
items[1] = {x = 199, y = 27, name = "POTION", amount = 1}
items[2] = {x = 199, y = 50, name = "SUPER POTION", amount= 0}
pokeballs = {}
pokeballs[1] = { x = 199, y = 27, name = "POKEBALL", amount = 1}
pokeballs[2] = { x = 199, y = 50, name = "GREAT BALL", amount = 0}
text_button = Image.load("text_arrow.png")
chars[1] = {x = 468, y = 300, pic = Image.load("./characters/OAK.png")}
oakx = 468
oaky = 300
oaktalk=4 
p =0
selector = Image.load("selector.png")
playerwidth = 14
playerheight = 21
Player= {}
Player[1]= {x =0, y = 0}
playerx = 108
playery = 49
dofile("./loaddata.lua")
if gender == "female" then
image = {}
image[1] = Image.load("./characters/female sprites/char1F-fstand.png")
image[2] = Image.load("./characters/female sprites/char1F-fright.png")
image[3] = Image.load("./characters/female sprites/char1F-fleft.png")

image[4] = Image.load("./characters/female sprites/char1F-bstand.png")
image[5] = Image.load("./characters/female sprites/char1F-bright.png")
image[6] = Image.load("./characters/female sprites/char1F-bleft.png")


image[7] = Image.load("./characters/female sprites/char1F-lstand.png")
image[8] = Image.load("./characters/female sprites/char1F-lright.png")
image[9] = Image.load("./characters/female sprites/char1F-lleft.png")

image[10] = Image.load("./characters/female sprites/char1F-rstand.png")
image[11] = Image.load("./characters/female sprites/char1F-rright.png")
image[12] = Image.load("./characters/female sprites/char1F-rleft.png")
end
if gender == "male" then
image = {}
image[1] = Image.load("./characters/male sprites/char1M-fstand.png")
image[2] = Image.load("./characters/male sprites/char1M-fright.png")
image[3] = Image.load("./characters/male sprites/char1M-fleft.png")

image[4] = Image.load("./characters/male sprites/char1M-bstand.png")
image[5] = Image.load("./characters/male sprites/char1M-bright.png")
image[6] = Image.load("./characters/male sprites/char1M-bleft.png")


image[7] = Image.load("./characters/male sprites/char1M-lstand.png")
image[8] = Image.load("./characters/male sprites/char1M-lright.png")
image[9] = Image.load("./characters/male sprites/char1M-lleft.png")

image[10] = Image.load("./characters/male sprites/char1M-rstand.png")
image[11] = Image.load("./characters/male sprites/char1M-rright.png")
image[12] = Image.load("./characters/male sprites/char1M-rleft.png")
end

y = 0
x = 3
choice_box = Image.load("choicebox.png")
counter = 0
counts = Timer.new()

selecty = 188
r = 0
run = 0
ani = 0
q = 0

i = 0
player_direction = 1
xy = 0
counts:start()
while true do
if place == "plutanium___" then
dofile("./plutanium.lua")

end
if place == "route1______" then
dofile("./Route1.lua")
end
 CurrentTime = counts:time()
 screen:clear()
 pad = Controls.read()


if place == "hometop_____" and i ==0 then
screen:blit(BG[6].x, BG[6].y, BG[6].pic)
screen:blit(playerx, playery, image[player_direction])

if pad:left() and playerx>=-1 then
    	moveleft()
    	playerx = playerx -1   
	if playerx == 74 and playery>= 32 and playery <=76 then
		playerx = playerx +1
	end
	if playerx == 33 and playery <=	35 and playery >= -1 then
		playerx = playerx +1
	end
	if playerx ==139 and playery >=-1 and playery <= 21 then
		playerx = playerx +1
	end
	if playerx == 210 and playery >= 26 and playery <= 69 then
		playerx = playerx +1
	end
	if playerx == 262 and playery >= -1 and playery <= 18 then
		playerx = playerx +1
	end
end
	
if pad:right() and playerx<=263 then
	moveright()
	
 	playerx = playerx +1
 	if playerx == 141 and playery >=25 and playery<=70 then
			playerx = playerx -1	
		end
		if playerx ==92 and playery >= -1 and playery<=24 then
			playerx = playerx -1
		end
		if playerx == 29 and playery >=31 and playery<=78 then
			playerx = playerx -1
		end
		if playerx ==222 and playery>=-1 and playery<=19 then
			playerx = playerx -1
		end
	end

if pad:up() and playery>= 0 then
	moveup()
  	
  	playery = playery -1


	if playery == 76 and playerx >=144 and playerx <= 206 then
		playery = playery +1
	end
	if playery == 26 and playerx >= 94 and playerx <= 139 then
		playery = playery +1
	end
	if playery == 79 and playerx >= 33 and playerx <= 72 then
		playery = playery +1
	end
	if playery == 38 and playerx >=-2 and playerx <= 27 then
		playery = playery +1
	end
	end
 	if pad:down()  and playery<=78 then
 	 if CurrentTime % 2 == 0 then 
	   player_direction = 1
	
	   
 	   playery = playery +1 

 	 else
 	  player_direction = 2
  	  playery = playery +1

 	 end 
	if playery == 27 and playerx >=	38 and playerx <=25 then
		playery = playery -1
	end
	if playery == 24 and playerx >=141 and playerx <= 204 then
		playery = playery -1
	end

	end 
	if pad:up() and playery==22 and playerx>=231 and playerx <=251 then
	place = "homebottom__"
	
	end
end

if place == "bottomhouse_" then
screen:clear()
screen:blit(0,0,BG[8].pic)
screen:blit(playerx,playery,image[player_direction])
if pad:left() and playerx>=0 then
	moveleft()    	
    	playerx = playerx -1

    
	
 

--left table
if playerx == 173 and playery >=102 and playery<=144 then
playerx = playerx +1
end
--left bed
if playerx == 312 and playery >=55 and playery <=78 then
playerx = playerx +1
end
--right bed
if playerx == 390  and playery >= 55  and playery<=78 then
playerx = playerx +1
end
--right table
if playerx == 400 and playery>=101 and playery<=144 then
playerx = playerx +1
end
--lady
if playerx == 69 and playery>=109 and playery<=147 then
playerx = playerx +1
end
--pikachu
if playerx == 345 and playery >=55 and playery <=79 then
playerx = playerx +1
end
end


if pad:right() and playerx<=443 then
	moveright()
        playerx = playerx +1
       
 
--left table
if playerx == 80 and playery >=102 and playery <=144 then
playerx = playerx -1
end
--left bed
if playerx == 271 and playery >= 55 and playery<= 78 then
playerx = playerx -1
end
--right bed
if playerx == 350 and playery >=55 and playery<=78 then
playerx = playerx -1
end
--pikachu
if playerx == 315 and playery>=55 and playery<=79 then
playerx = playerx -1
end
--right table
if playerx == 289 and playery>=101 and playery <= 144 then
playerx = playerx -1
end
--lady
if playerx == 36 and playery >=109 and playery<=147 then
playerx = playerx -1
end
end

if pad:up() and playery > 51 then
	moveup()
	playery = playery -1 

--left table 	
if playery == 144 and playerx >= 80 and playerx <=173 then
playery = playery +1
end
--left bed
if playery == 78 and playerx>=271 and playerx <= 312 then
playery = playery +1
end
--right bed
if playery == 78 and playerx >=350 and playerx <=390 then
playery = playery +1
end
--pikachu
if playery ==79 and playerx >=315 and playerx<=345 then
playery = playery +1
end

--right table
if playery == 144 and playerx >=289 and playerx <=400 then
playery = playery +1
end
--lady
if playery == 147 and playerx >=36 and playerx <=69 then
playery = playery +1
end
end

if pad:down()  and playery<148 then
	movedown()
	playery = playery +1

--left table
if playery == 102 and playerx >=80 and playerx <=173 then
playery = playery -1
end
--right table
if playery == 101 and playerx>=289 and playerx <= 400 then
playery = playery -1
end
--lady
if playery == 109 and playerx >=36 and playerx <=69 then
playery = playery -1
end

--leaving
if playery==130 and playerx>=214 and playerx <=244 then
place = "neptarento__"

end
end
-- talking
if pad:r() and oldpad:r() ~=pad:r() then
	--lady
	if playerx <= 71 and playerx >= 29 and playery >= 107 and playery <=149 then
		houselady = 1
	end


	--kid
	if playerx <= 402 and playerx >= 376 and playery >=99 and playery <=149 then
		bottomhousekid = 1
	end
	--pikachu
	if playerx <=346 and playerx >=313 and playery >=56 and playery <= 80 then
		pikachu = 1
	end

end
end


if place == "homebottom__" then
screen:clear()
screen:blit (BG[5].x, BG[5].y, BG[5].pic)
screen:blit(playerx+78, playery+15, image[player_direction])
 if pad:l() then
	dofile("./start_pressed.lua")
 end
if pad:left() and playerx >= -76 then
    	moveleft()
    	  playerx = playerx -1

    
	

	   
	if playerx == -43 and playery >= 45 and playery <=87 then
	playerx = playerx +1
	end
	if playerx == 42 and playery >= -14 and playery <= 18 then
	playerx = playerx +1
	end
	if playerx == 212 and playery >= 33 and playery <= 72 then
	playerx = playerx +1
	end
	if playerx == 198 and playery >= 72 and playery <= 80 then
	playerx = playerx +1
	end
end
	
if pad:right() and playerx<= 247 then
     moveright()    
	playerx = playerx +1
     if playerx == 140 and playery >= 43 and playery <= 79 then
	playerx = playerx -1
     end
     if playerx == 152 and playery >= 33 and playery <= 44 then
	playerx = playerx -1
     end
     if playerx == 219 and playery >= -14 and playery <= 27 then
	playerx = playerx -1
     end
     if playerx == 232 and playery >= 82 and playery <= 116 then
	playerx = playerx -1
     end
end

	if pad:up() and playery >= 18 then

  	moveup()

  	 playery = playery -1 
	
	if playery == 28 and playerx >=233 and playerx <= 240 then
	place = 0
	end
	if playery == 73 and playerx >= 199 and playerx <= 212 then
	playery = playery +1
	end
	if playery == 83 and playerx >= 153 and playerx <= 198 then
	playery = playery +1
	end
	if playery == 91 and playerx >= -77 and playerx <= -45 then
	playery = playery +1
	end
	if playery == 26 and playerx >= -77 and playerx <= 43 then 
	playery = playery +1 
	end
	end

	if pad:down() and playery <= 115 then
 	 movedown()
  	  playery = playery +1

 	 
	if playery == 101 and playerx >=94 and playerx <=113 then
	place = "neptarento__"
	BG[1].x = 0
	BG[1].y = 0
	BG[2].x = 0
	BG[2].y = 270
	BG[3].x = 480
	BG[3].y = 0
	BG[4].x = 480
	BG[4].y = 270
	chars[1].x = 468
	chars[1].y = 300
	end
	if playery == 86 and playerx >= 238 and playerx <= 248 then
	playery = playery -1
	end
	if playery == 41 and playerx >= 142 and playerx <= 151 then
	playery = playery -1	
	end
	if playery ==  30 and playerx >= 156 and playerx <= 211 then
	playery = playery -1
	end
	if playery == 45 and playerx >= -77 and playerx <= -41 then
	playery = playery -1
	end
end 
end
if place == "neptarento__" and i == 0 then
for blit_slides = 1, 4 do
 screen:blit(BG[blit_slides].x, BG[blit_slides].y, BG[blit_slides].pic) 
end
screen:blit(BG[7].x, BG[7].y, BG[7].pic)
screen:blit(240,135,image[player_direction])
screen:blit(chars[1].x,chars[1].y,chars[1].pic)
 if pad:l() then
	dofile("./start_pressed.lua")
  end

if pad:left() then
   if BG[1].x <= 240 then  
      moveleft()
      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
    	
    end
    
 if BG[1].x == -9 and BG[1].y <= 100 and BG[1].y >= 27  then
 
 
  leftmoveboundry()
  
 end 
 if BG[1].x == 137 and BG[1].y<=100 and BG[1].y>=27 then
 
 
  leftmoveboundry()
 
    	
 end 
 if BG[1].x == 8 and BG[1].y <=15 and BG[1].y >=-45 then
 
 
  leftmoveboundry()
 
 end 
 if BG[1].x == 207 and BG[1].y<= -95 and BG[1].y>=-141 then
 
   leftmoveboundry()
  end 
 if BG[1].x == 174 and BG[1].y <=-157 and BG[1].y >= -245 then
 
 leftmoveboundry()
 end 
 if BG[1].x == -27 and BG[1].y <= -249 and BG[1].y >= -337 then

 leftmoveboundry()
 end 
 if BG[1].x == -82 and BG[1].y <=-131 and BG[1].y >= -219 then
 
 leftmoveboundry()
 end 
 if BG[1].x == -65 and BG[1].y>=-241 and BG[1].y<=-219 then
 
 leftmoveboundry()
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         
     

 if BG[1].x == -214 and BG[1].y <=-144 and BG[1].y >=-197 then
  
  rightmoveboundry()
end
 if BG[1].x == 88 and BG[1].y>=25 and BG[1].y<=100 then
  
  rightmoveboundry()
end
 if BG[1].x == 233 and BG[1].y>= 25 and BG[1].y <=100 then
  
  rightmoveboundry()
end
 if BG[1].x == 70 and BG[1].y<= -9 and BG[1].y>= -46  then
  
  rightmoveboundry()
end

 if BG[1].x == -38 and BG[1].y<= 104 and BG[1].y>=-27 then
 
  rightmoveboundry()
end
 if BG[1].x == -55 and BG[1].y>= -1 and BG[1].y<= -20 then
  
  rightmoveboundry()
end
 if BG[1].x == 130 and BG[1].y <=-86 and BG[1].y >=-136  then
  
  rightmoveboundry()
end
 if BG[1].x == -19 and BG[1].y <= -132 and BG[1].y>= -205 then
  
  rightmoveboundry()
end
 if BG[1].x == -33 and BG[1].y <= -205 and BG[1].y >= -233 then
  
  rightmoveboundry()
end
 if BG[1].x == 106 and BG[1].y <= -255 and BG[1].y>= -325 then
  
  rightmoveboundry()
 end
 if BG[1].x == -204 and BG[1].y <= -187 and BG[1].y >= -244 then
  
  rightmoveboundry()
end
if BG[1].x == -223 and BG[1].y<=-81 and BG[1].y >=-208 then
  
  rightmoveboundry()
end
if BG[1].x == -280 and BG[1].y >= -330 and BG[1].y <= -265 then
  
  rightmoveboundry()
end
if BG[1].x <=-706 then
place ="route1______"
dofile("./Route1.lua")

end
end 

if pad:up() and BG[1].y <= 100 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


  if BG[1].y == 25 and BG[1].x>= -8 and BG[1].x<= 88 then
   
   upmoveboundry()
 end     
  if BG[1].y==25 and BG[1].x>= 143 and BG[1].x<=233 then
    
    upmoveboundry()
  end 
  if BG[1].y == -156 and BG[1].x<=120 and BG[1].x>=73 then
      
    upmoveboundry()
end
  if BG[1].y == -40 and BG[1].x<= 70 and BG[1].x>=7 then
      
    upmoveboundry()
end
  if BG[1].y == -139 and BG[1].x <= 261 and BG[1].x >=206 then
    
    upmoveboundry()
end   
  if BG[1].y == -329 and BG[1].x<=92 and BG[1].x>=-10 then
    
    upmoveboundry()
end   
  if BG[1].y == -219 and BG[1].x<=-19 and BG[1].x>=-73 then
    
    upmoveboundry()
end 
  if BG[1].y == -243 and BG[1].x<=241 and BG[1].x>=175 then
        
    upmoveboundry()
end 
  if BG[1].y ==-46 and BG[1].x<=-69 and BG[1].x>=-285 then
    
    upmoveboundry()
end 
  if BG[1].y ==-264 and BG[1].x <=-218 and BG[1].x>= -288 then
    
    upmoveboundry()
end   
  if BG[1].y == -331 and BG[1].x<=-297 and BG[1].x>=-705 then
    
    upmoveboundry()
end 
 if BG[1].y == 24 and BG[1].x >= 55 and BG[1].x<=57 then 
	place = "homebottom__"
	BG[1].y = 0
	playerx = 105
	playery = 97
end
 if BG[1].y == -330 and BG[1].x >= 35 and BG[1].x <= 41 then
	place = "bottomhouse_"
	playerx = 224
	playery = 134

 end
 if BG[1].y == -238 and BG[1].x >=-65 and BG[1].x <= -33 then
   
    upmoveboundry()
end

end


 if pad:down() and BG[1].y >= -337 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

 
   if BG[1].y == 100 and BG[1].x >= -8 and BG[1].x<=86 then

 downmoveboundry()
end
  if BG[1].y == 100 and BG[1].x<= 233 and BG[1].x>=137 then

 downmoveboundry()
 end
  if BG[1].y ==15 and BG[1].x <=73 and BG[1].x >= 8 then
 
 downmoveboundry()
 end
  if BG[1].y ==-98 and BG[1].x<=241 and BG[1].x >=208 then
 
 downmoveboundry()
  end 
  if BG[1].y == -85 and BG[1].x <= 129 and BG[1].x>=64 then
 
 downmoveboundry()
 end
  if BG[1].y == -159 and BG[1].x <=241 and BG[1].x >=175 then
 
 downmoveboundry()
end


  if BG[1].y == -251 and BG[1].x <=93 and BG[1].x>=-26 then

 downmoveboundry()
end
  if BG[1].y == -130 and BG[1].x <=-18 and BG[1].x >= -80 then
 
 downmoveboundry()
 end
 if BG[1].y == -77 and BG[1].x <=-219 then
downmoveboundry()
end
end


end
if pad:r() and oldpad:r() ~=pad:r() and oaktalk == 0 then  
  if  BG[1].x<= -200 and BG[1].x>=-214 and BG[1].y<=-146 and BG[1].y>=-186  then
  oaktalk = 1
 end  
  if BG[1].y <= -88 and BG[1].y>=-155 and BG[1].x <= 261 and BG[1].x >=226 then
	pichuguy = 1 

end
  if BG[1].y <= -88 and BG[1].y >= -155 and BG[1].x <= 225 and BG[1].x>=215 then
  pichu = 1
  end
if BG[1].y<= -220 and BG[1].y >= -242 and BG[1].x<= -32 and BG[1].x>=-70 then
lawnguy = 1
end

end
if oaktalk == 1 and r == 0 then
screen:blit( 71,170, textbox)
    screen:print(101,190,"Hello and welcome to the world of ",blue)
    

    screen:print(101, 210, "pokemon, which are domesticated  ", blue)

    
    screen:print(101, 230, "monsters that come in all shapes. ", blue)
    screen:print(101, 250, "and sizes.", blue)
    screen:blit(351, 250, text_button)
    
    counter = counter + 1

    if pad:r() and oldpad:r() ~= pad:r() and counter >= 25 then
	oaktalk = 2
    	counter = 0
	r = 2
	end
end
if oaktalk == 2 and r == 2 then
	screen:blit(71,170, textbox)
	screen:print(101, 190, "now it's time for you to ", blue)
	screen:print(101, 210, "choose the pokemon you would like.", blue)
	if pad:r() and oldpad:r() ~= pad:r() then
		oaktalk = 3
	end
	
end
if oaktalk == 3 then
dofile("./pokemonchoice.lua")
end
if pichuguy == 1 then
    counter = counter +1
    screen:blit(71,170, textbox)
    screen:print(101, 190, "Heya, how do you like my pichu?", blue)
    screen:print(101,210, "I just got it from Prof. OAK", blue)
    if pad:r() and oldpad:r() ~= pad:r() and counter >= 25 then
	pichuguy = 0
	counter = 0
    end
end
if pichu == 1 then
    counter = counter +1
    screen:blit(71,170, textbox)
    screen:print(101, 190, "Pichu Pii.", blue)
    if pad:r() and oldpad:r() ~= pad:r() and counter >= 25 then
	pichu = 0
	counter = 0
    end
end
  if lawnguy == 1 then
   counter = counter +1 
    screen:blit(71,170, textbox)
    screen:print(101, 190, "Hey you kids get off my lawn", blue)
	if pad:r() and oldpad:r() ~=pad:r() and counter >=15 then
	lawnguy = 0
	counter = 0
	end
  end

	if houselady == 1 then
		counter = counter +1 
		screen:blit(71,170, textbox)
		screen:print(101, 190, "My son keeps saying his pikachu is", blue)
		screen:print(101,210, "but i dont believe him.", blue)
		if pad:r() and oldpad:r() ~=pad:r() and counter >=15 then
			houselady = 0
			counter = 0
		end
	end
	if bottomhousekid == 1 then
		counter = counter +1 
		screen:blit(71,170, textbox)
		screen:print(101, 190, "My pikachu is possesed...it scares", blue)
		screen:print(101,210, "me.", blue)
		if pad:r() and oldpad:r() ~=pad:r() and counter >=15 then
			bottomhousekid = 0
			counter = 0
		end
	end		
	if pikachu == 1 then
		counter = counter +1 
		screen:blit(71,170, textbox)
		screen:print(101, 190, "ROAR!!!", blue)
		if pad:r() and oldpad:r() ~=pad:r() and counter >=15 then
			pikachu = 0
			counter = 0
		end
	end

--screen:print(0,0,p1_attacks[1].name .. p1_attacks[1].power .. p1_attacks[1].accuracy, blue)
--screen:print(0,15,p1_attacks[2].name.. p1_attacks[2].power .. p1_attacks[2].accuracy, blue)
--screen:print(0,30,p1_attacks[3].name.. p1_attacks[3].power .. p1_attacks[3].accuracy, blue)
--screen:print(0,45,p1_attacks[4].name.. p1_attacks[4].power .. p1_attacks[4].accuracy, blue)
screen:print(101,210,playery, blue)
--screen:print(101,230,BG[7].y, blue)
screen.waitVblankStart()
screen.flip()
oldpad = pad
end