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!

move image over and keep it there

This is a discussion on move image over and keep it there within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; alright, im learning LUA, so i wanna make it when you hti right ti moves character over and keeps him ...

Reply
 
LinkBack Thread Tools
Old 01-17-2006, 02:15 PM   #1
 
Join Date: Nov 2005
Posts: 45
Trader Feedback: 0
Default move image over and keep it there

alright, im learning LUA, so i wanna make it when you hti right ti moves character over and keeps him there. right now the code i wrote, it moves it but when i release right it moves it back to original position

Code:
pad = Controls.read()
x = 60
y = 40
	
       if pad:right() then
		x = x + 5
		y = y +5
	end

screen:blit(x, y, person)
screen.flip()
can someone help so he stays in spot after he is moved. thanks
Bone is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 01-17-2006, 02:20 PM   #2
 
[sYn]'s Avatar
 
Join Date: Oct 2005
Posts: 25
Trader Feedback: 0
Default

Mm.. I don't know LUA, but from what I can tell your creating two variables (x and y) and assigning them values, then providing a "keypad listener" to look for a right press to change those variable values.

The problem being that the variables will change back once this if statement is over.

Should you not create the variables and leave them empty then create an "if else" type statement to control the image..

please note this code is not real and simply an idea to try and help
Code:
if pad:right() then
     x = 65
     y = 45
else
     x = 60
     y = 40
end
excuse me if I am utterly wrong , simply trying to give you idea's.
[sYn] is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 01-17-2006, 02:33 PM   #3
 
Join Date: Jul 2005
Posts: 71
Trader Feedback: 0
Default

i don't know lua, but i think it's because you've assigned the variables inside of the function. every time you read the controls, the x and y are reset (because they are after the controls.read statement). put setting x and y as part of the loading function (does lua even work in functions?) instead of whenever the control pad is read.

[EDIT] i think the guy above me would also have the same problem you're having, because it's telling the PSP "if you're not holding the controller to the right, then reset the image," which is exactly what you don't want to do...
Damae is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 01-17-2006, 02:41 PM   #4
 
[sYn]'s Avatar
 
Join Date: Oct 2005
Posts: 25
Trader Feedback: 0
Default

Quote:
Originally Posted by Damae
i don't know lua, but i think it's because you've assigned the variables inside of the function. every time you read the controls, the x and y are reset (because they are after the controls.read statement). put setting x and y as part of the loading function (does lua even work in functions?) instead of whenever the control pad is read.

[EDIT] i think the guy above me would also have the same problem you're having, because it's telling the PSP "if you're not holding the controller to the right, then reset the image," which is exactly what you don't want to do...
I was trying to get at what you where saying, but didnt think about it quite so much when writting my "fake" code ..
[sYn] is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 01-17-2006, 02:58 PM   #5
 
Join Date: Oct 2005
Posts: 543
Trader Feedback: 0
Default

Code:
person=Image.load("img/picture.png")
pad = Controls.read()
x = 60
y = 40

while true do    
	 if pad:right() then
			 x = x + 5
			 y = y +5
	 end
	 screen:blit(x, y, person)
	 screen.flip()
end
That should work.
nathan42100 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 01-17-2006, 03:47 PM   #6

OMFG
 
Slasher's Avatar
 
Join Date: Jul 2005
Location: Toronto
Posts: 2,816
Trader Feedback: 0
Default

Quote:
Originally Posted by nathan42100
Code:
person=Image.load("img/picture.png")
pad = Controls.read()
x = 60
y = 40

while true do    
	 if pad:right() then
			 x = x + 5
			 y = y +5
	 end
	 screen:blit(x, y, person)
	 screen.flip()
end
That should work.
btw, if your trying to move your character right, then you should only need to increase the x value and not both the x and the y.
Slasher is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
image , move

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 09:44 AM.



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