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
​ The _____ attribute tells a browser to parse the HTML and JavaScript code together, only pausing to process the script before
slava [35]

Answer:

"async" attribute

Explanation:

the async attribute is used on the html script tag, it is a Boolean attribute indicating that the browser should, if possible, load the script asynchronously and then parse it as soon as it’s downloaded.

7 0
4 years ago
Whats your favorite thing about tech
Lera25 [3.4K]
How it advances our lives and helps us in so many ways
5 0
3 years ago
Read 2 more answers
g You need to create a program that will read the scores from the CSV file, pass the scores as a list to the finalGrade function
Goshia [24]

Answer:

def finalGrade(scoresList):

""" Function that finds the final grade """

hw1_weighted = float(scoresList[0])/10 * 0.05

hw2_weighted = float(scoresList[1])/10 * 0.05

mid_weighted = float(scoresList[2])/100 * 0.40

fin_weighted = float(scoresList[3])/100 * 0.50

final_grade = (hw1_weighted + hw2_weighted + mid_weighted + fin_weighted) * 100

return final_grade

if __name__ == '__main__':

''' Reading and processing scores '''

# Reading names from text file

names = []

# Opening text file

with open("d:\\Python\\names.txt", "r") as fp:

# Reading data

for line in fp:

# Stripping new line

line = line.strip()

# Adding to list

names.append(line)

# Reading scores

finalGrades = []

# Reading scores

with open("d:\\Python\\scores.csv", "r") as fp:

# Reading data

for line in fp:

# Stripping new line

line = line.strip()

# Scores list

scores = []

# Iterating over scores

for score in line.split(','):

# Adding to list

scores.append(score)

# Finding grade

grade = finalGrade(scores)

# Adding to list

finalGrades.append(grade)

# Printing result

for i in range(len(names)):

print("\n%s earned %.1f%%"%(names[i], finalGrades[i]))

Explanation:

This program was implemented with python programming language.

This program will read the scores from the CSV file, pass the scores as a list to the finalGrade function, and display the resulting final grade, along with the student's name.

See attachment for screenshots

6 0
3 years ago
What are three different reasons why people access networks? <br> Give an example of each reason
denpristay [2]

Communication: Communication is one way to be connected to the network and use the internet. It helps maintains communication with other network users. A few examples include email, IM services, video conferencing, Skype and many more.

File sharing: Easily sharing files and data. From businesses to schools to friends, everyone sends files to through internet and this has become an essential part of life. Various services like Gmail and yahoo mail are used.

Social networking: This is an essential medium to communicate with friends and family members. Examples include Facebook, Twitter, and Instagram.






3 0
4 years ago
Fourlotts Corp. provide integrated services that include storing manufactured goods, packaging, and delivering it to the dealers
PilotLPTM [1.2K]

Answer:

The answer is "Logistics provider of third parties".

Explanation:

In the given statement some information is missing, that is options, which can be described as follows:

a.Center for Allocation

b. Logistics provider of third parties

c. supplier

d. Manufacturer with contracts

The company provides contracted logistics facilities provided by any part of the sourcing and distribution operations. In the 3PL will have a specific definition for any service agreement requiring processing or shipment of goods, and certain choices were wrong, which can be explained as follows:

  • In option a, It includes products and services.
  • In option b, It is a person that provides the products.
  • In option d, It enables the customer to get off an incredibly important project, that saves a lot of cash.

7 0
3 years ago
Other questions:
  • In a word processing program, the ribbon or menus contain the
    12·1 answer
  • You are the system administrator for a medium-sized Active Directory domain. Currently, the environment supports many different
    7·1 answer
  • To what does the term computer hacking refer?
    10·2 answers
  • The memory process of retaining information received is called __________.
    9·2 answers
  • Select the three early tools that were prototypes of modern farming tools used for harvesting crops.
    14·1 answer
  • A key requirement for the process of testing hypotheses in the scientific method is Group of answer choices experimenter bias. c
    9·1 answer
  • The number of pixels displayed on the screen is known as ​
    12·1 answer
  • What is the reason for taking care of design a good computer human interface ​
    9·1 answer
  • Write a statement that takes a variable named file_object that contains a file object and reads its contents into a Python list
    7·1 answer
  • HELLO. Which of the following is NOT a way to control the flow of a program?
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!