img_menue = Image.load("data/menu_points.png")
img_title = Image.load("data/title.png")


--options = { players = 2, Music = "OFF", speed = 1, backgroundImage ="wood" }
options = { music = off }
option_width = 125

possibleOptions = {
	 a_1start_game = {
			displayName = 'start_game',
      src = img_menue,
      value = 0},

   b_2options = {
      displayName = 'options',
      src = img_menue,
      value = 24},      
   c_3credits = {
      displayName = 'credits',
      src = img_menue,
      value = 240},
   c_4exit = {
      displayName = 'exit',
      src = img_menue,
      value = 48}
--   music = {
--      displayName = 'music',
--      src = img_menue,
--      value = 144},
--	 players = {
--	 		displayName = "How many Players:",
--	 		value = { 1, 2 },
}


---game stuff

Level = {
	x=8, --always this value
	y=24, --always this value
	--name='',
	version=0,
	data={},
	playerstart={},
	sprites={}
}
Startpos = {p1={x=0,y=0},p2={x=0,y=0}}



--NOTE: selectedMenuePoint is the selected menuepoint ;)
	function mainMenu()
	
			--main menue is the following:
			-- Start game
			-- options
			-- exit
	   selectedOptionNumber = 0
	   deactivepos = option_width --where the deactivated gfx starts
	   activepos = 0		 					--where the activated gfx starts
	   oldPad = Controls.read()
	   while true do
	      screen:clear()
	      screen:blit(0,0,img_title, 0,0,img_title:width(),img_title:height(), true)
	     	screen:print(175, 250, '(c) PsPmad PsPLF2', Color.new(255,255,255))
	      y = 0
	      selectedOptionValues = nil
	      for optionKey, possibleOption in possibleOptions do
	         pos = deactivepos
	         if selectedOptionNumber == y then
	            pos = activepos
	            selectedOptionValues = possibleOption.value
	            selectedMenuePoint=selectedOptionValues/24
	         end
	         screen:blit(178,150+y*24, possibleOption.src, pos, possibleOption.value, option_width, 16, true )
	         y = y + 1
	      end
	
	      pad = Controls.read()
	      if pad ~= oldPad then
	         if pad:cross() or pad:start() then --select the current point
	         		if selectedMenuePoint == 0 then -- means start game is selected
	         			dofile("./data/game.lua")
	         		elseif selectedMenuePoint == 1 then -- show options
	         			dofile("./data/optionsMenue.lua")
	         		elseif selectedMenuePoint == 2 then --exit game
	         			break
	         		elseif selectedMenuePoint == 10 then -- means credits
	         			dofile("./data/credits.lua")
	         		end 
	         end
	         if pad:up() then
	            selectedOptionNumber = selectedOptionNumber - 1
	            if selectedOptionNumber < 0 then selectedOptionNumber = y - 1 end
	         end
	         if pad:down() then
	            selectedOptionNumber = selectedOptionNumber + 1
	            if selectedOptionNumber >= y then selectedOptionNumber = 0 end
	         end
	         oldPad = pad
	      end
	
	      screen.waitVblankStart()
	      screen.flip()
	   end
	end
	
mainMenu() --lops till triangle is pressed!