[SOLVED] S4P best movement for the player in the world

Hey Guys !

I am working on a game. And I have been incorporating S4P and I was thinking what is the best to move the player within the world. Currently I keep the player in the middle of the screen and just used S4P.moveWorldBy(). Any better take ons ? Or is this fine ?

Thanks in advance!

1 Like

I have not seen your game but one problem might be disorientation because the world is always moving.

Another approach you might consider is to allow the player to move within a rectangular area that is smaller than the sketch window box but also centred on the sketch window, then only move the world if the player attempts to leave this area.

1 Like

Hey There!

The world is large, players can move freely and the sketch window only gets to see a portion of it. So I am looking for a good camera system. As you said shifting the world will be disorientating especially that there are tiles and enemies. Does S4P encorpora! te any camera system ? If not any take on a library that does ?

Also soon I will feature a demo of the game here ! To receive criticism on how to improve it ! As I plan to release it!


So that how the world looks like . And I am trying to see what the best way to move the camera then !

I worked that one out myself :grinning:

S4P is a 2D sprite system so a camera system would simply decide on where the centre of the viewable area is and the display scale. S4P provides several methods to change this view e.g.

moveWorldBy(px, py)
moveWorldTo(px, py)

plus methods to convert between world and display coordinates.

So although S4P does not have a camera system per se all the core stuff is there to represent a camera. It is unlikely that a 3rd party camera system would integrate as well with S4P.


So I guess I am on the right track ! I guess I am just gonna make a wrap around class for moveWorldBy. Also the .isOnSceeem() works great for only rendering tiles that are seen on the screen I love it. That also fixed the issue from my ControlP5 post!

I am a great fan of object orientated programming so creating a camera class could be good provided there is a real need for the class and its design is based on sound object orientated principles.

1 Like

There is a need indeed! I will make sure to make a sophisticated one. Before the end of tonight I will showcase what has been done. To receive feedback on improving performance !

Hey so the best method I found was use translate(player posx - width/2 , player posy - height/2)
As moveWorldBy didn’t work as the game features LAN.

1 Like