Skip to content

Instantly share code, notes, and snippets.

@towc
Created April 11, 2014 07:27
Show Gist options
  • Save towc/10446734 to your computer and use it in GitHub Desktop.
Save towc/10446734 to your computer and use it in GitHub Desktop.
Dastul
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
</project>
<?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>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" />
</project>
<?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>
<component name="DependencyValidationManager">
<state>
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</state>
</component>
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="" />
</component>
</project>
<!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>
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;
});
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;
});
require(['GameManager'], function(GameManager){
var dastul=new GameManager();
window.dastul=dastul;
});
define(function(){
function Physics(){
this.is='still not implemented';
}
return Physics;
});
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;
});
�PNG

IHDR��� pHYs���+ IDAT�c` ����IEND�B`�
�PNG

IHDR��� pHYs���+%IDAT�chp`�3���@� pLEȂȊ����x�^g��IEND�B`�
�PNG

IHDR��� pHYs���+$IDAT�c`h`����@� L=Ȃ(���R,q���uIEND�B`�
�PNG

IHDR��� pHYs���+&IDAT�c�9s�|�D�g�� pLEȂȊ��3��
#�IEND�B`�
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment