Help with controls!

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

Moderators: Shine, Insert_witty_name

Post Reply
MuffinKing
Posts: 5
Joined: Tue Dec 13, 2005 11:07 am

Help with controls!

Post by MuffinKing »

I hate double posting but people don't seem to see my first one... sigh. Anyway, I just want this piece of code:

Code: Select all

if pointer_x >= 0 and pointer_x <= 98 and pointer_y >= 245 and pointer_y <= 272 and pad&#58;cross&#40;&#41; then
screen&#58;blit&#40;0,245,startpushed&#41;
end
For it to stay blitted instead of letting go and it dissappear.. i want it to appear until i tell it to stop! Is there anyway to fix that??
Dr. Vegetable
Posts: 171
Joined: Mon Nov 14, 2005 1:32 am
Location: Boston, Massachusetts
Contact:

Post by Dr. Vegetable »

Well, my knowledge of Lua is pretty skimpy, but usually what you need to do in a situation like this is to create a "flag" variable that indicates whether the image should be displayed, and then set or reset that flag based on the appropriate events. You didn't specify the circumstances under which the image should go away, but (for example) you could have it stay until you press the square by doing something like:

Code: Select all

if pointer_x >= 0 and pointer_x <= 98 and pointer_y >= 245 and pointer_y <= 272 and pad&#58;cross&#40;&#41; then 
showImage = 1
end

if pad&#58;square&#40;&#41; then
showImage = 0
end

if showImage > 0 then
screen&#58;blit&#40;0,245,startpushed&#41; 
end 
This is untested code, but should give you some idea of how to proceed. Hope this helps!
User avatar
dragaron
Posts: 6
Joined: Tue Dec 06, 2005 11:14 am

Post by dragaron »

if showblit == true then do
if pointer_x >= 0 and pointer_x <= 98 and pointer_y >= 245 and pointer_y <= 272 and pad:cross() then
screen:blit(0,245,startpushed)
end
end


showblit = true (will show blit)
showblit = false (will not show blit)
He has showed you, O man, what is good.
And what does the LORD require of you?
To act justly and to love mercy
and to walk humbly with your God. (Micah 6:8)
MuffinKing
Posts: 5
Joined: Tue Dec 13, 2005 11:07 am

Post by MuffinKing »

Dr. Vegetable wrote:Well, my knowledge of Lua is pretty skimpy, but usually what you need to do in a situation like this is to create a "flag" variable that indicates whether the image should be displayed, and then set or reset that flag based on the appropriate events. You didn't specify the circumstances under which the image should go away, but (for example) you could have it stay until you press the square by doing something like:

Code: Select all

if pointer_x >= 0 and pointer_x <= 98 and pointer_y >= 245 and pointer_y <= 272 and pad&#58;cross&#40;&#41; then 
showImage = 1
end

if pad&#58;square&#40;&#41; then
showImage = 0
end

if showImage > 0 then
screen&#58;blit&#40;0,245,startpushed&#41; 
end 
This is untested code, but should give you some idea of how to proceed. Hope this helps!
OH THANK GOD!! IT WORKS!!!!! I just hate being a noob though, now to figure out how to make it work with one button instead of 2 >_<.
Post Reply