• Empleos
  • Sobre nosotros
  • Empleos
    • Inicio
    • Empleos
    • Cursos y retos
  • Empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

197
Vistas
problems moving a game sprite angle

I have a game sprite that I want to move verticaly, and normally this would be easy with this.x += number, exept for the fact that the x/y of the sprite are relitive to its angle. this can be kinda confusing so I have a example here. enter image description here

in other cases where the picture will not load of something else i have a link examplepicture

it can get kinda long do here is the basic code

this.update = function() {
        ctx = myGameArea.context;
      if (type == "image") {
          
          
ctx.save();
       ctx.translate(300, 200);
        ctx.rotate(this.angle);
        ctx.translate(this.x, this.y)
       
            ctx.drawImage(this.image, 
                this.width / -2, 
                this.height/ -2,
                this.width, this.height);
ctx.restore(); 
        
        
            }else {
        ctx.save();
        ctx.translate(this.x, this.y);
        ctx.rotate(this.angle);
        ctx.fillStyle = color;
        ctx.fillRect(this.width / -2, this.height / -2, this.width, this.height);
        
        ctx.restore();
        
      }
    }



function framethingupdate() {
gamething.update();
}

due to certen issues i am unable to run or provide a demo, however if the full code is needed you can find it her: full code

over 3 years ago · Juan Pablo Isaza
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 Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda