{ "key_pair_value_system": true, "answer_rating_count": "", "question_feedback_html": { "html_star": "", "html_star_feedback": "" }, "answer_average_rating_value": "", "answer_date_js": "2024-09-26T10:35:08-04:00", "answer_date": "2024-09-26 10:35:08", "is_docs_available": "", "is_excel_available": "", "is_pdf_available": "", "count_file_available": 0, "main_page": "student_question_view", "question_id": "13830619", "url": "\/study-help\/questions\/using-my-javascript-code-i-need-to-be-able-to-13830619", "question_creation_date_js": "2024-09-26T10:35:08-04:00", "question_creation_date": "Sep 26, 2024 10:35 AM", "meta_title": "[Solved] using my javascript code, i need to be ab | SolutionInn", "meta_description": "Answer of - using my javascript code, i need to be able to move my paddles up and down. this is a ping pong game. use key w and s | SolutionInn", "meta_keywords": "javascript,code,move,paddles,ping,pong,game,key,s,left,paddle,arrow", "question_title_h1": "using my javascript code, i need to be able to move my paddles up and down. this is a ping pong game. use key w", "question_title": "using my javascript code, i need to be able to move my", "question_title_for_js_snippet": "using my javascript code, i need to be able to move my paddles up and down this is a ping pong game use key w and s to move left paddle, and the up and down arrow key to move the right paddle Please use the code I already have below and add on, thanks Term Project Ping Pong", "question_description": "

using my javascript code, i need to be able to move my paddles up and down. this is a ping pong game. use key w and s to move left paddle, and the up and down arrow key to move the right paddle. Please use the code I already have below and add on, thanks<\/p>

<\/p>

<\/p>

<\/p>

<\/p>

Term Project - Ping Pong <\/title><\/p> <p><\/head><\/p> <p><body><\/p> <p><canvas id =\"myCanvas\" width = \"800\" height = \"600\"<\/p> <p><\/canvas><\/p> <p><script><\/p> <p>var canvas, paddle1, paddle2, ctx;<\/p> <p> <\/p> <p>\/* set the canvas size and color *\/<\/p> <p>var canvas = document.getElementById(\"myCanvas\");<\/p> <p>var ctx = canvas.getContext(\"2d\");<\/p> <p>ctx.fillStyle = \"green\";<\/p> <p>ctx.fill();<\/p> <p>var x = canvas.width;<\/p> <p>var y = canvas.height;<\/p> <p>var dx = 2;<\/p> <p>var dy = -2;<\/p> <p>ctx.beginPath();<\/p> <p>ctx.rect(20, 20, 800, 800); <\/p> <p>ctx.fill();<\/p> <p>\/* dimensions of the ball *\/<\/p> <p>var xposball = 200;<\/p> <p>var yposball = 300;<\/p> <p>\/* radius of the ball *\/<\/p> <p>var radiusball = 12;<\/p> <p>\/* speed of the ball *\/<\/p> <p>var xspeedball = 1;<\/p> <p>var yspeedball = 1;<\/p> <p>\/* direction of the ball *\/<\/p> <p>xdirball = 1;<\/p> <p>ydirball = 1;<\/p> <p>\/* speed of the game *\/<\/p> <p>var gamespeed = 2;<\/p> <p>\/* add the ball, paddles, and canvas to game *\/<\/p> <p>function draw(){<\/p> <p>ctx.fillStyle = \"green\";<\/p> <p>ctx.clearRect(0,0, canvas.width, canvas.height);<\/p> <p>ctx.fill();<\/p> <p> <\/p> <p>\/\/ paddle 1<\/p> <p>ctx.rect(39, 115, 20, 150);<\/p> <p>ctx.fillStyle = 'black';<\/p> <p>ctx.stroke();<\/p> <p>\/\/ paddle 2<\/p> <p>ctx.rect(770, 115, 20, 150);<\/p> <p>ctx.fillStyle = 'black';<\/p> <p>ctx.stroke();<\/p> <p>\/* draw the ball *\/<\/p> <p>ctx.fillStyle = \"black\";<\/p> <p>ctx.beginPath();<\/p> <p>ctx.arc(xposball, yposball, radiusball, 0, 2 * Math.PI, false);<\/p> <p>ctx.fill();<\/p> <p>ctx.closePath();<\/p> <p>xposball = xposball + xspeedball * xdirball;<\/p> <p>yposball = yposball + yspeedball * ydirball;<\/p> <p>}<\/p> <p> <\/p> <p>\/\/ calling our draw function, and game speed<\/p> <p>setInterval(draw, gamespeed);<\/p> <p> <\/p> <p> <\/p> <p><\/script><\/p> <p><\/body><\/p> <p><\/html><\/p>", "transcribed_text": "", "related_book": { "title": "Database Programming With Visual Basic .NET", "isbn": "1590590325, 978-1590590324", "edition": "2nd Edition", "authors": "Carsten Thomsen", "cover_image": "https:\/\/dsd5zvtm8ll6.cloudfront.net\/si.question.images\/book_images\/6507d835d8d38_54997.jpg", "uri": "\/textbooks\/database-programming-with-visual-basic-net-2nd-edition-9781590590324", "see_more_uri": "\/textbooks\/computer-science-xpages-2778" }, "question_posted": "2024-09-26 10:35:08", "step_by_step_answer": "The Answer is in the image, click to view ...", "students_also_viewed": [ { "url": "\/study-help\/international-human-resource-management\/defi-ne-grievance-and-identify-the-stages-in-a-grievance-2123355", "description": "Defi ne grievance and identify the stages in a grievance procedure.", "stars": 0 }, { "url": "\/kershaw-electric-sold-6000000-10-10year-bonds-on-january-1", "description": "Kershaw Electric sold $6,000,000, 10%, 10-year bonds on January 1, 2017. The bonds were dated January 1, 2017, and paid interest on January 1. The bonds were sold at 98. Instructions (a) Prepare the...", "stars": 3.5 }, { "url": "\/study-help\/questions\/using-my-javascript-code-i-need-to-be-able-to-13830619", "description": "using my javascript code, i need to be able to move my paddles up and down. this is a ping pong game. use key w and s to move left paddle, and the up and down arrow key to move the right paddle....", "stars": 3.5 }, { "url": "\/study-help\/questions\/1when-the-term-of-apurchasesale-are-fob-shipping-then-the-11617942", "description": "1.When the term of apurchase\/sale are FOB shipping, then the seller pays the shipping costs? 2. Net Sale minus Cost Good Sold=? 3.Gross Sales minus Discount and Returns and Allowances= Cost of Good...", "stars": 3.5 }, { "url": "\/study-help\/questions\/calmex-is-situated-in-north-india-it-specializes-in-manufacturing-1110175", "description": "Calmex is situated in North India. It specializes in manufacturing overhead water tanks. The management of Calmex has identified a niche market in certain Southern cities that need a particular size...", "stars": 3.5 }, { "url": "\/study-help\/questions\/two-players-amy-and-beth-play-the-following-game-with-5232475", "description": "Two players, Amy and Beth, play the following game with a jar containing 100 pennies. The players take turns; Amy goes first. Each time it is a player's turn, she takes between 1 and 10 pennies out...", "stars": 3.5 }, { "url": "\/study-help\/questions\/a-population-consists-of-the-five-numbers-2-3-6-1015980", "description": "A population consists of the five numbers 2, 3, 6, 8 and 11. Consider samples of size 2 that can be drawn from this population. a. List all the possible samples and the corresponding mean. Sample Mean", "stars": 3.5 }, { "url": "\/study-help\/questions\/the-terms-normal-and-inferior-are-multiple-choice-question-the-1620018", "description": "The terms \"normal\" and \"inferior\" are: Multiple choice question. the same for everyone, irrespective of income. used interchangeably. subjective to the incomes of people. based on the product sales...", "stars": 3.5 }, { "url": "\/study-help\/questions\/a-company-wants-to-investigate-if-the-average-rating-of-1016014", "description": "A company wants to investigate if the average rating of consumers for a particular product is greater than 4.5 (on a scale of 1 to 10). They collect a random sample of 35 consumers and ask them to...", "stars": 3.5 }, { "url": "\/study-help\/cost-of-capital-in-managerial-finance\/what-are-decision-trees-2132175", "description": "What are Decision Trees?", "stars": 3.5 }, { "url": "\/study-help\/cost-of-capital-in-managerial-finance\/what-is-meant-by-the-term-glass-ceiling-2132172", "description": "What is meant by the Term Glass Ceiling?", "stars": 3.5 }, { "url": "\/study-help\/cost-of-capital-in-managerial-finance\/what-interface-is-used-to-develop-data-mining-structures-in-2132176", "description": "What Interface is used to develop Data Mining Structures in SQL Server Analytical Databases?", "stars": 3.5 } ], "next_back_navigation": { "previous": "\/study-help\/questions\/write-a-program-to-process-a-collection-of-daily-high-13830618", "next": "\/study-help\/questions\/1-match-the-part-of-the-systems-model-with-the-13830620" }, "breadcrumbs": [ { "name": "Study help", "link": "https:\/\/www.solutioninn.com\/study-help\/questions-and-answers" }, { "name": "Computer Science", "link": "https:\/\/www.solutioninn.com\/study-help\/questions-and-answers\/computer-science" }, { "name": "Databases", "link": "https:\/\/www.solutioninn.com\/study-help\/questions\/computer-science-databases" }, { "name": "using my javascript code, i need to be able to move my", "link": "https:\/\/www.solutioninn.com\/study-help\/questions\/using-my-javascript-code-i-need-to-be-able-to-13830619" } ], "skill_details": { "skill_id": "656", "skill_name": "Databases", "parent_id": "8" } }