Concept explainers
a)
To create a moveBubble() method which moves the bubble across the bubble box, this method accepts two argumentsheight and width which represent height and width of the object and declaring variables, bubbletop equal to the value of the yPos property, bubblebottom equal to the sum of the yPos and radius properties, bubbleLeft equal to the value of the xPos property, and bubbleRight equal to the sum of the xPos and radius properties.
b)
To declare a conditional if statement inside the moveBubble() method,for the bubbletop if it is less than zero or bubbleBottom is greater than the height argument, then the bubble has hit the top or bottom wall and if the condition is trure then changing the direction of the vertical velocity by letting this.yVelocity equal this.yVelocity.
c)
To declare a conditional if statement inside the moveBubble() method, for the bubbleLeft is less than zero or bubbleRight is greater than the width argument, the bubble has hit the left or right wall and if the condition becomes true then changing the direction of the horizontal velocity by letting this.xVelocity equal this.xVelocity.
d)
To declare new location to move the bubble by adding the value of the yVelocity property to yPos and adding the value of the xVelocity property to xPos inside the moveBubble() method.
Want to see the full answer?
Check out a sample textbook solutionChapter 14 Solutions
Bndl: Llf New Perspectives Htm L5 Css3 & Javascript, 6th Edition
- (Using R language)arrow_forwardAfter our initial deployment for our ML home based security system, the first steps we took to contribute further to the project, we conducted load testing, tested and optimize for low latency, and automated user onboarding. What should be next?arrow_forwardWhy investing in skills and technology is a critical factor in the financial management aspect of system projects.arrow_forward
- New Perspectives on HTML5, CSS3, and JavaScriptComputer ScienceISBN:9781305503922Author:Patrick M. CareyPublisher:Cengage LearningNp Ms Office 365/Excel 2016 I NtermedComputer ScienceISBN:9781337508841Author:CareyPublisher:Cengage