We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Im making a "game" where you are in control of a ship and you have to avoid "asteroids". right now, it's quite simple, but it's barely my first game.
previusly, i was using a rect(); as a ship, but now im trying to use a shape based on this paint drawing:
but i dont know how to make it go where my mouse is!
any ideas? thanks in advance ;)
Answers
Check the reference for an example of PGraphics object: https://processing.org/reference/PGraphics.html
Then after you designed your ship in this object, you can draw it like this:
image(yourPGraphics, mouseX,mouseY);
Make sure you call
imageMode(CENTER);
andrectMode(CENTER);
in your setup() function as these calls will make your task at hand easier.Kf
@P14082003 --
A second option is, if you want to load a graphic of your ship rather than drawing it in processing, use
loadImage()
and then draw the ship withimage()
at yourmouseX, mouseY
location -- like this:A third option is that you could load the ship graphic into the mouse cursor itself with
cursor()
-- but this is not very flexible if you want things other than the mouse to affect the location of the ship.thanks kf,jeremy, both work perfectly ;)
And, just like that, i got into assets :)
Great. Updated my answer to also give a
cursor()
example -- althoughimage()
is more flexible.wish people on stack exchange were as helpful as you..