Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

195
Vistas
What does vx and vy denote in graphics?

HI I'm making a small 2d game as my first project and I found this cool example online at https://ebiten.org/examples/sprites.html.

I'm just wondering what the meaning and purpose of vx, and vy is in the sprite structure (code snippet below). Thanks!

type Sprite struct {
    imageWidth  int
    imageHeight int
    x           int
    y           int
    vx          int
    vy          int
    angle       int
}
about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

They're the X and Y velocity of the sprite. See this code in the Update() method:

    s.x += s.vx
    s.y += s.vy

Each time the sprite moves, its position is incremented by these two values.

about 4 years ago · Santiago Trujillo Denunciar

0

vx and vy usually mean "velocity X" and "velocity Y." The velocity is used to move the player, by incramenting the player position by the velocity, like this:

player.posX += player.velX
player.posY += player.posY

However, this can be taken one step further, for more realistic movement, by creating an acceleration variable, like so: vel += acc and pos += vel.

Then, this can be used like this:

player.velX += player.accX
player.posX += player.velX

player.velY += player.accY
player.posY += player.velY

It works very similarly, but this allows the velocity to be slowly incremented, thus slowly incrementing the player position, which provides a neat and realistic acceleration effect.

Hope this helps!!

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda