Created
April 11, 2014 07:27
-
-
Save towc/10446734 to your computer and use it in GitHub Desktop.
Dastul
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
game |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" /> | |
</project> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<module type="WEB_MODULE" version="4"> | |
<component name="NewModuleRootManager"> | |
<content url="file://$MODULE_DIR$" /> | |
<orderEntry type="inheritedJdk" /> | |
<orderEntry type="sourceFolder" forTests="false" /> | |
</component> | |
</module> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="ProjectRootManager" version="2" /> | |
</project> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="ProjectModuleManager"> | |
<modules> | |
<module fileurl="file://$PROJECT_DIR$/.idea/game.iml" filepath="$PROJECT_DIR$/.idea/game.iml" /> | |
</modules> | |
</component> | |
</project> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<component name="DependencyValidationManager"> | |
<state> | |
<option name="SKIP_IMPORT_STATEMENTS" value="false" /> | |
</state> | |
</component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="VcsDirectoryMappings"> | |
<mapping directory="" vcs="" /> | |
</component> | |
</project> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head lang="en"> | |
<meta charset="UTF-8"> | |
<title>Dastul | t1wc</title> | |
</head> | |
<body> | |
<canvas id="canvas" width="1024" height="512">Too bad: your browser does not support the element where the game is run</canvas> | |
<script src="/matei/assets/require.js" data-main="/matei/games/dastul/game/scripts/main"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(function(){ | |
var Blocks={ | |
air:{ | |
sprite:new Image(), | |
friction:0.01, | |
hardness:1, | |
breakable:false, | |
solid:false, | |
gettable:5, | |
gen:function(x, y){ | |
this.type='air'; | |
this.breakPhase=0; | |
this.x=x; | |
this.y=y; | |
} | |
}, | |
rock:{ | |
sprite:new Image(), | |
friction:0.04, | |
hardness:5, | |
breakable:true, | |
solid:true, | |
gettable:3, | |
gen:function(x, y){ | |
this.type='rock'; | |
this.breakPhase=0; | |
this.x=x; | |
this.y=y; | |
} | |
}, | |
grass:{ | |
sprite:new Image(), | |
friction:0.06, | |
hardness:2, | |
breakable:true, | |
solid:true, | |
gettable:2, | |
gen:function(x, y){ | |
this.type='grass'; | |
this.breakPhase=0; | |
this.x=x; | |
this.y=y; | |
} | |
}, | |
dirt:{ | |
sprite:new Image(), | |
friction:0.08, | |
hardness:3, | |
breakable:true, | |
solid:true, | |
gettable:2, | |
gen:function(x, y){ | |
this.type='dirt'; | |
this.breakPhase=0; | |
this.x=x; | |
this.y=y; | |
} | |
} | |
}; | |
Blocks.air.sprite.src='/matei/games/dastul/game/sprites/blocks/air.png'; | |
Blocks.rock.sprite.src='/matei/games/dastul/game/sprites/blocks/rock.png'; | |
Blocks.grass.sprite.src='/matei/games/dastul/game/sprites/blocks/rock.png'; | |
Blocks.dirt.sprite.src='/matei/games/dastul/game/sprites/blocks/dirt.png'; | |
Blocks.air.gen.prototype.draw=function(){ | |
dastul.drawer.drawXY(Blocks.air.sprite, this.x, this.y); | |
}; | |
Blocks.rock.gen.prototype.draw=function(){ | |
dastul.drawer.drawXY(Blocks.rock.sprite, this.x, this.y); | |
}; | |
Blocks.grass.gen.prototype.draw=function(){ | |
dastul.drawer.drawXY(Blocks.grass.sprite, this.x, this.y); | |
}; | |
Blocks.dirt.gen.prototype.draw=function(){ | |
dastul.drawer.drawXY(Blocks.dirt.sprite, this.x, this.y); | |
}; | |
return Blocks; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(['physics', 'blocks', /*'settings', 'entities', */'world'], function(Physics, Blocks, /*Settings, Entity,*/ World){ | |
function GameManager(){ | |
//this.settings=new Settings(); | |
this.world= new World(); | |
this.physics=new Physics(); | |
//this.entities=new Entity.array(); | |
}; | |
return GameManager; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(['GameManager'], function(GameManager){ | |
var dastul=new GameManager(); | |
window.dastul=dastul; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(function(){ | |
function Physics(){ | |
this.is='still not implemented'; | |
} | |
return Physics; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(['blocks'], function(Blocks){ | |
function World(width, height){ | |
this.cells=[]; | |
this.loaded=[]; | |
this.name=''; | |
this.width=width; | |
this.height=height; | |
} | |
World.prototype.generate=function(){ | |
for(var column=0; column<this.width; ++column){ | |
this.cells.push([]); | |
for(var row=0; row<this.height; ++row){ | |
this.cells[column].push(new Blocks.air.gen(column, row)); | |
} | |
} | |
var localWidth=this.width; | |
for(var i=0; i<localWidth; ++i){ | |
var isOccupied=false; | |
for(var j=0; j<this.height; ++j){ | |
if(this.cells[i][j].type!=='air') isOccupied=true; | |
} | |
isOccupied ? ++localWidth : function () { | |
var random = Math.floor(Math.random() * this.height); | |
cells[i][random] = new Blocks.grass.gen(column, row); | |
for(var j=0; j<random; ++j){ | |
cells[i][j]=new Blocks.dirt.gen(column, row); | |
} | |
}; | |
} | |
} | |
World.prototype.draw=function(){ | |
for(var column=0; column<this.width; ++column){ | |
for(var row=0; row<this.height; ++row){ | |
} | |
} | |
} | |
return World; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
�PNG | |