cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <html>
 <head>
	<meta charset=utf-8 />
	<title>fun with maps </title>

	<link href='https://fonts.googleapis.com/css?family=Ubuntu+Mono' rel='stylesheet' type='text/css'>

    
    <!-- USE WASD to MOVE-->
    <!-- E for Action --> 
    
</head>
  <body>
   <div  class="minime"></div>
   <div class='custom-popup' id='map'></div>
  </body>
</html>

            
          
!
            
                body { margin:0; padding:0; }
  #map { position:absolute; top:0; bottom:0; width:100%; }

/* 
Original Graphic Sources From: http://vxresource.wordpress.com/category/resources/tilesets/
AND 
zelda_fire_render.gif:
http://www.p4rgaming.com/wp-content/uploads/2013/01/
*/
.minime { 
    width:32px; height:48px;
    background-image:url('http://www.maptags.de/wp-content/uploads/2014/07/minime.png'); 
	background-position:  0px 0px;
}

.fire { 
    width:32px; height:32px; 
    background-image:url('http://www.maptags.de/wp-content/uploads/2014/07/fire.gif'); 
}


/*
From https://codepen.io/jkneb/pen/smtHA
*/

.down { 
   -webkit-animation: down .2s steps(4) infinite;
   -moz-animation: down .2s steps(4) infinite;
   -ms-animation: down .2s steps(4) infinite;
   -o-animation: down .2s steps(4) infinite;
   animation: down .2s steps(4) infinite; 

}

@-webkit-keyframes down {
   from { background-position:   0px 0px; }
     to { background-position: 128px 0px; }
}

@-moz-keyframes down {
   from { background-position:   0px 0px; }
     to { background-position: 128px 0px; }
}

@-ms-keyframes down {
   from { background-position:   0px 0px; }
     to { background-position: 128px 0px; }
}

@-o-keyframes down {
   from { background-position:   0px 0px; }
     to { background-position: 128px 0px; }
}

@keyframes down {
   from { background-position:   0px 0px; }
     to { background-position: 128px 0px; }
}



.left { 
   -webkit-animation: left .2s steps(4) infinite;
   -moz-animation: left .2s steps(4) infinite;
   -ms-animation: left .2s steps(4) infinite;
   -o-animation: left .2s steps(4) infinite;
   animation: left .2s steps(4) infinite; 
}

@-webkit-keyframes left {
   from { background-position:   0px -48px; }
     to { background-position: 128px -48px; }
}
@-moz-keyframes left {
   from { background-position:   0px -48px; }
     to { background-position: 128px -48px; }
}

@-ms-keyframes left {
   from { background-position:   0px -48px; }
     to { background-position: 128px -48px; }
}

@-o-keyframes left {
   from { background-position:   0px -48px; }
     to { background-position: 128px -48px; }
}

@keyframes left {
   from { background-position:   0px -48px; }
     to { background-position: 128px -48px; }
}



.up { 
   -webkit-animation: up .2s steps(4) infinite;
   -moz-animation: up .2s steps(4) infinite;
   -ms-animation: up .2s steps(4) infinite;
   -o-animation: up .2s steps(4) infinite;
   animation: up .2s steps(4) infinite; 
}

@-webkit-keyframes up {
   from { background-position:   0px -144px; }
     to { background-position: 128px -144px; }
}
@-moz-keyframes up {
   from { background-position:   0px -144px; }
     to { background-position: 128px -144px; }
}

@-ms-keyframes up {
   from { background-position:   0px -144px; }
     to { background-position: 128px -144px; }
}

@-o-keyframes up {
   from { background-position:   0px -144px; }
     to { background-position: 128px -144px; }
}

@keyframes up {
   from { background-position:   0px -144px; }
     to { background-position: 128px -144px; }
}



.right { 
   -webkit-animation: right .2s steps(4) infinite;
   -moz-animation: right .2s steps(4) infinite;
   -ms-animation: right .2s steps(4) infinite;
   -o-animation: right .2s steps(4) infinite;
   animation: right .2s steps(4) infinite; 
}

@-webkit-keyframes right {
   from { background-position:   0px -96px; }
     to { background-position: 128px -96px; }
}
@-moz-keyframes right {
   from { background-position:   0px -96px; }
     to { background-position: 128px -96px; }
}

@-ms-keyframes right {
   from { background-position:   0px -96px; }
     to { background-position: 128px -96px; }
}

@-o-keyframes right {
   from { background-position:   0px -96px; }
     to { background-position: 128px -96px; }
}

@keyframes right {
   from { background-position:   0px -96px; }
     to { background-position: 128px -96px; }
}




.custom-popup .leaflet-popup-content-wrapper {
  background:rgba(44, 62, 80, 0.5);
  color:#fff;
  font-size:12px;
  line-height:24px;
  border: 5px ridge #8DB6CD;padding:3px;
 font-family: 'Ubuntu Mono';
  }
.custom-popup .leaflet-popup-content-wrapper a {
  color:rgba(255,255,255,0.5);

  }
.custom-popup .leaflet-popup-tip-container {
#margin: 0 10px;
width: 40px;
height: 20px;
position: relative;
overflow: hidden;
  }
.custom-popup .leaflet-popup-tip {
  #border-left:20px solid transparent;
  #border-right:20px solid transparent;
  border-top:20px solid #8DB6CD;
  margin: -20px 0px;

}
.leaflet-popup-close-button+.leaflet-popup-content-wrapper .leaflet-popup-content {
  padding: 0px 0px 0px;
}


.leaflet-popup-pane {
	top: -15px;
	left:80px;
	padding: 0px 0px 0px;
}
            
          
!
            
              /* 
Original Source From: 
https://github.com/mapbox/leaflet-pip
*/
var map = L.mapbox.map('map', 'maptagsde.imalja62',{zoomControl: false}).setView([51.509, -0.08], 2);

map.doubleClickZoom.disable();
map.scrollWheelZoom.disable();
map.touchZoom.disable();


var fireplaceArea = { "type": "Feature", "geometry": { "type": "Polygon", "coordinates": [ 
[ [ -12.56772109426303, 76.640675139015244 ], 
[ 12.957173087971377, 76.518527926744383 ], 
[ 12.957173087971377, 76.518527926744383 ], 
[ 13.088744707467416, 73.905859897440834 ], 
[ -12.436149474766973, 73.905859897440834 ],
 [ -12.56772109426303, 76.640675139015244 ] ] 
 ] } }

var roomBounds = {"type":"Feature","geometry":{"type": "Polygon","coordinates":[
[[ -62.676772379335048, -82.108591935621632 ], 
[ -62.676772379335048, -78.742006162967286 ], 
[ -79.513992526245048, -78.72478331549398 ], 
[ -79.249533571057981, -7.03449920804889 ], 
[ -70.963152975196522, -7.209444813339119 ], 
[ -70.874999990134171, -21.103470505223903 ], 
[ -45.486940292175639, -21.103470505223903 ],
[ -45.927705217487421, -7.03449920804889 ], 
[ -12.341417908729781, -7.03449920804889 ], 
[ -12.341417908729781, 45.751964523699577 ], 
[ -79.513992526245062, 45.690420480697462 ], 
[ -79.073227600933294, 73.966295667280988 ], 
[ -28.826026115390352, 73.966295667280988 ], 
[ -28.914179100452714, 77.471493249880709 ], 
[ -14.897854475538113, 77.528732037201564 ], 
[ -14.809701490475755, 76.123717780534506 ], 
[ 15.955690296286495, 76.123717780534506 ], 
[ 15.779384326161781, 77.547754382608574 ], 
[ 65.189132453612316, 77.547754382608574 ], 
[ 65.277285438674667, 73.396666822787068 ], 
[ 79.910680959025768, 73.371459047954829 ], 
[ 79.822527973963403, 45.75196452369957 ], 
[ -3.878731342743613, 45.75196452369957 ], 
[ -3.878731342743613, -6.947001577535963 ], 
[ 12.870335819104028, -6.77195766569692 ], 
[ 12.782182834041672, -23.063801000907869 ], 
[ 79.910680959025768, -23.306900951671896 ], 
[ 79.822527973963403, -78.690259563165014 ], 
[ -12.121035446073897, -78.724783315494008 ], 
[ -12.385494401260965, -43.87614760578316 ], 
[ -37.420942158970071, -43.87614760578316 ], 
[ -37.509095144032422, -78.724783315494008 ],
[ -54.170009320817705, -78.742006162967314 ], 
[ -54.346315290942421, -82.120685770878296 ], 
[ -54.346315290942421, -82.120685770878296 ], 
[ -54.346315290942421, -82.120685770878296 ], 
[ -62.676772379335048, -82.108591935621632 ] ],
[ [ 17.674673505002403, -57.392181242879481 ], 
[ 17.850979475127115, -71.258353791220003 ], 
[ 67.21665111004647, -71.201623831408469 ], 
[ 67.392957080171186, -57.106045004950815 ], 
[ 17.674673505002403, -57.392181242879481 ] ], 
[ [ -49.850513052762281, 62.419901109202549 ], 
[ -49.674207082637572, 53.809481980674889 ], 
[ -33.10144589091464, 54.017172832629889 ], 
[ -33.277751861039356, 62.582711593280344 ], 
[ -49.850513052762281, 62.419901109202549 ]]
 ]}};


//MARKER 
var marker = L.marker([51.51, -0.078],  {
        icon: L.divIcon({
            className: 'minime',
            iconSize: [32, 48]
        })
    }).bindPopup("Hello and welcome everyone.");
marker.addTo(map);



var fire = L.marker([78, 0],  {
        icon: L.divIcon({
            className: 'fire',
            iconSize: [32, 32],
			
        })
    });




//MOVEMENT + BOUNDS
var gjLayer = L.geoJson(roomBounds);
var fireArea = L.geoJson(fireplaceArea);
var $minime = $('.minime');

function callFire(){
	var div = document.createElement('div');
	div.setAttribute('class', 'fire');
	document.body.appendChild(div);
	fire.addTo(map);
	marker.bindPopup("It is getting warmer...").openPopup();
}

$(document).on('keydown', function(e) {
			 var inFireRange = leafletPip.pointInLayer(L.latLng([marker.getLatLng().lat, marker.getLatLng().lng]), fireArea, true);
			 if (inFireRange.length && $(".fire").length === 0){		
					marker.bindPopup("I'm cold...").openPopup();				
				} else{}
				
switch(e.keyCode) {
	case 87:
     var up = leafletPip.pointInLayer(L.latLng([marker.getLatLng().lat + 2, marker.getLatLng().lng]), gjLayer, true);
        if (up.length){
            marker.setLatLng(L.latLng([marker.getLatLng().lat + 2, marker.getLatLng().lng]));
			$('.minime').addClass('up');
			setTimeout(function() { $minime.removeClass('up'); }, 200);
			$minime.css('background-position', '0px -144px');
	
			 }
        else {}
       break;
	case 68:
	 var right = leafletPip.pointInLayer(L.latLng([marker.getLatLng().lat, marker.getLatLng().lng  + 2]), gjLayer, true);
		if (right.length){
			marker.setLatLng(L.latLng([marker.getLatLng().lat, marker.getLatLng().lng + 2])); //right
			$('.minime').addClass('right');
			setTimeout(function() { $minime.removeClass('right'); }, 200);
			$minime.css('background-position', '0px -96px');
        }
        else {}
        break;	
	 case 83:
	  var down = leafletPip.pointInLayer(L.latLng([marker.getLatLng().lat - 2, marker.getLatLng().lng]), gjLayer, true);
		if (down.length){
			marker.setLatLng(L.latLng([marker.getLatLng().lat - 2, marker.getLatLng().lng])); //down
			$('.minime').addClass('down');
			setTimeout(function() { $minime.removeClass('down'); }, 200);
			$minime.css('background-position', '0px 0px');
        }
		else {}
		break;
	case 65:	
	  var left = leafletPip.pointInLayer(L.latLng([marker.getLatLng().lat, marker.getLatLng().lng - 2]), gjLayer, true);
		if (left.length){
			marker.setLatLng(L.latLng([marker.getLatLng().lat, marker.getLatLng().lng - 2])); //left
			$('.minime').addClass('left');
			setTimeout(function() { $minime.removeClass('left'); }, 200);
			$minime.css('background-position', '0px -48px');
        }
		else {}
		break;  		
	case 69:
	
	  	  var inFireRange = leafletPip.pointInLayer(L.latLng([marker.getLatLng().lat, marker.getLatLng().lng]), fireArea, true);
		  //alert($(".fire").length);
		if (inFireRange.length && $(".fire").length === 0){
			callFire();
        }
		else {
			marker.bindPopup("What to do?").openPopup()
		}
		break; 
		}
});	
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console