Tile Map Test
How do I make an tile map test?
What is a tile map test? How do you make a tile map test? This script and codes were developed by Yvan Dumont on 08 December 2022, Thursday.
Tile Map Test - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Tile Map Test</title> <link href="https://fonts.googleapis.com/css?family=Arvo|Montserrat" rel="stylesheet"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <header> <h1> Simple Tile Map Test </h1>
</header>
<main class="map--container dragscroll" id="map"> <div class="map--container--inner"></div>
</main>
<section class="map--config" id="config"> <form class="map--config--form"> <label for="cols">Columns:</label><input id="cols" name="cols" placeholder="50" type="number" value="50" /><label for="rows">Rows:</label><input id="rows" name="rows" placeholder="50" type="number" value="50" /><label for="cellSize">Cell Size:</label><input id="cellSize" name="cellSize" placeholder="48" type="number" value="48" /><button id="btnCreate" type="button">Recreate</button> </form>
</section> <script src='https://codepen.io/LeYvan/pen/aBgEGg.js'></script>
<script src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/193986/dragscroll.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/simplex-noise/2.2.0/simplex-noise.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Tile Map Test - Script Codes CSS Codes
html { height: 100vh;
}
h1 { font-size: 36px; margin: 36px 0 10px; text-align: center;
}
.sub--title { margin: 0 auto; text-align: center;
}
body { color: white; font-family: 'Montserrat', sans-serif; text-shadow: rgba(0, 0, 0, 0.3) 2px 2px 2px; min-height: 100%; display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-orient: vertical; -webkit-box-direction: normal; -ms-flex-direction: column; flex-direction: column; -webkit-box-align: center; -ms-flex-align: center; align-items: center; -ms-flex-pack: distribute; justify-content: space-around; background: -webkit-linear-gradient(right, #001510, #00bf8f); background: linear-gradient(to left, #001510, #00bf8f);
}
#map { -webkit-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0); background: #333333; background: -webkit-linear-gradient(right, #485563, #29323c); background: linear-gradient(to left, #485563, #29323c); width: 800px; height: 600px; box-shadow: rgba(0, 0, 0, 0.5) 4px 4px 2px; border: 10px solid transparent; background-origin: border-box;
}
.map--container { will-change: scroll; -webkit-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0); overflow: auto; display: -webkit-box; display: -ms-flexbox; display: flex; -ms-flex-pack: distribute; justify-content: space-around;
}
.map--container[data-need-scroll=false] { -webkit-box-align: center; -ms-flex-align: center; align-items: center;
}
.map--container--inner { position: relative;
}
.map--cell { position: absolute; display: inline-block; z-index: 0;
}
#config { margin: 36px 0; line-height: 26px; min-width: 800px;
}
#config button,
#config input { font-weight: bold; font-family: 'Arvo', serif; text-transform: uppercase; background: white; border-radius: 2px; border: none; text-align: center; box-shadow: rgba(0, 0, 0, 0.3) 2px 2px 2px;
}
#config input { width: 100px;
}
#config button { padding: 0 20px; cursor: pointer;
}
#config button:hover { background-color: rgba(250, 250, 250, 0.5);
}
#config button:active { background-color: rgba(50, 50, 50, 0.75);
}
.map--config--form { display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-orient: horizontal; -webkit-box-direction: normal; -ms-flex-direction: row; flex-direction: row; -webkit-box-pack: justify; -ms-flex-pack: justify; justify-content: space-between;
}
.dragscroll { cursor: -webkit-grab; cursor: grab;
}
.dragscroll:active { cursor: -webkit-grabbing; cursor: grabbing;
}
/*scrollbars*/
*::-webkit-scrollbar-track { -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3); background-color: transparent;
}
*::-webkit-scrollbar { height: 2px; width: 2px;
}
*::-webkit-scrollbar-thumb { -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.2); background-color: #00bf8f;
}
*::-webkit-scrollbar-corner { display: none;
}
Tile Map Test - Script Codes JS Codes
var Map = function(selector, cols, rows, cellSize) { var container = $(selector), mapEl = container.find('.map--container--inner'), noise = new SimplexNoise(), elevation = null, terrain = null, scaleRange = function(value, originalMin, originalMax, newMin, newMax) { var newAmplitude = newMax - newMin, originalOffset = value - originalMin, originalAmplitude = originalMax - originalMin; return (newAmplitude * originalOffset / originalAmplitude) + newMin; },colorCodeLevel = function(value) { var r = parseInt(value * 0.3), g = parseInt(value * 0.7), b = parseInt(value * 0.5); return `rgb(${r},${g},${b})`; },createCell = function(x, y) { var cellDiv = document.createElement('div'), level = scaleRange(elevation[x][y], -1, 1, 1, 255), bgColor = colorCodeLevel(level); cellDiv.classList.add('map--cell'); cellDiv.style.top = CSS.px((y-1) * cellSize); cellDiv.style.left = CSS.px((x-1) * cellSize); cellDiv.style.height = CSS.px(cellSize); cellDiv.style.width = CSS.px(cellSize); cellDiv.style.backgroundColor = bgColor; return cellDiv; },generateRandomLayer = function() { var layer = new Array(); for (var x = 1; x <= cols; x++) { layer[x] = new Array(); for (var y = 1; y <= rows; y++) { layer[x][y] = noise.noise2D(x, y); } } return layer; }; this.empty = function() { mapEl.innerHTML = ''; }; this.create = function() { var mapWidth = cols * cellSize, mapHeight = rows * cellSize; mapEl.style.width = CSS.px(mapWidth); mapEl.style.height = CSS.px(mapHeight); container.dataset.needScroll = mapWidth > container.offsetWidth || mapHeight > container.offsetHeight; elevation = generateRandomLayer(); for (var y = 1; y <= rows; y++) { for (var x = 1; x <= cols; x++) { var cellTemplate = createCell(x, y); mapEl.appendChild(cellTemplate); } } }; this.center = function() { var map = $('#map'), centerX = map.offsetWidth / 2, centerY = map.offsetHeight / 2; map.scrollLeft = centerX; map.scrollTop = centerY; }; this.empty(); this.create(); this.center();
};
var defaultColsCount = $('#cols').value, defaultRowsCount = $('#rows').value, defaultCellSize = $('#cellSize').value;
var tmap = new Map('#map', defaultColsCount, defaultRowsCount, defaultCellSize);
$('#btnCreate').addEventListener('click', function() { var cols = parseInt($('#cols').value), rows = parseInt($('#rows').value), cellSize = parseInt($('#cellSize').value); tmap = Map('#map', cols, rows, cellSize);
});
Developer | Yvan Dumont |
Username | LeYvan |
Uploaded | December 08, 2022 |
Rating | 3 |
Size | 4,860 Kb |
Views | 8,096 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Drive-Space-Info | 4,253 Kb |
Whyutils | 3,752 Kb |
A Pen by Yvan Dumont | 7,322 Kb |
Prodjask-Vue Exercice | 11,220 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Simple, flat contact form | Zeaklous | 2,719 Kb |
CSS Tooltips | Darylldoyle | 2,599 Kb |
Starfield old school style | Bolloxim | 5,214 Kb |
Typefaces with descriptions | Megandoty | 2,944 Kb |
Custom Select Element | Agrayson | 3,616 Kb |
Bootstrap 4 Gridsystem Demo | Rivella50 | 1,535 Kb |
IbrahimJabbari-Effect21 | Ibrahimjabbari | 1,882 Kb |
Cofee and sugar | Tripack | 2,094 Kb |
Fireworks Show | Arianalynn | 3,048 Kb |
Svg penguin | _massimo | 2,990 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!