QJ.NET | Videos | Forums | iPhone | MMORPG | Nintendo DS | Wii | PlayStation 3 | PSP | Xbox 360 | PC | Downloads | Contact Us
Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact

QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides

Go Back   QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides > Developers Corner > PSP Development, Hacks, and Homebrew > PSP Development Forum
The above video goes away if you are a member and logged in, so log in now!

Slight Menu Problem

This is a discussion on Slight Menu Problem within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; its easy to fix, i'm sure. Code: while true do screen:blit(0, 0, mmenu) pad = Controls.read() screen:print(180, 130, ">Start Game", ...

Reply
 
LinkBack Thread Tools
Old 02-15-2006, 03:59 PM   #1
 
EminentJonFrost's Avatar
 
Join Date: Dec 2005
Location: Here
Posts: 2,715
Trader Feedback: 0
Default Slight Menu Problem

its easy to fix, i'm sure.

Code:
while true do
	screen:blit(0, 0, mmenu)
	
	pad = Controls.read()

	screen:print(180, 130, ">Start Game", red)
	screen:print(180, 140, "Credit", white)
	screen.flip()

--This it to give the user the ability to choose options, but theres an error

	if pad:down() then
		screen:clear()
		screen:blit(0, 0, mmenu)
		screen:print(180, 130, "Start Game", white)
		screen:print(180, 140, ">Credit", red)
		screen.flip()

	if pad:up() then
		screen:clear()
		screen:blit(0, 0, mmenu)
		screen:print(180, 130, ">Start Game", red)
		screen:print(180, 140, "Credit", white)
		screen.flip()
end
end


screen.waitVblankStart()
end
with this code, the main page does what i want mostly. but i dont know how to keep the selected option..well selected. lol :icon_razz
__________________
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
EminentJonFrost is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 02-15-2006, 04:06 PM   #2

Developer
 
MasterQ's Avatar
 
Join Date: Sep 2005
Location: USA
Posts: 154
Trader Feedback: 0
Default

the code is correct, but the way you have it oriented will only have it printed to the screen if you hold up or down. make the up/down buttons add or subtract from a variable. then, in your main loop, use an if/then statement to check the variable, and act accordingly.

EXAMPLE
Code:
while true do
	screen:blit(0, 0, mmenu)
	
	pad = Controls.read()

	screen:print(180, 130, ">Start Game", red)
	screen:print(180, 140, "Credit", white)
	screen.flip()

--This it to give the user the ability to choose options, but theres an error

	if pad:down() then
		if menuitem < 1 then
                        menuitem = menuitem + 1
                end
        end

	if pad:up() then
                if menuitem > 0 then
                        menuitem = menuitem - 1
                end
        end

screen:clear()
screen:blit(0, 0, mmenu)
if menuitem == 0 then
        screen:print(180, 130, ">Start Game", red)
        screen:print(180, 140, "Credit", white)
elseif menuitem == 1 then
        screen:print(180, 130, "Start Game", white)
        screen:print(180, 140, ">Credit", red)
end
screen.flip()
screen.waitVblankStart()
end
__________________

Last edited by MasterQ; 02-15-2006 at 04:11 PM..
MasterQ is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 02-15-2006, 04:10 PM   #3
 
EminentJonFrost's Avatar
 
Join Date: Dec 2005
Location: Here
Posts: 2,715
Trader Feedback: 0
Default

oh ok. thats about where i am right now in learning lua.
good time to get a crash course.
__________________
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
EminentJonFrost is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 02-15-2006, 04:12 PM   #4

Developer
 
MasterQ's Avatar
 
Join Date: Sep 2005
Location: USA
Posts: 154
Trader Feedback: 0
Default

i edited my first post to show you what i meant
__________________
MasterQ is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 02-15-2006, 04:21 PM   #5
 
EminentJonFrost's Avatar
 
Join Date: Dec 2005
Location: Here
Posts: 2,715
Trader Feedback: 0
Default

ohhh
i get it now
well not really...
i understand it, but i wouldnt be able to create that on my own.

after looking and thinking at it for a while, then i should be able to do that by myself

thanks
__________________
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
EminentJonFrost is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 02-15-2006, 06:14 PM   #6

...in a dream...
 
SG57's Avatar
 
Join Date: Jul 2005
Posts: 4,957
Trader Feedback: 0
Default

Ya, I would just make an integer named 'menu' (imagine that? lol) and if UP is pressed, than add 1 to that integer, and if DOWN is pressed, than subtract 1 from that integer, and if that integer goes over/under how ever many items on your menu, then have it go back to the end/start. Then just do what he said and use an 'if' statement with a boolean in it to check if that integer is true to a certain number, and if it is true, then do whatever you want.

This is basically what MasterQ did, except it's in words to help you out.
__________________
SG57 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 02-16-2006, 09:07 AM   #7
 
EminentJonFrost's Avatar
 
Join Date: Dec 2005
Location: Here
Posts: 2,715
Trader Feedback: 0
Default

what happens now is when i press DOWN, it goes down (so far so good) BUT when i release the down button, it automatically goes back up.
and thats with the code MasterQ gave me.
__________________
[CENTER][IMG]http://img148.imageshack.us/img148/6985/siglw8.jpg[/IMG][/CENTER]
EminentJonFrost is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 02-16-2006, 10:11 AM   #8

PSP Developer
 
alatnet's Avatar
 
Join Date: Oct 2005
Real First Name: Alex
Location: ~* Confidential *~
Just Played: N/A
Posts: 839
Trader Feedback: 0
Default

Try this:

Code:
while true do
	screen:blit(0, 0, mmenu)
	
	pad = Controls.read()

	screen:print(180, 130, " Start Game", white)
	screen:print(180, 140, " Credit", white)
	screen.flip()

--This it to give the user the ability to choose options, but theres an error

	if pad:down() then
                menuitem = menuitem + 1
                if menuitem > 1 then
                        menuitem = 1
                end
        end

	if pad:up() then
                menuitem = menuitem - 1
                if menuitem < 0 then
                        menuitem = 0
                end
        end

        screen:clear()
        screen:blit(0, 0, mmenu)
        if menuitem == 0 then
                screen:print(180, 130, ">Start Game", red)
                screen:print(180, 140, " Credit", white)
        elseif menuitem == 1 then
                screen:print(180, 130, " Start Game", white)
                screen:print(180, 140, ">Credit", red)
        end
        screen.flip()
        screen.waitVblankStart()
end
This should generaly be correct since i use the same method in my acno's energizer game.
__________________

"Every team needs an idealistic person (whether they are a noob or a pro), my team doesn't have one cus im the idealistic founder."-me
Anime/Manga and Fanfiction is my inspiration!

Creator of:
- PSPSDK makefile creator - Lua Prompt - Animated Sprite Class\Library for Lua - Gmax2PSP -
alatnet is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 02-16-2006, 04:33 PM   #9

...in a dream...
 
SG57's Avatar
 
Join Date: Jul 2005
Posts: 4,957
Trader Feedback: 0
Default

Quote:
Originally Posted by EminentJonFrost
what happens now is when i press DOWN, it goes down (so far so good) BUT when i release the down button, it automatically goes back up.
and thats with the code MasterQ gave me.
Your problem is that you initialized the variable in side of the main loop.

Code:
while true do
	 menu = 0
	 ya da ya da
end
When it should be:
Code:
menu = 0
while true do
	ya da ya da
end
Basically, everytime your program goes through that loop over and over again, it is seeing menu = 0, so it resets the menu integer number to 0, there fore making it go back up. Just move what ever your integer or variable holding your menu bool, is not inside of any loop.
__________________
SG57 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
menu , problem , slight

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 10:02 AM.



Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © 2009, QJ.NET. All Rights Reserved.
Contact Us