Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*Thumbs.db*
*Thumbs.db*
/.vscode/
6 changes: 4 additions & 2 deletions background.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
</head>

<html>
<body id="body" style="background-color:#00000000;"></body>
<body id="body" style="background-color:#00000000;">
</body>
</html>

<script src="scripts/background_pokemon.js">
</script>
<script src="scripts/background_pokemon-size-reasonable-gmax.js">
</script>
<script src="scripts/background.js">
</script>
11 changes: 6 additions & 5 deletions scripts/background.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
img {
image-rendering: crisp-edges;
position: absolute;
max-width: 196px;
height: auto;
Expand All @@ -13,11 +14,11 @@ img {
}

.sphealnone, .sphealsparkle {
animation: spin linear 5s infinite;
-webkit-animation: spin linear 5s infinite;
-ms-animation: spin linear 5s infinite;
-o-animation: spin linear 5s infinite;
-moz-animation: spin linear 5s infinite;
animation: spin linear 5s infinite, fadeIn ease 5s;
-webkit-animation: spin linear 5s infinite, fadeIn ease 5s;
-ms-animation: spin linear 5s infinite, fadeIn ease 5s;
-o-animation: spin linear 5s infinite, fadeIn ease 5s;
-moz-animation: spin linear 5s infinite, fadeIn ease 5s;
}

.wailordnone {
Expand Down
111 changes: 95 additions & 16 deletions scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const config = {
swarmOdds: 1 / 64,
fakemonOdds: 1 / 128, // Chance to add a single "fakemon" from Smogon's CAP - https://www.smogon.com/dex/ss/formats/cap/
bigWailords: true, // BIG FUCKINF WAILORD
sphealSpin: true // Spinny boi
sphealSpin: true, // Spinny boi
heights: false // Biblically accurate Pokémon
};

// Create background elements on load
Expand All @@ -26,48 +27,111 @@ $(function () {
// Generate Pokémon and their attributes
function create() {
let onscreenPokemon = "";
const shuffledPokemon = shuffle(pokemon).slice(0, config.maxOnscreen);
let shuffledPokemon = "";
var height_pos= [];
var shuffled_size = [];
var bodyWrapper = document.getElementById("main");

if(config.heights)
{
//Ensures both arrays of objects are shuffled identically
multishuffle(pokemon, pokemonsize)
shuffledPokemon = pokemon.slice(0, config.maxOnscreen)
shuffled_size = pokemonsize.slice(0, config.maxOnscreen)
}
else
{
shuffledPokemon = shuffle(pokemon).slice(0, config.maxOnscreen);
}

// Handle Fakemon
if (Math.random() < config.fakemonOdds) {
const shuffledFakemon = shuffle(fakemon);
shuffledPokemon.unshift(shuffledFakemon[0]);
// Fakemon sprites
if (Math.random() < config.fakemonOdds) {
if(config.heights)
{
//Ensures both arrays of objects are shuffled identically
multishuffle(fakemon,fakemonsize)
const shuffledFakemon = fakemon
shuffledPokemon.unshift(shuffledFakemon[0])
shuffled_fakesize = fakemonsize
shuffled_size.unshift(shuffled_fakesize[0])
}
else
{
const shuffledFakemon = shuffle(fakemon);
shuffledPokemon.unshift(shuffledFakemon[0]);
}
}

// Handle swarms
if (config.swarms && Math.random() < config.swarmOdds) {
const swarm = Array(config.swarmAmount).fill(shuffledPokemon[0]);
shuffledPokemon.push(...swarm);

if(config.heights)
{
const swarmHeight = Array(config.swarmAmount).fill(shuffled_size[0]);
shuffled_size.push(...swarmHeight);
}
}

// Process each Pokémon
shuffledPokemon.forEach((pokemon) => {
let form;
for (const val in pokemon) {
form = pokemon[val][Math.floor(Math.random() * pokemon[val].length)];
formval = Math.floor(Math.random() * pokemon[val].length)
form = pokemon[val][formval];
}
height_pos.push(formval)

const isShiny = Math.random() < config.shinyOdds;
const sparkleClass = isShiny ? "sparkle" : "none";
const spritePath = isShiny ? "shiny/" : "normal/";
const area = floating_pokemon.includes(form) ? "sky" : "ground";

// Special cases
let specialClass = "";
if (form === "wailord" && config.bigWailords) specialClass = "wailord";
if (form === "spheal" && config.sphealSpin) specialClass = "spheal";
let specialClass = ""

//Do not enable big_wailords if heights is enabled. Causes Wailord to take up the entire screen while also rendering on-top of everything else.
if (form == "wailord" && config.big_wailords && !config.heights) specialClass = "wailord"
if (form == "spheal" && config.spheal_spin) specialClass = "spheal"

// Append the Pokémon sprite
onscreenPokemon += `
<img class="${specialClass}${sparkleClass}" id="${area}"
src="sprites/${spritePath}${form}.gif"
onerror="this.style.display='none'"
alt="Pokemon">
`;
src="sprites/${spritePath}${form}.gif"
onerror="this.style.display='none'"
alt="Pokemon">
`;
});
i=0
shuffled_size.forEach((pokemonsize) => {
for (var val in pokemonsize) {
list = pokemonsize[val]
form = pokemonsize[val][height_pos[i]]
height_multi.push(form)
i++
}
});

// Inject Pokémon sprites into the body
document.getElementById("body").innerHTML = onscreenPokemon;

if(config.heights){
setTimeout(function(){
i = 0
$("img").each(function(){
s = "Height slot: "+ height_pos[i] + " Multi: " + height_multi[i]+" OG Height: "+$(this).height()
h = $(this).height() * height_multi[i];
$(this).height(h);
//Logging for checking which Pokemon are chosen, their original height in px, the multiplier applied to them, and their new height px
//console.log(s + " New Height: " + $(this).height()+" ", shuffledPokemon[i])
i++
});
}, 100);
//Change scale from 1.6x to 1.2x. Big mons at 1.6x are WAY too big.
$('img').css('transform', 'translate(var(--x-position), var(--y-position)) scale(1.2)')
//Remove max-width
$('img').css('max-width', '9999px')
}
}

// Randomly position and style Pokémon sprites
Expand Down Expand Up @@ -125,7 +189,6 @@ function randomOrder() {
}
});
}

// Shuffle sprites for ground and sky
shuffleSprites('#ground', 1000, 50);
shuffleSprites('#sky', 10, 400);
Expand All @@ -142,3 +205,19 @@ function shuffle(array) {
}
return array;
}

function multishuffle(array, array2) {
let i = array.length,
rand;

while (i != 0) {
rand = Math.floor(Math.random() * i);
i--;
[array[i], array[rand]] = [
array[rand], array[i]
];
[array2[i], array2[rand]] = [
array2[rand], array2[i]
];
}
}
Loading