forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[Controls help] Push the Up-button and the X button to...

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
MacorgaZ



Joined: 26 Jun 2006
Posts: 1

PostPosted: Mon Jun 26, 2006 12:43 am    Post subject: [Controls help] Push the Up-button and the X button to... Reply with quote

Hi!
I'm new here to the forum, so if I do anything wrong, just tell me :).

I want to make a simple game, and for that i need a piece of code that checks if 2 buttons are pressed, like the Up-button and the X-button.

Would this code do:

Code:
if pad:cross() and
   pad:up() then
screen:print(100, 250, "Blablabliboe", blue)
screen.flip()
end


Or is there something wrong in it?
I'm just a beginner (a bit better then newbie :p), so I don't know how to use If-statements that wel.

So, if anybody knows how i should do this, please tell me :).


Thanks in advance, MacorgaZ.
Back to top
View user's profile Send private message
Debug



Joined: 06 Oct 2005
Posts: 16

PostPosted: Mon Jun 26, 2006 4:43 am    Post subject: Reply with quote

it should, try it, if not, try
Code:

if pad:cross() then
   if pad:up() then
      screen:print(100, 250, "Blablabliboe", blue)
      screen.flip()
   end
end

_________________
Code:

catch(IOException e){
//oh crap
}
Back to top
View user's profile Send private message AIM Address
daurnimator



Joined: 11 Dec 2005
Posts: 38
Location: melbourne, australia

PostPosted: Wed Jun 28, 2006 11:09 pm    Post subject: Reply with quote

it should work...
have you tested it?
Back to top
View user's profile Send private message MSN Messenger
romero126



Joined: 24 Dec 2005
Posts: 200

PostPosted: Sat Jul 01, 2006 5:22 am    Post subject: Reply with quote

pad = controls.read()

Code:



if pad:cross() and
   pad:up() then
screen:print(100, 250, "Blablabliboe", blue)
screen.flip()
end
Back to top
View user's profile Send private message
Teggles



Joined: 16 Jan 2006
Posts: 27

PostPosted: Mon Jul 10, 2006 7:43 am    Post subject: Reply with quote

If you would like the text to remain on the screen after pressing the buttons (then disappear after pressing again), you would use variables. Here is an example:

Code:

local display = 0
local pad = Controls.read()

while (true) do
   pad = Controls.read()
   if (pad:up()) and (pad:cross()) then
      if (display == 0) then
         display = 1
      elseif (display == 1) then
         display = 0
      end
   end

   screen:clear()
   if (display == 1) then
      screen:print(0, 0, "blah", Color.new(0, 0, 0))
   end
   screen.flip()
end
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group