half done pokemon
This commit is contained in:
parent
25072921a7
commit
8ca92f7373
|
@ -28,19 +28,23 @@ let drowzee = {
|
||||||
level: 33,
|
level: 33,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let bjarne = {
|
||||||
|
name: "Bjarne",
|
||||||
|
image: "Images/pokemonTrainerIdle.png",
|
||||||
|
pokemon: [],
|
||||||
|
}
|
||||||
let possiblePokemon = [pikachu, bulbasaur, oranguru, drowzee];
|
let possiblePokemon = [pikachu, bulbasaur, oranguru, drowzee];
|
||||||
let randomPokemon = null;
|
let randomPokemon = null;
|
||||||
|
|
||||||
let playerName = "Bjarne";
|
|
||||||
let playerImage = "/Images/pokemonTrainerIdle.png";
|
|
||||||
let playerPokemon = [];
|
|
||||||
|
|
||||||
let app = document.getElementById("app");
|
let app = document.getElementById("app");
|
||||||
|
|
||||||
updateView();
|
updateView();
|
||||||
|
|
||||||
function updateView() {
|
function updateView() {
|
||||||
getRandomPokemon()
|
getRandomPokemon()
|
||||||
|
// randomPokemon.level = Math.floor(Math.random() * 100)
|
||||||
|
// randomPokemon.health = Math.floor(Math.random() * 100)
|
||||||
|
// console.log(randomPokemon.level, randomPokemon.health);
|
||||||
app.innerHTML = /*HTML*/ `
|
app.innerHTML = /*HTML*/ `
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="opposingPokemon">
|
<div class="opposingPokemon">
|
||||||
|
@ -51,8 +55,8 @@ function updateView() {
|
||||||
|
|
||||||
<div class="bottomScreen">
|
<div class="bottomScreen">
|
||||||
<div class="player">
|
<div class="player">
|
||||||
<img src="${playerImage}">
|
<img src="${bjarne.image}">
|
||||||
<div>${playerName}</div>
|
<div>${bjarne.name}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="buttonContainer">
|
<div class="buttonContainer">
|
||||||
|
@ -66,10 +70,10 @@ function updateView() {
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function caughtPokemonView(){
|
function caughtPokemonView() {
|
||||||
app.innerHTML = /*HTML*/`
|
app.innerHTML = /*HTML*/`
|
||||||
<div class="caughtContainer">
|
<div class="caughtContainer">
|
||||||
<h1>Du fanget ${playerPokemon[playerPokemon.length - 1].name}</h1>
|
<h1>Du fanget ${bjarne.pokemon[bjarne.pokemon.length - 1].name}</h1>
|
||||||
<div class="buttonContainer">
|
<div class="buttonContainer">
|
||||||
<button onclick="updateView()">Finn en annen</button>
|
<button onclick="updateView()">Finn en annen</button>
|
||||||
<button onclick="showPokemon()">Vis dine pokemon</button>
|
<button onclick="showPokemon()">Vis dine pokemon</button>
|
||||||
|
@ -78,16 +82,30 @@ function caughtPokemonView(){
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function catchPokemon(){
|
function catchPokemon() {
|
||||||
playerPokemon.push(randomPokemon);
|
bjarne.pokemon.push(randomPokemon);
|
||||||
caughtPokemonView();
|
caughtPokemonView();
|
||||||
}
|
}
|
||||||
|
|
||||||
function showPokemon(){
|
function showPokemon() {
|
||||||
console.log(playerPokemon);
|
app.classList = '';
|
||||||
|
app.innerHTML = '';
|
||||||
|
|
||||||
|
for (i = 0; i < bjarne.pokemon.length; i++){
|
||||||
|
app.innerHTML += /*HTML*/ `
|
||||||
|
<table><tr><th>Navn</th><th>Level</th></tr>
|
||||||
|
<td>${bjarne.pokemon[i].name}</td><td>${bjarne.pokemon[i].level}</td></tr>
|
||||||
|
</table>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
app.innerHTML += /*HTML*/`
|
||||||
|
<div>
|
||||||
|
<button onclick="updateView()">Finn en annen</button>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRandomPokemon(){
|
function getRandomPokemon() {
|
||||||
let randomNum = Math.floor(Math.random() * possiblePokemon.length);
|
let randomNum = Math.floor(Math.random() * possiblePokemon.length);
|
||||||
randomPokemon = possiblePokemon[randomNum];
|
randomPokemon = possiblePokemon[randomNum];
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,6 @@ function Header({ title }) {
|
||||||
export default function HomePage() {
|
export default function HomePage() {
|
||||||
const names = ['Ada Lovlace', 'Grace Hopper', 'Margaret Hamilton'];
|
const names = ['Ada Lovlace', 'Grace Hopper', 'Margaret Hamilton'];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Header title="Develop. Preview. Ship." />
|
<Header title="Develop. Preview. Ship." />
|
||||||
|
|
Loading…
Reference in a new issue