Tag Info

Hot answers tagged

5

Step 1 - Don't check collisions in each key, test them at the end In your example, you are checking collisions for each key independantly. This will cause some trouble and code replication. In order to avoid that, I would suggest you use temporary variables that will stock the movement, increment it for each key and test collisions only once at the end: ...


1

You're right, it can be done in two ways: -Moving the player -Moving the world This seems like a 50-50 deal. It doesn't matter how you do it, right? I don't agree. I would ALWAYS suggest moving the player. Because if you choose to move the world now, and a few months further on in development, when you have enemies, npc's, and other entities on screen, ...


1

The keyword you're looking for is "easing". There are lots of different easing functions that behave and look different but all of them interpolate some variable from A to B given a time T. If your ship is at A and you want it to decelerate until it hits B, you can give it a velocity by, for example, applying this function: template<class T> inline T ...


1

Libgdx does not handle this itself, you need to take care about collision detection + collision response yourself. One possible solution would be Box2D, a 2D physic engine. It takes care about forces, mass, friction and other physical things. It also detects and handles collisions for you. It is also possible to let Box2D just detect the collision and notify ...


1

Your main character class should not have a reference to the keyboard or any input-related class. Input should be handled in the game loop, or preferably a dedicated input class, decoupled from other entities so they'll only need to respond to abstract actions, not raw input. Not all input is related to your characters and and not all types of input devices ...


1

When I make a physics part of a game, Personally I don't like to fix or modify basic physics constants. ex) gravity. So, I suggest you to add delta time concept in your physics. When the object jumps up, time is passing fast. When the object goes down, the time become slow. I modified your js fiddle sample source. this is not exactly what I want to ...



Only top voted, non community-wiki answers of a minimum length are eligible