# Explaining “dx” and “dy” as ball properties

A ball in a 2D volleyball game is described by 4 variables, x , y, dx and dy. What exactly does it mean by dx and dy?

• Without providing more detail, it would just be a guess. They are variables. We do not know the variable type, nor do we know how they are used. You only provide the variable name. – jgallant Nov 4 '16 at 9:37
• I have unfortunately only these informations as in my post. – Tkininter Nov 4 '16 at 9:45
• My guess is that they are the delta position, or the previous position, of the ball. – jgallant Nov 4 '16 at 9:48
• I've seen this before, in computer graphics. Hopefully my diagrams provide more insight. – Gnemlock Nov 4 '16 at 9:53
• Typically, it means Delta. Or distance/difference moved. – Krythic Nov 4 '16 at 17:28

## 3 Answers

I have encountered this, before, when dealing with computer graphics. In these cases, x and y are the co-ordinates for the center of the circle, while dx and dy are the dimensions (or commonly, the diameter) of the circle.

This seems especially valid in the described scenario, even if the volleyball would typically be a perfect circle (i.e. we only need a single diameter, as dx == dy). This is not always the case, in animation. A common practice for basic shapes is to simply alter the width or height with movement, to show greater animation.

I guess it is the speed of the ball.

At each frame, you can update the coordinates of the ball by doing

x = x + dx;
y = y + dy;


You should not update the position as written above in real life. If you are doing this in a game loop you should always keep track of the "delta", the time between 2 frames. That way, even if users have a different FPS, the ball will still move the same.

The code will look like :

x = x + dx * delta;
y = y + dy * delta;


The more time between 2 frames, the more distance traveled by the ball.

• Please note that if you want to check previous versions or changes to a post (including your own), you can click on the "edited x min ago" link. This is a better alternative then adding the "edit:" ammendments that are more commonly associated with forums. +1 for adding the info on why you would not just use position and speed; I see people miss that one a lot. – Gnemlock Nov 4 '16 at 10:02

The dx and dy naming convention comes from calculus. In calculus you often find the derivative of a function which is often read as "the change in x" or "the change in y". These terms are notated using dx, dy, dz, etc. You can read more about it here.