Search the Community

Showing results for tags 'degrees'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 3 results

  1. I'm thoroughly confused about radians and degrees! Been a long time since high school math I'd like to get the rotation of an object (currently being returned in radians), convert that to degrees, and allow for a variance of a few degrees. So a player is rotating the object to line it up with another object, and I'm checking that the rotation is correct. The rotation should be 180 deg, give or take a few degs (so 175 to 185 deg). However, my rotation is converting as where approx 185 is shows up as -175... Basically once it hits 180 it converts into a negative number, backwards from 180. I've got this.rot = rotationOfSprite; var degs = this.getDegrees(this.rot); console.log(degs); getDegrees: function(){ var degs = this.rot * 180/Math.PI; return degs; } SOLVED. Figured it out. Thanks (future ref: if(this.rot<0) this.rot +=2*Math.PI.
  2. Hi, yesterday i was struggling with rotation of an enemy. In my game you drive a spaceship and the enemies should rotate to your location in the nearest way (left or right), so they can follow you. This seems to be simple, but i find some problems in the rotation degrees. First i have to find the angle that the enemy should have, to point to my spaceship. I find two ways to do it. The first doesn't work: angle = game.physics.arcade.angleBetween( this , player ); // returns angles between something like 3.1 and -3.1// ( this = Enemy class )I don't know why. Maybe because i am using p2 physics and not arcade? The second works: angleRadians = Math.atan2(this.position.y - player.position.y, this.position.x - player.position.x);angle = Math.atan2(this.position.y - player.position.y, this.position.x - player.position.x) * 180 / Math.PI;// returns 180 to -180So i use that instead. Here I find something strange, the 0° angle in the Enemy is on Top. But, the 0° angle returned in the var angle is on the left. ( both ways in clockwise ) Finally i try doing something tricky like this, but doesn't work properly: if( this.body.angle+180 - angle-90 <= 180 && this.body.angle+180 - angle-90 >= 0 ){ this.body.angle += .6;}else{ this.body.angle -= .6;} May if I figure out why the degrees are different, i can get it work. Thanks!
  3. I am using some art of a player character for a top down game I am making - the art is here: http://opengameart.org/content/top-down-mage-animations The sprite is orientated so that the mage's face / front is facing upward (north). I'm having some issue with rotation, with both mouse movement and keyboard movement. For example, I have this "hack" that adds additional radians to a calculated angle in order to get the mage's "front" to face the pointer instead of the right shoulder: this.rotation = this.game.physics.arcade.angleToPointer(this, pointer) + 1.57079633; Is there an easier way to handle this? I'm running in to the same issue attempting to use angular velocity for keyboard movements: this.game.physics.arcade.velocityFromAngle(this.angle, 300, this.body.velocity); The goal is to get wasd to rotate and move the character similar to the example here: http://examples.phaser.io/_site/view_full.html?d=arcade%20physics&f=angular+velocity.js&t=angular%20velocity) What is the best way to get the front of the sprite to face the direction the sprite is moving? I will also be having objects that "shoot" out from the front of the sprite, which will have to be based on it's rotation so I'd rather calculate the offset a single time instead of all over the place... Let me know if this makes sense. Thank you!