Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

10 years ago by SebastianKG

Maybe this is obvious, but I didn't find anything from various Google searches: is there an easy or built-in way to have the edges of the screen loop to the opposite side, like in Asteroids or Pac-Man?

10 years ago by stillen

Do you mean the background, like a tiled background, or the player jump from onside to another?

10 years ago by FelipeBudinich

You could do something like this inside the entity's update function:

if (entity pos x > screen width) { entity pos x = 0 - entity width }
if (entity pos y > screen height) { entity pos y = 0 - entity height }

10 years ago by Joncom

Like FelipeBudinich said, use an if statement to check if the entity has gone past the edge of the screen and, if so, move it to the other side.

10 years ago by SebastianKG

Ah okay, I thought of that but I guess it didn't seem elegant to me. For example, with this solution you would never see one half of the entity on one side and one half on the other: I guess I would have to spawn a new entity on the other side with the same traits, and remove the player control from the other one if I wanted that to happen.

Thanks for the help guys, I'll probably just stick with your solution as the stuff I was talking about above seems pretty annoying/hard.

10 years ago by vincentpiel

You don't have to spawn two entities to get the mirror entity effect, rather just overload the draw() of your player, and draw it twice if it crosses the border.

10 years ago by LazerFriends

Quote from vincentpiel
You don't have to spawn two entities to get the mirror entity effect, rather just overload the draw() of your player, and draw it twice if it crosses the border.


Could you explain overloading the draw() a bit further? N00b here.
Page 1 of 1
« first « previous next › last »