Options Problem

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
BrokenHeartedLoser
Posts: 11
Joined: Mon Oct 10, 2005 3:30 am
Location: London, UK

Options Problem

Post by BrokenHeartedLoser »

i'm new to luaplayer and i would like some help knowing whats wrong with my options menu ever since i added it, it just closes down while using luaplayer for windows...

Code: Select all

   if pad:cross() then

           ShowOptions()
      end
end
would this be the way to show my option menu with a function?

here is what my option menu coding is

Code: Select all


function ShowOptions()

screen:blit(0, 0, IMGOptionsMenu)
      screen:blit(340, 84, IMGSlow)
      screen:blit(356, 127, IMGNormal2)
      screen:blit(366, 174, IMGFast)
      screen:blit(366, 174, IMGBack)

   if selectedOption == 1 then

	screen:blit(340, 84, IMGSlow2)
      screen:blit(356, 127, IMGNormal)
      screen:blit(366, 174, IMGFast)
      screen:blit(366, 174, IMGBack)

   elseif selectedOption == 2 then

	screen:blit(340, 84, IMGSlow)
      screen:blit(356, 127, IMGNormal2)
      screen:blit(366, 174, IMGFast)
      screen:blit(366, 174, IMGBack)

   elseif selectedOption == 3 then

      screen:blit(340, 84, IMGSlow)
      screen:blit(356, 127, IMGNormal)
      screen:blit(366, 174, IMGFast2)
      screen:blit(366, 174, IMGBack)

   elseif selectedOption == 4 then

      screen:blit(340, 84, IMGSlow)
      screen:blit(356, 127, IMGNormal)
      screen:blit(366, 174, IMGFast)
      screen:blit(366, 174, IMGBack2)

   end

   screen.waitVblankStart()
   screen.flip()

end

   pad = Controls.read()
	
   if pad:left() then

	if selectedOption > 1 then
 
	   selectedOption=selectedOption-1

	end 

   end 
	
   if pad:right() then

	if selectedOption < 3 then
 
	   selectedOption=selectedOption+1

	end

   end   

   if pad&#58;cross&#40;&#41; then

	if selectedOption == 1 then

        ballspeed  = 100 
        selectedOption == 4

	elseif selectedOption == 2 then

        ballspeed   = 200
        selectedOption == 4

	elseif selectedOption == 3 then

        ballspeed   = 300
        selectedOption == 4

	elseif selectedOption == 4 then

        Menu&#40;&#41;

	end 

   end 
i know that all images are loaded and i know that 2 of them go into the same place i'll put them where i want after :P
and this is my varible for selectOption

Code: Select all

selectedOption = 2 --&#91;&#91; 
		    1 - slow; 
		    2 - normal;
		    3 - fast;
                    4 - back;

		&#93;&#93;--
once i get this working hopefully i can save the settings just like shine's snake :)
Shine
Posts: 728
Joined: Fri Dec 03, 2004 12:10 pm
Location: Germany

Re: Options Problem

Post by Shine »

Looks like the code you quoted with your "ShowOptions" function is more code than just this function, but it is hard, because the idention is strange.

You can call it as a function, but when it returns, it will be displayed only once. If you like, you could take a look at the Snake game source code.

The best solution would be a general event based library, which removes the need of the game-loop, because looks like this makes it harder than needed for Lua Player beginners. This could be implemented in Lua and could look like just some class, where you need to overide onPaint, onCross, onLeft etc., only and then call some internal event loop, which is provided by the class. This is the point A LuaPlayer library for cooperative multitasking, clipping regions (windows), cursor, “mouse” and keyboard events, and stuff like that on http://wiki.ps2dev.org/psp:lua_player:todos , which doesn't mean that nevyn or I have to do the work alone :-) (we are busy for the next weeks with porting to different operating systems, preparing the conference talk, sound enhancements and OpenGL implementation)
BrokenHeartedLoser
Posts: 11
Joined: Mon Oct 10, 2005 3:30 am
Location: London, UK

Post by BrokenHeartedLoser »

yea i understand you guys are busy and yea i have checked out the snake source code but i was trying to find out a way to this with images without editting the snake source code...i've only been doing visual basic programming since this and that was easy heh
Post Reply