1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
stiks02 [169]
3 years ago
15

I have a question about Java Script How do I make gravity working on a game and need to know not in a rush though

Computers and Technology
1 answer:
lisov135 [29]3 years ago
4 0

Answer:

Explanation:

To add this functionality to our component constructor, first add a gravity property, which sets the current gravity. Then add a gravitySpeed property, which increases everytime we update the frame:

Example

function component(width, height, color, x, y, type) {

 this.type = type;

 this.width = width;

 this.height = height;

 this.x = x;

 this.y = y;

 this.speedX = 0;

 this.speedY = 0;

 this.gravity = 0.05;

 this.gravitySpeed = 0;

 this.update = function() {

   ctx = myGameArea.context;

   ctx.fillStyle = color;

   ctx.fillRect(this.x, this.y, this.width, this.height);

 }

 this.newPos = function() {

   this.gravitySpeed += this.gravity;

   this.x += this.speedX;

   this.y += this.speedY + this.gravitySpeed;

 }

}

You might be interested in
What does the word "e-business" mean?
Zepler [3.9K]
It stands for Electronic Business, a typical example of this is a online store.
4 0
3 years ago
Read 2 more answers
Why have countries requested for the removal of content?
Kipish [7]
These links should help u:
https://support.google.com/transparencyreport/answer/7347744?hl=en

https://searchengineland.com/most-censorship-and-content-takedown-requests-come-from-us-says-google-...
5 0
3 years ago
"Which of the following will help protect against a brute force attack?
Effectus [21]

Answer:

B

Explanation:

A complex and unpredictable password would prove very hard to guess or deduce for any attacker.

3 0
4 years ago
What do you understand by the term polysome?​
jasenka [17]

Answer:

A polyribosome (or polysome or ergasome) is a group of ribosomes bound to an mRNA molecule like “beads” on a “thread”. It consists of a complex of an mRNA molecule and two or more ribosomes that act to translate mRNA instructions into polypeptides.

6 0
3 years ago
Whats the size of a short bond paper in microsoft word?
poizon [28]
I believe the size is 8.5x11
7 0
3 years ago
Other questions:
  • What is the circular motion that the earth makes in its orbit around the sun
    14·1 answer
  • Alison retrieved data from a company database containing personal information on customers. When she looks at the SSN field, she
    14·1 answer
  • Common icons found on the Windows desktop are _____.
    6·2 answers
  • What happens if you never confirm your facebook account?
    8·1 answer
  • Alessandro wants to use his desktop computer to video chat with his mother. What hardware does he need to accomplish this?
    9·1 answer
  • Problems of mobile phones
    8·1 answer
  • Members of the sales team use laptops to connect to the company network. While traveling, they connect their laptops to the inte
    15·1 answer
  • Help<br> pls need quickly
    9·1 answer
  • Terrell, a programmer, is creating a website for an online merchant and wants the program to calculate the total price based on
    14·2 answers
  • True or false. A plug-in card is always required to support pc sound
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!