Jump to content

Search the Community

Showing results for tags 'trig'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

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 1 result

  1. Hello, I am building an Oceanic game and need to utilize the water surface. I am swimming fish through the sea however at angle '0' I want to fish to be pointing up and not left. I do this by creating the angle 90 degrees: this.xSpeed = Math.cos((this.fishBody.angle+90)/180*Math.PI) * -this.pSpeed; this.ySpeed = Math.sin((this.fishBody.angle+90)/180*Math.PI) * - this.pSpeed; However, I run into problems down the road with AI Fish.prototype.avoid = function(fishBodx, FishBodY, xsp,ysp){ var targetAngle = this.game.math.angleBetween( xsp, ysp, fishBodx, FishBodY ); if (this.fishBody.rotation !== targetAngle) { var delta = (targetAngle) - (this.fishBody.rotation); this.TURN_RATE = 3; // Keep it in range from -180 to 180 to make the most efficient turns. if (delta > Math.PI) delta -= Math.PI * 2; if (delta < -Math.PI) delta += Math.PI * 2; if (delta > 0) { // Turn clockwise this.fishBody.angle += this.TURN_RATE; } else { // Turn counter-clockwise this.fishBody.angle -= this.TURN_RATE; } // Just set angle to target angle if they are close if (Math.abs(delta) < this.game.math.degToRad(this.TURN_RATE)) { this.fishBody.rotation = targetAngle; } } } What is a good solution to this?
×
×
  • Create New...