--------stop wall collision from first level-----

	wall = nil

	status = "game"

--------load map-------

	shop = Image.load("backgrounds/shop.png")

-----------**Walls**---------

	wall1 = Image.createEmpty(1,60)  -----first vertical wall - left
	wall2 = Image.createEmpty(1,60)  -----first vertical wall - right
	wall3 = Image.createEmpty(70,1)  -----first horizontal wall - left
	wall4 = Image.createEmpty(70,1)  -----first horizontal wall - right
	wall5 = Image.createEmpty(1,1)   -----vertical right wall 1
	wall6 = Image.createEmpty(1,40)  -----vertical right wall 2 - chairs
	wall7 = Image.createEmpty(300,1) -----top horizontal wall
	wall8 = Image.createEmpty(18,1)  -----box next to counter 1
	wall9 = Image.createEmpty(1,60)  -----vertical wall left
	
------------Walls------

   	wall1 = {x = 213, y = 209, height = wall1:height(), width = wall1:width() }
   	wall2 = {x = 276, y = 208, height = wall2:height(), width = wall2:width() }
   	wall3 = {x = 120, y = 210, height = wall3:height(), width = wall3:width() }
   	wall4 = {x = 276, y = 210, height = wall4:height(), width = wall4:width() }
   	wall5 = {x = 347, y = 200, height = wall5:height(), width = wall5:width() }
   	wall6 = {x = 329, y = 143, height = wall6:height(), width = wall6:width() }
   	wall7 = {x = 158, y = 129, height = wall7:height(), width = wall7:width() }
   	wall8 = {x = 135, y = 138, height = wall8:height(), width = wall8:width() }
   	wall9 = {x = 119, y = 149, height = wall9:height(), width = wall9:width() }
   	  
-----------------**Collision Check**---------

function collisionCheck(test)

	if (player.x + playerWidth > test.x) and (player.x < test.x + test.width) and
	(player.y + playerHeight > test.y) and (player.y < test.y + test.height) then

	player.x = oldx
	player.y = oldy
	end
end

--------------**map loading**------

function maps()   ------House

	if player.x>=214 and player.x <=258 and
	player.y >=265 and player.y <=267 then
	player.x = 410
	player.y = 99
	player.img = player10
	dofile("map2.lua")
	end
end

----------player text---------

	function playertext()
       
---------character conversation-----

	if player.x >=222 and player.x <=265 and
	player.y >=128 and player.y <=137 and
	pad:circle() then
	select:play()
	screen:blit(240, 80, box1)
	screen:print(254, 120, "Welcome to", black)
	screen:print(254, 140, "the shop!.", black)
	screen:print(254, 160, "See anything.", black)
	screen:print(254, 180, "you like?", black)
	screen.flip()
	screen.waitVblankStart(140)
	screen:blit(240, 80, box1)
	screen:print(254, 120, "Sorry,", black)
	screen:print(254, 140, "You don't", black)
	screen:print(254, 160, "have enough.", black)
	screen:print(254, 180, "rupees", black)
  	screen.flip()
	screen.waitVblankStart(130)
   	end
     

	if player.x >=222 and player.x <=265 and
	player.y >=128 and player.y <=137 and
	pad:cross() then
	select:play()
	screen:blit(240, 80, box1)
	screen:print(254, 120, "Welcome to", black)
	screen:print(254, 140, "the shop!.", black)
	screen:print(254, 160, "See anything.", black)
	screen:print(254, 180, "you like?", black)
	screen.flip()
	screen.waitVblankStart(140)
	screen:blit(240, 80, box1)
	screen:print(254, 120, "Sorry,", black)
	screen:print(254, 140, "You don't", black)
	screen:print(254, 160, "have enough.", black)
	screen:print(254, 180, "rupees", black)
  	screen.flip()
	screen.waitVblankStart(130)
   	end
end

----------start main loop--------

	while true do

    maps()

-------**store players position at beginning of each loop**----

	oldx = player.x
	oldy = player.y
	screen:clear()

-------init controls---------

	pad = Controls.read()

---------init functions-----

	if pad:right() then    -----Right Movement
	moveRight()
	player.x = player.x + 2
 	end

	if pad:left() then    -----Left Movement
	moveLeft()
	player.x = player.x - 2
  	end

	if pad:up() then      -----Up Movement
	moveUp()                                                   
 	player.y = player.y - 2
	end

	if pad:down() then   -----Down Movement
	moveDown()
 	player.y = player.y + 2
	end

------**check collision for wall**-----

	collisionCheck(wall1)
	collisionCheck(wall2)
	collisionCheck(wall3)
	collisionCheck(wall4)
	collisionCheck(wall5)
	collisionCheck(wall6)
	collisionCheck(wall7)
	collisionCheck(wall8)
	collisionCheck(wall9)
	
-------------**Blit To Screen**----

	screen:blit(0, 0, shop)
	screen:blit(player.x, player.y, player.img)
	screen:blit(245, 78, shopkeeper1)
	screen:blit(127, 10, shopmenu)
	screen:blit(400, 10, container)
 	screen:blit(417, 13, triangle)
 	screen:blit(432, 30, circle)
   	screen:blit(403, 30, square)
   	screen:blit(417, 45, cross)
 	screen:blit(404, 32, sword)
 	screen:blit(420, 15, bomb)
 	screen:blit(420, 49, maja)
 	screen:blit(2, 0, hearts)
 	screen:blit(240, 0, rupee)
   	screen.flip()

    playertext()

  screen.waitVblankStart()
  end


