Skip to content

Instantly share code, notes, and snippets.

@Kanol
Created November 28, 2015 15:25
Show Gist options
  • Save Kanol/ea46603afad062da4a91 to your computer and use it in GitHub Desktop.
Save Kanol/ea46603afad062da4a91 to your computer and use it in GitHub Desktop.
<head>
<meta charset=utf-8>
<style>
.air{
background: rgb(255,255,255);
}
.dirt{
background: rgb(153,76,0);
}
.stone{
background: rgb(192,192,192);
}
</style>
</head>
<body>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script>
function Random(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function MapGeneration(){
var x=10;
var Map=[];
var DirtMaxHeight;
var DirtMaxCount;
for(var i=0, i<x, i++){
Map[i]=[];
Map[i][0]='air';
Map[i][1]='air';
DirtMaxCount=Random(1,6);
DirtMaxHeight=Random(2,6);
for(var i=6, i>=DirtMaxCount, i--){
Map[x][i]='dirt';
DirtMaxCount--;
if(DirtMaxCount==0)
}
}
}
function MapGeneration(x, y){
var Map=[];
for(var i=x, i>0, i--){
Map[i]=[];
}
for(var i=0, x>i, i++){
for(var b=0, y>b, b++){
var Block=Random(0,y);
if(Block<=y/3){
Map[i][b]='dirt';
}else{
Map[i][b]='air';
}
}
}
}
function MapDraw(Map){
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment