O'Reilly logo

Slick2D Game Development by Jacob Bevilacqua

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using input for movement

One of the most common uses for user input is movement including player, camera, item, and so on. The most effective way to represent movement and position in two-dimensional space is using vectors. Vectors are used in both two-dimensional and three-dimensional games.

Basic overview of vectors

For the purpose of game development a vector has a position, direction, and magnitude. In Slick2D the most important aspect of vectors is the position. Let us break down a vector into its three components.

Vector position

Position is the location of the starting point of a vector. Vectors may be expressed in several dimensions. A one-dimensional vector will only have an x or y value, not both. A two-dimensional vector will have both ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required