42 videos
238 minutes
We will optimize the game, and first I want to add more steps so that we have to climb, and then skewers. First of all, I found a bug in this code snippet, FloorEntity X is wrong because it is the left edge. I should suffice to put an X to indicate that Scene2D should put it there. Such as coordinates of Scene2D is already good, but boy, I've made a mistake. Now what will I do, yes,
It is that the stage can see smaller to display more the horizon. I'm going down the constant PIXELS_IN_METER 90 to 45. Now everything will be smaller. A) Yes. The grace of this is that now I have somewhere to put more land, and this is easy, because it is the same as what I have done here. The only difference is that now I have to give other parameters, for example, I will put 12 meters away from the origin, by occupying 10 meters,
and laying the groundwork on 2 meters, to make him have to jump. Now it will be a second floor that will appear where you see. Come on! He has jumped well, but very fast. This is a detail that should fix too. I was researching and what I do is, yes, when you jump hit a momentum that the chute It makes you up, but you must go down faster. And I found a way to do this. This test is removed by mistake. What you need to do is, if you're jumping
the player will apply a negative force stronger than the force rise. So not to mess, I'll draw another constant called IMPULSE_JUMP, I'll move Constants, to determine the strength of the impulse. And, now, what I do is introduce a negative force, in the opposite direction IMPULSE_JUMP, and 25% more powerful. With this it will be better. This is done, as I say, by trial and error, but now with more speed low note.
In fact I have now passed, I'll give you 15%. Or I do not know, just because I'm playing too bad. As you can see, I have collided with the edge but is not dead, so what I do is add a little something on the edge of the floor so that when shocks with this edge behave like a skewer. It is adding a object allowed to die if it hits the wall, as it does in the Geometry Dash. This is easy, I must add a new Body, and a new Fixture,
and what I will do is create a new Body, are their own definition. You will be positioned on the left edge. And it will be positioned slightly below medium so that there is exactly in the same position as the other. And then what we'll do is create a new Fixture, as leftbox. I will also do that has only 0.2 meters wide because I do not want to do it big, but I'll give high 0.45 so you can not hit the corner,
because I do not want to die in such cases. Change the variables, so you do not behave strangely. And with this, it is important, finally I assign the fixture of this object UserData, to be Spike to behave like a skewer and die, basically. Assuming there are no errors, It should be correct. If it is. To verify I'll make you print a message on the screen when it dies, GameOver. Now if I make the jump.
As you see, puts GameOver. In fact, not advance. This has to be very thin because if not as you see is a transparent edge, so I'll make it even narrower, 0.02. It should be perfect now. All right. Best. But grace is obviously that if I do good jumps and coordinate well, I do not have that problem and I can move forward. The problem now is that I have gone, so my last modification will cause the camera to follow.
About the Author
Biography: Analyst-Programmer in different languages. Tutor PREMIUM platforms recognized worldwide as CodigoFacilito. Editor Cristalab articles. My YouTube Channel is sponsored by the ANAYA and LaTostadora publisher. I like to explain in detail and give several examples for the avoidance of doubt.