{ "key_pair_value_system": true, "answer_rating_count": "", "question_feedback_html": { "html_star": "", "html_star_feedback": "" }, "answer_average_rating_value": "", "answer_date_js": "2024-08-17T06:03:25-04:00", "answer_date": "2024-08-17 06:03:25", "is_docs_available": null, "is_excel_available": null, "is_pdf_available": null, "count_file_available": 0, "main_page": "student_question_view", "question_id": "8129884", "url": "\/study-help\/questions\/hi-is-there-anyway-for-me-to-have-the-user-8129884", "question_creation_date_js": "2024-08-17T06:03:25-04:00", "question_creation_date": "Aug 17, 2024 06:03 AM", "meta_title": "[Solved] hi is there anyway for me to have the use | SolutionInn", "meta_description": "Answer of - hi is there anyway for me to have the user pick the character at the start of the game? I want to make this more inter | SolutionInn", "meta_keywords": "user,pick,character,start,game,make,interactive,thinking,lines,listed,below,attached", "question_title_h1": "hi is there anyway for me to have the user pick the character at the start of the game? I want to make this more", "question_title": "hi is there anyway for me to have the user pick the", "question_title_for_js_snippet": "hi is there anyway for me to have the user pick the character at the start of the game I want to make this more interactive anyway to do that I was thinking along the lines of something like this listed below I have attached my html for reference and javascript Have a character creation menu where the player can input their name and select a Pokemon species Use the species selection to determine the character's initial stats such as attack, defense, and special abilities Store the player's name and species choice in variables that can be accessed throughout the game Use this information to generate a visual representation of the character and display it in the game Allow the player to customize their character's appearance or attributes through a customization menu, if desired Have the player confirm their character creation to start the game html Pokemon PVP Game Start Player 1 javascript class Pokemon constructor(name, sprite, hp, moves) this name name this sprite sprite this hp hp this fullhp hp this moves moves let pkmList 'Charizard', 'https img pokemondb net sprites black white normal charizard png', 360, 'Flamethrower', 'fire', 95, 0 95 , 'Dragon Claw', 'dragon', 80, 0 95 , 'Air slash', 'fly', 75, 0 85 , 'Slash', 'normal', 70, , 'Blastoise', 'https img pokemondb net sprites black white normal blastoise png', 362, 'Surf', 'water', 90, 0 95 , 'Crunch', 'normal', 80, 0 95 , 'Ice punch', 'ice', 75, 0 95 , 'Flash cannon', 'steel', 80, 0 95 , 'Venusaur', 'https img pokemondb net sprites black white normal venusaur f png', 364, 'Petal Blizzard', 'grass', 90, 0 95 , 'Sludge bomb', 'poison', 90, 0 95 , 'Earthquake', 'ground', 100, 0 95 , 'Body Slam', 'normal', 85, 0 95 let typeMatch 'Charizard' 'ground' , 'water', 'rock' , 'fire', 'grass', 'steel' , 'Blastoise' '' , 'grass' , 'fire', 'water' , 'Venusaur' 'poison' , 'fire', 'fly', 'ice', 'steel' , 'grass', 'water' , definition of new start game() function that displays the message of let's begin the game with the user name function start game() let text let player document getElementById( nickName ) value text Hello player Let's start the game displaying alert for starting the game alert(text) changing the name of the player on the screen document getElementById( player1 ) innerHTML player function spawn(bool) let p pkmList Math floor(Math random() pkmList length) let pkm new Pokemon(p 0 , p 1 , p 2 , p 3 ) if(bool) for(i 0 i 4 i ) document getElementById('m' i) value pkm moves i 0 return pkm let pk1 spawn(true) s1 document createElement('img') s1 src pk1 sprite document getElementById('pk1') appendChild(s1) document getElementById('hp1') innerHTML ' HP ' pk1 hp ' ' pk1 fullhp ' ' let pk2 spawn(false) s2 document createElement('img') s2 src pk2 sprite document getElementById('pk2') appendChild(s2) document getElementById('hp2') innerHTML ' HP ' pk2 hp ' ' pk2 fullhp ' ' for(i 0 i 4 i ) let btn document getElementById('m' i) let move pk1 moves i function addHandler(btn, move, pk1, pk2) btn addEventListener('click', function(e) attack(move, pk1, pk2, 'hp2', '') setTimeout(attack,2000, pk2 moves Math floor(Math random() 3) , pk2, pk1, 'hp1', 'Foe ') ) addHandler(btn, move, pk1, pk2) function attack(move, attacker, receiver, hp, owner) document getElementById('comment') innerHTML ' ' owner attacker name ' used ' move 0 ' ' if(Math random() move 3 ) let power move 2 Math floor(Math random() 10) let rtype typeMatch receiver name let mtype move 1 let scale 1 for(i 0 i", "question_description": "

hi is there anyway for me to have the user pick the character at the start of the game? I want to make this more interactive anyway to do that??<\/p>

I was thinking along the lines of something like this listed below. I have attached my html for reference and javascript<\/p>

<\/p>

Have a character creation menu where the player can input their name and select a Pokemon species.<\/strong><\/p>

Use the species selection to determine the character's initial stats such as attack, defense, and special abilities.<\/strong><\/p>

Store the player's name and species choice in variables that can be accessed throughout the game.<\/strong><\/p>

Use this information to generate a visual representation of the character and display it in the game.<\/strong><\/p>

Allow the player to customize their character's appearance or attributes through a customization menu, if desired.<\/strong><\/p>

Have the player confirm their character creation to start the game.<\/strong><\/p>

<\/p>

<\/p>

html<\/strong><\/p>

<\/p>

<\/p>

<\/p>

<\/p>

<\/p>

<\/p>

<\/p>

<\/p>

<\/p>

<\/p>

<\/p>

<\/p>

<\/p>

<\/p>

Pokemon PVP Game<\/title><\/p> <p> <\/p> <p><script defer src=\"app.js\"><\/script><\/p> <p> <\/p> <p><\/head><\/p> <p> <\/p> <p><body><\/p> <p> <\/p> <p><div id=\"player-name\"><\/p> <p> <\/p> <p><input type=\"text\" id=\"nickName\"><\/p> <p> <\/p> <p><button id=\"start-btn\" onclick = \"start_game()\">Start<\/button><\/p> <p> <\/p> <p><\/div><\/p> <p> <\/p> <p><div id=\"player1\"><\/p> <p> <\/p> <p>Player 1<\/p> <p> <\/p> <p><\/div><\/p> <p> <\/p> <p><table class='table'><\/p> <p> <\/p> <p><tr><\/p> <p> <\/p> <p><td id='hp1'><\/td><\/p> <p> <\/p> <p><td id='hp2'><\/td><\/p> <p> <\/p> <p><\/tr><\/p> <p> <\/p> <p><tr><\/p> <p> <\/p> <p><td id='pk1'><\/td><\/p> <p> <\/p> <p><td id='pk2'><\/td><\/p> <p> <\/p> <p><\/tr><\/p> <p> <\/p> <p><tr><\/p> <p> <\/p> <p><td colspan='2' id='comment'><\/td><\/p> <p> <\/p> <p><\/tr><\/p> <p> <\/p> <p><tr><\/p> <p> <\/p> <p><td><\/p> <p> <\/p> <p><input type='button' id='m0'><\/p> <p> <\/p> <p><input type='button' id='m1'><\/p> <p> <\/p> <p><input type='button' id='m2'><\/p> <p> <\/p> <p><input type='button' id='m3'><\/p> <p> <\/p> <p><\/td><\/p> <p> <\/p> <p><\/tr><\/p> <p> <\/p> <p><\/table><\/p> <p> <\/p> <p><\/body><\/p> <p> <\/p> <p><strong>javascript<\/strong><\/p> <p> <\/p> <p>class Pokemon{<\/p> <p> <\/p> <p> constructor(name, sprite, hp, moves){<\/p> <p> <\/p> <p> this.name = name;<\/p> <p> <\/p> <p> this.sprite = sprite;<\/p> <p> <\/p> <p> this.hp = hp;<\/p> <p> <\/p> <p> this.fullhp = hp;<\/p> <p> <\/p> <p> this.moves = moves;<\/p> <p> <\/p> <p> }<\/p> <p> <\/p> <p> }<\/p> <p> <\/p> <p> <\/p> <p> <\/p> <p> let pkmList = [<\/p> <p> <\/p> <p> ['Charizard', 'https:\/\/img.pokemondb.net\/sprites\/black-white\/normal\/charizard.png', 360,[<\/p> <p> <\/p> <p> ['Flamethrower', 'fire', 95, 0.95],<\/p> <p> <\/p> <p> ['Dragon Claw', 'dragon', 80, 0.95],<\/p> <p> <\/p> <p> ['Air slash', 'fly', 75, 0.85],<\/p> <p> <\/p> <p> ['Slash', 'normal', 70, ]<\/p> <p> <\/p> <p> ]],<\/p> <p> <\/p> <p> ['Blastoise', 'https:\/\/img.pokemondb.net\/sprites\/black-white\/normal\/blastoise.png', 362,[<\/p> <p> <\/p> <p> ['Surf', 'water', 90, 0.95],<\/p> <p> <\/p> <p> ['Crunch', 'normal', 80, 0.95],<\/p> <p> <\/p> <p> ['Ice punch', 'ice', 75, 0.95],<\/p> <p> <\/p> <p> ['Flash cannon', 'steel', 80, 0.95]<\/p> <p> <\/p> <p> ]],<\/p> <p> <\/p> <p> ['Venusaur', 'https:\/\/img.pokemondb.net\/sprites\/black-white\/normal\/venusaur-f.png', 364,[<\/p> <p> <\/p> <p> ['Petal Blizzard', 'grass', 90, 0.95],<\/p> <p> <\/p> <p> ['Sludge bomb', 'poison', 90, 0.95],<\/p> <p> <\/p> <p> ['Earthquake', 'ground', 100, 0.95],<\/p> <p> <\/p> <p> ['Body Slam', 'normal', 85, 0.95]<\/p> <p> <\/p> <p> ]]<\/p> <p> <\/p> <p> ];<\/p> <p> <\/p> <p> let typeMatch = {<\/p> <p> <\/p> <p> 'Charizard': [['ground'],['water', 'rock'], ['fire', 'grass', 'steel']],<\/p> <p> <\/p> <p> 'Blastoise':[[''],['grass'],['fire', 'water']],<\/p> <p> <\/p> <p> 'Venusaur':[['poison'],['fire', 'fly', 'ice', 'steel'],['grass', 'water']],<\/p> <p> <\/p> <p> }<\/p> <p> <\/p> <p> \/\/definition of new start_game() function that displays the message of let's begin the game with the user name<\/p> <p> function start_game(){<\/p> <p> <\/p> <p> let text;<\/p> <p> <\/p> <p> let player = document.getElementById(\"nickName\").value;<\/p> <p> <\/p> <p> text = \"Hello \" + player + \"! Let's start the game.\";<\/p> <p> <\/p> <p> \/\/displaying alert for starting the game<\/p> <p> alert(text);<\/p> <p> <\/p> <p> \/\/changing the name of the player on the screen<\/p> <p> document.getElementById(\"player1\").innerHTML = player;<\/p> <p> <\/p> <p> }<\/p> <p> <\/p> <p> function spawn(bool){<\/p> <p> <\/p> <p> let p = pkmList[Math.floor(Math.random()*pkmList.length)];<\/p> <p> <\/p> <p> let pkm = new Pokemon(p[0], p[1], p[2], p[3]);<\/p> <p> <\/p> <p> if(bool){<\/p> <p> <\/p> <p> for(i=0; i<4; i++){<\/p> <p> <\/p> <p> document.getElementById('m'+i).value = pkm.moves[i][0];<\/p> <p> <\/p> <p> }<\/p> <p> <\/p> <p> }<\/p> <p> <\/p> <p> return pkm;<\/p> <p> <\/p> <p> }<\/p> <p> <\/p> <p> let pk1 = spawn(true);<\/p> <p> <\/p> <p> s1 = document.createElement('img');<\/p> <p> <\/p> <p> s1.src = pk1.sprite;<\/p> <p> <\/p> <p> document.getElementById('pk1').appendChild(s1);<\/p> <p> <\/p> <p> document.getElementById('hp1').innerHTML = '<p>HP: ' + pk1.hp + '\/' + pk1.fullhp + '<\/p>';<\/p> <p> <\/p> <p> <\/p> <p> let pk2 = spawn(false);<\/p> <p> <\/p> <p> s2 = document.createElement('img');<\/p> <p> <\/p> <p> s2.src = pk2.sprite;<\/p> <p> <\/p> <p> document.getElementById('pk2').appendChild(s2);<\/p> <p> <\/p> <p> document.getElementById('hp2').innerHTML = '<p>HP: ' + pk2.hp + '\/' + pk2.fullhp + '<\/p>';<\/p> <p> <\/p> <p> for(i=0; i<4; i++){<\/p> <p> <\/p> <p> let btn = document.getElementById('m'+i);<\/p> <p> <\/p> <p> let move = pk1.moves[i];<\/p> <p> <\/p> <p> function addHandler(btn, move, pk1, pk2){<\/p> <p> <\/p> <p> btn.addEventListener('click', function(e){<\/p> <p> <\/p> <p> attack(move, pk1, pk2, 'hp2', '');<\/p> <p> <\/p> <p> setTimeout(attack,2000, pk2.moves[Math.floor(Math.random()*3)], pk2, pk1, 'hp1', 'Foe ');<\/p> <p> <\/p> <p> });<\/p> <p> <\/p> <p> }<\/p> <p> <\/p> <p> addHandler(btn, move, pk1, pk2);<\/p> <p> <\/p> <p> }<\/p> <p> <\/p> <p> <\/p> <p> <\/p> <p> function attack(move, attacker, receiver, hp, owner){<\/p> <p> <\/p> <p> document.getElementById('comment').innerHTML = '<p>' + owner + attacker.name + ' used ' + move[0] + '!<\/p>';<\/p> <p> <\/p> <p> if(Math.random() < move[3]){<\/p> <p> <\/p> <p> let power = move[2] += Math.floor(Math.random()*10);<\/p> <p> <\/p> <p> let rtype = typeMatch[receiver.name];<\/p> <p> <\/p> <p> let mtype = move[1];<\/p> <p> <\/p> <p> let scale = 1;<\/p> <p> <\/p> <p> for(i=0; i<rtype.length; i++){<\/p> <p> <\/p> <p> if(rtype[i].includes(mtype)){<\/p> <p> <\/p> <p> switch(i){<\/p> <p> <\/p> <p> case 0:<\/p> <p> <\/p> <p> scale = 0;<\/p> <p> <\/p> <p> setTimeout(function(){<\/p> <p> <\/p> <p> document.getElementById('comment').innerHTML = '<p>It had no effect!<\/p>';<\/p> <p> <\/p> <p> },1000);<\/p> <p> <\/p> <p> break;<\/p> <p> <\/p> <p> case 1:<\/p> <p> <\/p> <p> scale = 2;<\/p> <p> <\/p> <p> setTimeout(function(){<\/p> <p> <\/p> <p> document.getElementById('comment').innerHTML = '<p>It was super effective!<\/p>';<\/p> <p> <\/p> <p> },1000);<\/p> <p> <\/p> <p> break;<\/p> <p> <\/p> <p> case 2:<\/p> <p> <\/p> <p> scale = 0.5;<\/p> <p> <\/p> <p> setTimeout(function(){<\/p> <p> <\/p> <p> document.getElementById('comment').innerHTML = '<p>It was not very effective!<\/p>';<\/p> <p> <\/p> <p> },1000);<\/p> <p> <\/p> <p> break;<\/p> <p> <\/p> <p> }<\/p> <p> <\/p> <p> break;<\/p> <p> <\/p> <p> }<\/p> <p> <\/p> <p> }<\/p> <p> <\/p> <p> power *= scale;<\/p> <p> <\/p> <p> receiver.hp -= Math.floor(power);<\/p> <p> <\/p> <p> document.getElementById(hp).innerHTML = '<p>HP: ' + receiver.hp + '\/' + receiver.fullhp + '<\/p>';<\/p> <p> <\/p> <p> }<\/p> <p> <\/p> <p> else{<\/p> <p> <\/p> <p> setTimeout(function(){<\/p> <p> <\/p> <p> document.getElementById('comment').innerHTML = '<p>Attack missed!<\/p>';<\/p> <p> <\/p> <p> })<\/p> <p> <\/p> <p> }<\/p> <p> <\/p> <p> checkWinner(hp);<\/p> <p> <\/p> <p> <\/p> <p> }<\/p> <p> <\/p> <p> <\/p> <p> function checkWinner(hp){<\/p> <p> <\/p> <p> let f = (pk1.hp <=0) ? pk1 : (pk2.hp<=0) ? pk2 : false;<\/p> <p> <\/p> <p> if(f!=false){<\/p> <p> <\/p> <p> alert('GAME OVER: ' + f.name +' fainted!' );<\/p> <p> <\/p> <p> document.getElementById(hp).innerHTML = '<p>HP: 0\/' + f.fullhp + '<\/p>';<\/p> <p> <\/p> <p> setTimeout(function(){<\/p> <p> <\/p> <p> location.reload();<\/p> <p> <\/p> <p> },1500)<\/p> <p> <\/p> <p> }<\/p> <p> <\/p> <p> }<\/p>", "transcribed_text": "", "related_book": { "title": null, "isbn": null, "edition": null, "authors": null, "cover_image": null, "uri": null, "see_more_uri": "" }, "free_related_book": { "isbn": "", "uri": "", "name": "", "edition": "" }, "question_posted": "2024-08-17 06:03:25", "see_more_questions_link": "\/study-help\/questions\/computer-science-computer-network-2023-February-20", "step_by_step_answer": "The Answer is in the image, click to view ...", "students_also_viewed": [ { "url": "\/study-help\/biostatistics\/a-tdistribution-with-60-or-more-degrees-of-freedom-is-1964906", "description": "A t-distribution with 60 or more degrees of freedom is very nearly a _________ distribution.", "stars": 0 }, { "url": "\/rlf-company-sells-office-equipment-and-supplies-to-many-organizations", "description": "RLF Company sells office equipment and supplies to many organizations in the city and surrounding area on contract terms of 2\/10, n\/30. In the past, over 75% of the credit customers have taken...", "stars": 3 }, { "url": "\/study-help\/questions\/what-is-a-synonym-for-common-law-8899307", "description": "What is a synonym for common law", "stars": 3 }, { "url": "\/study-help\/questions\/on-october-1-2022-nespresso-sold-some-merchandise-to-gloria-8890054", "description": "On October 1, 2022, Nespresso sold some merchandise to Gloria Jeans Coffee for $60,000. In payment, Nespresso agreed to accept a 6% note requiring the receipt of interest and principal on June 30,...", "stars": 3 }, { "url": "\/study-help\/questions\/5-cumulative-frequencies-a-statistics-content-developer-at-aplia-wanted-1000879", "description": "5. Cumulative frequencies A statistics content developer at Aplia wanted to know whether study skills are related to memory quality. She invited students to perform an online memory task. The...", "stars": 3 }, { "url": "\/study-help\/questions\/the-gable-company-manufactures-trendy-highquality-moderately-priced-watches-as-999084", "description": "The Gable Company manufactures trendy, high-quality, moderately priced watches. As Gable's senior financial analyst, you are asked to recommend a method of inventory costing The chief financial...", "stars": 3 }, { "url": "\/study-help\/questions\/suppose-in-the-singlefactor-model-an-obligor-has-a-oneperiod-1007912", "description": "Suppose, in the single-factor model, an obligor has a one-period default probability of 2.75 percent and an asset return correlation to the market factor of =0.4. What fractions of its asset return...", "stars": 3 }, { "url": "\/study-help\/questions\/find-the-most-frequent-bigrams-please-complete-the-freqbigram-function-680743", "description": "1. Find the most frequent bigrams (20 pts) Please complete the freq_bigram function to find the nn most frequent bigrams. Your function should return a list of top_n tuples. Each of the tuples should...", "stars": 3 }, { "url": "\/study-help\/questions\/objective-this-activity-has-the-purpose-of-helping-students-to-999011", "description": "Objective: This activity has the purpose of helping students to implement sorted lists with links (dynamic memory). (Objective 4). Students Instructions: After studying this module, write the answers...", "stars": 3 } ], "next_back_navigation": { "previous": "\/study-help\/questions\/which-of-the-following-are-not-true-about-the-initial-8129883", "next": "\/study-help\/questions\/on-september-1-ziegler-corporation-had-73000-shares-of-5-8129885" }, "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": "hi is there anyway for me to have the user pick the", "link": "https:\/\/www.solutioninn.com\/study-help\/questions\/hi-is-there-anyway-for-me-to-have-the-user-8129884" } ], "skill_details": { "skill_id": "656", "skill_name": "Databases", "parent_id": "8" } }