PDA

View Full Version : Quick X and Y finding in RMXP


Illusion
December 29th, 2005, 11:03 AM
While making my battle system I really needed the x and y of a picture, but I didn't want to enter random numbers and just see what it does... So when you are showing a picture, add search_something in the loop do then add Input.update if it isn't in there
then make a new definition called search_something
(BTW:You can change "something" into anything you like as long as the one in loop do is identical.)
Then add this in def search_comething:

if Input.press?(Input::DOWN)
@hpbar.y +=2
end
if Input.press?(Input::UP)
@hpbar.y -=2
end
if Input.press?(Input::RIGHT)
@hpbar.x +=2
end
if Input.press?(Input::LEFT)
@hpbar.x -=2
end
if Input.trigger?(Input::C)
print @hpbar.x.to_s+" "+@hpbar.y.to_s
end
end
with replacing @hpbar with the picture you want.
Then when you've found the x and y delete that script.
Here is an example using attached pictures.Just add this in your script editor.
:
class Test_Pokécommunity
def hpbarhero
@hphero = Sprite.new
@hphero.bitmap = RPG::Cache.picture("HPBarHero")
@hphero.x = 242
@hphero.y = 136
@hphero.z = 500
@hphero.zoom_x = 2
@hphero.zoom_y = 2
@hphero.visible = true
@hpbar = Sprite.new
@hpbar.bitmap = RPG::Cache.picture("HPBarMain50")
@hpbar.x = 302
@hpbar.y = 170
@hpbar.z = 500
@hpbar.zoom_x = 2
@hpbar.zoom_y = 2
@hpbar.visible = true
loop do
update_hpbarhero
Graphics.update
Input.update
end
end
def update_hpbarhero
@hpbar.update
if Input.press?(Input::DOWN)
@hpbar.y +=2
end
if Input.press?(Input::UP)
@hpbar.y -=2
end
if Input.press?(Input::RIGHT)
@hpbar.x +=2
end
if Input.press?(Input::LEFT)
@hpbar.x -=2
end
if Input.trigger?(Input::C)
print @hpbar.x.to_s+" "+@hpbar.y.to_s
end
end
end
I hope this is clear because I made it in a hurry..:\

Sydr0me
January 24th, 2006, 12:43 PM
I dont understand it, can you give a demo whos working with Blizzy's Starter kit?

Illusion
February 2nd, 2006, 11:52 AM
Well just add this in your script editor and add the provided ressources. Then in an event do call script and type this in :

class Test
def hpbarhero
@spriteset = Spriteset_Map.new
@hphero = Sprite.new
@hphero.bitmap = RPG::Cache.picture("HPBarHero")
@hphero.x = 242
@hphero.y = 136
@hphero.z = 500
@hphero.zoom_x = 2
@hphero.zoom_y = 2
@hphero.visible = true
@hpbar = Sprite.new
@hpbar.bitmap = RPG::Cache.picture("HPBarMain50")
@hpbar.x = 302
@hpbar.y = 170
@hpbar.z = 500
@hpbar.zoom_x = 2
@hpbar.zoom_y = 2
@hpbar.visible = true
Graphics.transition
loop do
update_hpbarhero
Graphics.update
Input.update
if $scene != self
break
end
end
@spriteset.dispose
@hpbar.dispose
@hphero.dispose
end
def update_hpbarhero
@spriteset.update
@hpbar.update
if Input.press?(Input::DOWN)
@hpbar.y +=2
end
if Input.press?(Input::UP)
@hpbar.y -=2
end
if Input.press?(Input::RIGHT)
@hpbar.x +=2
end
if Input.press?(Input::LEFT)
@hpbar.x -=2
end
if Input.trigger?(Input::C)
print @hpbar.x.to_s+" "+@hpbar.y.to_s
end
if Input.trigger?(Input::B)
$scene = Scene_Map.new
end
end
end