The objective I’m trying to reach is to make smooth, 2-D movement in processing’s python mode. I understand that python processing isn’t nearly as popular as Java, but I need to do it for a school project.
I don’t know Java at all, and because python is so unpopular on processing, I wasn’t able to find much help on legacy forum posts. My movement, while fishy, still works in the X and Y axis, but diagonals are a complete no-go, and overall is really uncomfortable to use.
I’m aiming for something like this:
If you want to try my code: have a look for yourself!
PlayX = 1280 / 2 PlayY = 720 / 2 def setup(): size(1280, 720) background(255) frameRate(60) def draw(): global PlayX, PlayY if keyPressed: if key == 'w': PlayY -= 10 pushMatrix() # activating translation grid background(255) # painting over previous circle ellipse(PlayX, PlayY, 55, 55) #drawing the player translate(10, 0) # translation popMatrix() # deactivating translation grid if key == 'a': PlayX -= 10 pushMatrix() background(255) ellipse(PlayX, PlayY, 55, 55) translate(-10, 0) popMatrix() if key == 's': PlayY += 10 pushMatrix() background(255) ellipse(PlayX, PlayY, 55, 55) translate(0, 10) popMatrix() if key == 'd': PlayX += 10 pushMatrix() background(255) ellipse(PlayX, PlayY, 55, 55) translate(0, -10) popMatrix()
Any help would be really appreciated.