11.1.2 Ball and Paddle Code HS JavaScript



Overview

Add the ball and paddle. The ball should bounce around the screen. The paddle should move with the mouse.


Add Ball and Paddle

The first step is to add the ball to the center of the screen, and the paddle to the bottom of the screen. The dimensions of the paddle and its offset from the bottom of the screen are already constants in the starter code.


The next step is to get the paddle to move when you move the mouse. The paddle should be centered under the mouse, and should not go offscreen.


Move Paddle, Bounce Ball

The next step is to get the ball to bounce around the screen. We may have done this exact problem before…

Answers

Answer 1

Using the knowledge in computational language in JAVA it is possible to write a code that Add the ball and paddle. The ball should bounce around the screen. The paddle should move with the mouse.

Writting the code:

function setupBall(){

ball = new Circle(BALL_RADIUS);

ball.setPosition(getWidth()/2, getHeight()/2);

add(ball);

}

function setupPaddle(){

paddle = new Rectangle(PADDLE_WIDTH, PADDLE_HEIGHT);

paddle.setPosition(getWidth()/2 - paddle.getWidth()/2,

 getHeight() - paddle.getHeight() - PADDLE_OFFSET);

add(paddle);

}

function getColorForRow(rowNum){

rowNum = rowNum % 8;

if(rowNum <= 1){

 return Color.red;

}else if(rowNum > 1 && rowNum <= 3){

 return Color.orange;

}else if(rowNum > 3 && rowNum <= 5){

 return Color.green;

}else{

 return Color.blue;

}

}

function drawBrick(x, y, color){

var brick = new Rectangle(BRICK_WIDTH, BRICK_HEIGHT);

brick.setPosition(x, y);

brick.setColor(color);

add(brick);

}

function drawRow(rowNum, yPos){

var xPos = BRICK_SPACING;

for(var i = 0; i < NUM_BRICKS_PER_ROW; i++){

 drawBrick(xPos, yPos, getColorForRow(rowNum));

 xPos += BRICK_WIDTH + BRICK_SPACING;

}

}

function drawBricks(){

var yPos = BRICK_TOP_OFFSET;

for(var i = 0; i < NUM_ROWS; i++){

 drawRow(i, yPos);

 yPos += BRICK_HEIGHT + BRICK_SPACING;

}

}

function setSpeeds(){

vx = Randomizer.nextInt(2, 7);

if(Randomizer.nextBoolean())

 vx = -vx;

}

function setup(){

drawBricks();

setupPaddle();

setupBall();

setSpeeds();

}

See more about JAVA at brainly.com/question/18502436

#SPJ1

11.1.2 Ball And Paddle Code HS JavaScriptOverviewAdd The Ball And Paddle. The Ball Should Bounce Around

Related Questions

What is the definition of alternative technology?

Answers

Answer:

Alternative technology is a term used to refer to technologies that are more environmentally friendly than the functionally equivalent technologies dominant in current practice.

Explanation:

Answer:

Alternative technology, also known as appropriate technology or sustainable technology, refers to technologies that are designed to be environmentally friendly and socially responsible. These technologies often use renewable or reusable resources and are intended to improve the quality of life for individuals and communities without causing harm to the environment. Examples of alternative technology include solar panels, wind turbines, and composting toilets.

How many parameters does the create_frame function take?

Answers

The numbers of parameters that the create_frame function accept  is one that is at least 127 parameters.

What is the create_frame function parameters?

A new frame structure is created via the createFrame() function. A new frame structure is created via the createFrame() function. It adds the header data, including the start delimiter, frame type, Serial ID, Waspmote ID, and sequence number, after clearing the frame buffer. The addSensor() function should be used to add sensor fields to the payload after this function has been called.

Therefore, without more details about the method, I am unable to determine how many parameters the create frame function requires.

Depending on its intended usage and the environment in which it is called, the create frame function may accept any number of parameters. It is impossible to correctly estimate the number of parameters a function requires without more details.

Learn more about function  from

https://brainly.com/question/29851234

#SPJ1

How has programming changed in the past 50 years?

Answers

Answer:

programming has changed in the past 50 years because of the introduction of new languages and the introduction of new technologies.

37. where a preprinted form contract is used: a) preprinted words in a contract prevail over typed words; b) handwritten words prevail over both preprinted and typed words; c) typed words prevail over both handwritten and preprinted words; d) preprinted words prevail over handwritten words

Answers

A preprinted form contract is used in  typed words prevail over both handwritten and preprinted words.

What is preprinted form contract ?

A standard form contract, also known as a contract of adhesion, a leonine contract, a take-it-or-leave-it contract, or a boilerplate contract, is an agreement between two parties in which one of the parties sets the terms and conditions and the other party has little or no power to negotiate for more advantageous terms, leaving the other party in a "take it or leave it" position.The possibility of being unconscionable exists even if these contracts are not inherently unlawful. Additionally, ambiguities will be decided contra proferentem, or against the party who drafted the contract language, in the event of a dispute.

To learn more preprinted form contract  refer to:

https://brainly.com/question/13651174

#SPJ4

[2 marks]
The company found that the lights were turning on too early in the summer, and too late in the
winter. They decided to change the street light design so that they turn on when the light levels
are below a certain value.
Name a suitable input device for this system. Give a reason for your choice.
Input device: ..
Reason:

Answers

Answer:

A light sensor, it will detect the light, if there is not enough, the streetlights will have to be turned on.

Explanation:

Answer:

One suitable input device for this system could be a light sensor. The reason for this choice is that the light sensor can measure the ambient light levels and provide input to the system to determine when the street lights should be turned on or off. This allows the system to respond dynamically to changes in the light levels and ensure that the street lights are turned on at the appropriate times.

which of the following is true? the authentication header protocol (ah) provides source authentication, data integrity, and confidentiality. the encapsulation security protocol (esp) provides source authentication and data integrity, but not confidentiality. the authentication header protocol (ah) provides source authentication and confidentiality, but not data integrity. the encapsulated security protocol (esp) provides source authentication, data integrity, and confidentiality.

Answers

Encapsulated security protocol (ESP) offers data integrity, confidentiality, and source authentication.

A protocol is exactly what?

The protocol is a collection of instructions for exchanging data. Each step and method of interaction between a number of computers has a set of rules that apply to it. For networks to transport information, they must abide by certain guidelines.

Which two primary protocols are there?

Although there are other protocols in the suite, both TCP & IP are really the two most common. The TCP/IP protocol stack serves as such an intermediate device between the routing & changing fabric and network applications. TCP (Transfer Internet Control message protocol) and IP are the two most significant protocols for information transmission through the Internet (Internet Protocol).

To know more about protocol visit:

https://brainly.com/question/27581708

#SPJ4

true or false: using the limiters in quick search is helpful because you can limit your results by such limiters as date or whether or not it is peer-reviewed.

Answers

Using the limiters in quick search is helpful because you can limit your results by such limiters as date or whether or not it is peer-reviewed is true.

Why are limiters used in research?

You can use limiters to focus your search so that the data you retrieve from the databases you search is constrained by the values you choose. If more than one limiter is available, you may use more than one of them.

Therefore, a person can have the choice of restricting your search to papers with references, articles with a specific publication date, or only scholarly (peer reviewed) journals. Simply choose the desired option, then update the results. There will be some relevant and some irrelevant articles in your result list.

Learn more about limiters  from

https://brainly.com/question/25609681
#SPJ1

Marisol wants a data structure that is as flexible and controllable as possible. Which of these would be most appropriate?

A. primitive
B. Built-in
C. User-defined
D. String

Answers

Answer:

B. Built-in

Explanation:

You can modify built-in data structures like adding elements to an array and removing elements.

However, creating a data structure is more time-consuming such as manually sorting a list instead of using the built-in sort function.

New methods for video game operation are still being invented.

A.
True

B.
False

Answers

Answer: A

Explanation: True

you work as a network administrator for stormwind. you have been asked to look at a windows 10 system for some of the windows 10 hidden files. how will you unhide the hidden files?

Answers

Data that is fragmented is reorganized by Windows' Disk Defragmenter to improve the performance of your disks and devices.

Is disk defragmentation beneficial?

Why should you defrag? Defragging your computer can help to address and avoid a variety of issues. If you don’t defrag your hard disk on a regular basis, your computer may operate slowly and/or take a long time to boot up once you turn it on. If your hard disk is too fragmented, your computer may freeze or fail to boot.

Defragmentation reassembles the fragmented fragments of data. As a consequence, data are stored in a continuous way, making it easier for your computer to read the disk and get the files you want, enhancing your PC’s overall performance.

To learn more about disk defragmentation, visit:

brainly.com/question/14940701

#SPJ4

Visual aids generally make a speaker

Feel more comfortable
More effective in delivering his/her message

Answers

Answer:

Visual aids generally make a speaker More effective in delivering his/her message

Explanation:

i hope this helps

Isabella is creating a video game and wants to include a unique mental obstacle. Which of the following should Isabella consider adding to her game? A. a riddle or puzzle B. a wall to jump over C. an enemy with a sword D. dynamite

Answers

An enemy with a sword ⚔️

Answer:

A. a riddle or puzzle

Explanation:

Isabella should consider adding a riddle or puzzle to her game as a unique mental obstacle. Riddles and puzzles are challenges that require players to use their mental abilities to solve them. They can be a fun and engaging way to add an extra level of difficulty to a game.

Complete the code to create a new file.
aFile = open("stuff.txt", "__")

Answers

Answer:

aFile = open("stuff.txt", "w")

which function returns the contents of a cell at the intersection of a specified row and column from a range?

Answers

The INDEX function extracts a value from a table or range or a reference to a value and returns it.

What is array?

The INDEX function can be applied in one of two ways: See Array form if you wish to return the value of a specific cell or array of cells. The row and column numbers you enter determine how the INDEX array form calculates the value of each element in a range or array. A table or range of cells is called an array. The row number in the array is the one from which a value should be returned.

Column number is necessary if row number is left out. Excel's OFFSET function provides a cell or range of cells that are a specified number of rows and columns away from a starting point.

To learn more about INDEX from given link

brainly.com/question/14297987

#SPJ4

bluetooth is the popular name for the 802.15 wireless networking standard, which is useful for creating small __________.

Answers

Answer:

personal area networks (PAN)

Explanation:

which of the following is not an acceptable javascript variable name? a. one name b. thefirstname c. name one d. 1name

Answers

A number cannot start the sentence. The variable name can be finished off with any letter, number, or underscore. Some characters, including spaces, symbols, and punctuation, are prohibited. Variable names are case sensitive.

What is the purpose of JavaScript?

Programmers all over the world use Javascript to make dynamic and interactive online apps and browsers. With 97.0% of all websites using it as a client-side programming language, JavaScript is the most widely used programming language in the world.

Python versus JavaScript: which is simpler?

You should be aware that JavaScript is more harder to learn than Python if you're trying to decide which computer language to learn initially. Both are dynamically typed, high-level programming languages, and they resemble one another quite a bit.

To know more about JavaScript visit;

https://brainly.com/question/28448181

#SPJ4

If randi wants to draw attention to a quote she's placed on a slide, what type of alignment should she use? question 21 options: center left right full

Answers

Answer: i think its the left

Explanation: I'm on the same question and thats what I usually see

The answer is center

Explanation: I took the test ^^

Creating compelling visuals for presentations requires people to learn what new tools? question 15 options:
a. gaming software
b. language translation software
c. design software
d. audio recording software

Answers

Creating compelling visuals for presentations requires people to learn new tools such as c: design software.

A presentation is made compelling by adding visuals and graphics that allow a reader to better understand the topic of the presentation. In order to make the presentation to be more compelling, it is required that you learn new tools to design software that enable you to add themes, templates, charts, graphs, shapes, and fonts. All these tools of design software help a presenter to make a presentation more compelling.

You can learn more about presentations at

https://brainly.com/question/24653274

#SPJ4

PLS HELP ASAP!!!!
Which (active or passive) do you need to be most concerned with? Why?

Answers

Elaborate please, I do not understand what you mean by "active or passive".

jose recently noticed a virus on his system and that it is using encryption to modify itself. the virus is able to escape detection by signature-based antivirus software. what type of virus has jose discovered

Answers

Jose really discovered adware on his device that is using encryption to change itself. Logo antivirus software may fail to detect the infection. The virus is polymorphic.

Describe what an antiviral is.

Virus removal software is designed to locate and remove viruses and other harmful material from any laptop or computer. Malicious software, sometimes referred to as malware, is computer software that has the potential to harm both your computers and the data you hold.

Briefing :

The primary body of polymorphic viruses is duplicated and kept in an encrypted state by a secondary encryption engine. The virus just exposes basic encrypt routine for potential detection. The virus incorporates its slave into the decryption process, which takes control of the target system and exposes the main body of the infection. it can execute.

To know more about Antivirus visit :

https://brainly.com/question/14313403

#SPJ4

The game Just Dance involves players copying the dance moves of the actors in the game. What kind of game mode does Just Dance use?

A.
turn-based game mode
B.
card-based game mode
C.
King of the Hill game mode
D.
movement game mode

Answers

Answer:

D. movement game mode

Explanation:

Just Dance uses a movement game mode. In a movement game mode, players are required to use physical movement, such as dancing, to play the game. This type of game mode is often used in games that involve dancing, sports, or other physical activities.

Just Dance is a game that involves players copying the dance moves of the actors in the game. In order to play the game, players need to move their bodies and perform the dance moves that are shown on the screen. This type of gameplay is characteristic of a movement game mode.

what is the code? im stuckk

Answers

sum=0

c=0

while(1):

   tmp = int(input("Enter a number: "))

   sum+=tmp

   c+=1

   if(sum>200):

       print("\nSum:",sum,"\nTotal number entered:",c)

       break

   else:

       continue

Answer:

sum = 0

count = 0

while sum < 200:

   number = int(input("Enter a number: "))

   sum += number

   count += 1

print("\nSum:", sum)

print("Number's Entered:", count)

Explanation:

The while loop will keep running until the sum is greater than 200. The sum will be added to the number that the user inputs and the count will be added by 1. Once the sum is greater than 200, the program will print the sum and the count of how many numbers were entered.

you are the network administrator for a large organization. you need to watch some of the main components on a windows server. these include the memory, cpu, network, and disk. what utility can you use to get a quick overview of these four components? group of answer choices system configuration

Answers

B: Resource Monitor is the required utility that can be used to get a quick overview of the memory, CPU, network, and disk.

On Windows Server, the Resource Monitor utility permits you to go in-depth to get insight that the Task Manager cannot display. This utility is can be used to determine how programs have been using computer resources over time.

Based on the given scenario where a network administrator of a large organization needs to overview the four main components, such as the memory, CPU, network, and disk, on a Windows Server, In order to meet this goal, the network administrator will use the utility called Resource Monitor.

"

Complete question:

you are the network administrator for a large organization. you need to watch some of the main components on a windows server. these include the memory, cpu, network, and disk. what utility can you use to get a quick overview of these four components? group of answer choices

A: system configuration

B: Resource Monitor

C: Task Manager

D: None of them

"

You can learn more about Resource Monitor at:

https://brainly.com/question/13175719

#SPJ4

Why does a game need to have an objective? A. so that the player knows the point of the game B. so that the player won’t get dizzy while playing the game C. so that the player can always win the game D. so that the player will never beat the game

Answers

Answer:

A. so that the player knows the point of the game

Explanation:

A game needs to have an objective so that the player knows the point of the game. The objective of a game is the goal or purpose of the game. It is the reason why the game exists and what the player is supposed to accomplish.

Having an objective is important because it gives the player a clear understanding of what they are supposed to do in the game. This helps to engage the player and motivate them to play the game. Without an objective, the player may not know what to do or why they are playing the game, which could lead to confusion and lack of interest.

suppose we sample music at a rate of 35 khz and quantize with 16 bits/sample. how many bytes are needed to store a 2-minute song in stereo? express your answer in terms of mb where 1mb

Answers

1Mb = 1/8 MB = 0.125 MB bytes are needed to store a 2-minute song in stereo.

How you figure out how many bytes are required to store a sound file?The rule of thumb for MP3 audio is that 2 minute of audio takes up about 2 megabyte.First, we need to compute the bit rate by multiplying the sampling frequency to its bit depth multiplied by the number of channels.Then  We multiply the determined bit rate to  the length of the recording in seconds. Audio recorded at 192kHz/24-bit takes up 6.5x the file space of audio recorded at 44.1kHz/16-bit.To calculate the file size of an audio file, multiply the bit rate by the audio’s duration in seconds. As a result, we obtain file size numbers in kilobits and megabits.

To learn more about bytes visit to

https://brainly.com/question/12996601

#SPJ4

if you refer to an identifier without declaring it, the compiler will generate an error message. true false

Answers

Answer:

True, Explanation Declaration can be checked during compile time

Explanation:

Which type of server is used to sign in clients that are joined to an active directory domain?.

Answers

Domain Controller...

domain control im pretty sure

your manager asked you to set up a secure network connection at a remote site to move over some back ups. what protocol what do you use

Answers

The protocol that should be used to establish a secure network connection for backups is SSH.

Secure Shell

SSH stands for Secure Shell. SSH is a protocol that allows users to remotely control and modify servers. SSH is commonly used by administrators to manage certain systems or applications remotely. So the admin can enter the computer via the network, then run various commands to modify or manage files from one computer to another.

SSH has several crucial functions for managing data transfer traffic. Specifically, the following are the functions and benefits of SSH:

Securing remote access to SSH-enabled systems or network devices for the user and processing them automatically.SSH will automatically terminate the connection if there is suspicious activity on the connection used. So you can avoid various cyber threats such as IP and DNS spoofing, data manipulation, illegal tracking, and others.Perform automatic and secure file transfers.Launch commands securely on remote devices or systems.Perform secure component management of network infrastructure.

Learn more about Secure network connection: https://brainly.com/question/28083478

#SPJ4

What must be integrated into an organization’s enterprise resource management solution to allow it to create and maintain regulatory and compliance information from a centralized location?.

Answers

A supply chain management system must be connected with an organization's enterprise resource management solution  to develop and maintain regulatory and compliance information from a centralized place.

What is the supply chain management system?

Supply chain management (SCM) is the management of the movement of data, commodities, and finances associated with a product or service, from raw material purchase through final product delivery.

Supply chain management enables firms to deliver more rapidly, assure product availability, decrease quality concerns, and easily navigate returns, eventually creating value both inside the organization and for consumers.

Therefore, it is supply chain management system

Learn more about the management system, refer to:

https://brainly.com/question/19551372

#SPJ1

Suppose you have the following numbers and need them to be written in the two other numbering
systems. Before you could translate them, you would need to identify what numbering system is currently
used. Which numbering systems do the following numbers represent? (4 points)
a) 2C
b) 109

Answers

Answer:

Explanation:

a) hexadecimal

because hexadecimal numbers use 0-9 and letters A-F

b) decimal

109 is just a regular number and the standard numbering system that humans use is decimal

Other Questions
Answer for 10 points! How many ways Berlin symbolized the global struggle between worlds from the Cold War Newton's first law of motion is known asa) mass and accelerationc) electrical forceb) inertia c) action and reactiond) tension forced) momentum which designers recreated photographs by hand because of the limitations of printing and photographic process? a natural disaster has resulted in a company moving to an alternate processing site. the company has operations moved within a few hours as a result of having a building with all of the equipment and data needed to resume services. the alternative site was actively running prior to the natural disaster. evaluate the types of recovery sites to determine which processing site the company is utilizing. A rectangle is 5 inches long and 2x inches wide. The value of the perimeter in inches) is equal to the value of the area (in square inches). Find x. If you rent a car from Caleb's Cars, you'll pay a $61 feeand $24 per day. At Vinny's Vehicles, you'll pay a $105 fee and $20 per day. Determine the number of days you can rent a car from either place and pay the same amount. Use substitution or elimination.Thanks A hollow plastic ball is projected into the air.There is significant air resistance opposing theball's motion, so the magnitude of the ball'sacceleration is not equal to g. At time t, the ball ismoving up and to the right at an angle of 45 tothe horizontal, as shown above. Which of thefollowing best shows the magnitude a and thedirection of the ball's acceleration at time/? Which sentence below is a goodexample of "Expository Writing"?A. She screamed and ran for cover as the blackcloud appeared out of nowhere.B. We think this smartphone is the best in theindustry, and it comes in 15 of your favoritecolors.C. According to seismologists, an earthquakeoccurs somewhere in the world about every 30seconds. When conveiling units, summarize the steps using the direct method based on the information presented which of the following best explains why the resaeachre measured ocugen consumption as an indicator of the effectivenesas of drug x Which of these relations is a function? 714.0g of KBr will decompose fully to produce how many liters of Bromine gas?2KBr (s) 2K (s) + Brz (g) How difficult was it for braddock to pay off his debt to the government at a time when no one was giving back?. If a cell is placed in a hypertonic solution, what will be the MOST LIKELY action that will result from the body attempting to maintain homeostasis? Select the two correct answers.AThe cell will shrink as water moves between the environments to reach equilibrium.BWater will move by active transport out of the cell.CSalt will move by active transport out of the cell.DSalt will move by osmosis out of the cell.EWater will move by osmosis out of the cell. This map shows a part of the sea floor.Identify the following features.a continental shelfa continental slopea spreading ridgea subduction zone with a deep trenchan abyssal plainsome isolated seamountsWhere is this? (North is up.) How is the value of b related to the y-intercept of the graph of y = 3x + b? HURRRRYYY PLSSSS HELP!!!!!!!Listen to the five sentences from the lesson page in Spanish. Eachsentence contains one error. For each sentence:1. Describe the error found.2. Rewrite each of the five sentences correcting the error.Mis amigos escuchamos la musicaYo toco la guitarraLorena miras televisionEllas bailais biennosotros montan en bicicleta Which rock is an example of an organic sedimentary rock?A - iron oreB - rock saltC - limestoneD - sandstone Imagine you got into an auto accident which was your fault and you have 15/30/5 insurance. You did $5,000 damage to the other car, and broke a computer in the other car's trunk worth$2,000.There were 3 people in the other car and their medical bills were $12,000each. The father in the other car also was out of work for a month costing the family $6,000.In total, you are sued for $49,000.How much money will the insurance company pay toward the amount you were sued for in this accident?