Skip to content

Commit

Permalink
synk
Browse files Browse the repository at this point in the history
  • Loading branch information
1j01 committed Oct 26, 2013
1 parent bae53a9 commit 4420450
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 48 deletions.
28 changes: 27 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,43 @@
.modal .content {
background: rgba(0,0,0,0.1) !important;
}
.onerror {
position: absolute;
left: 0; right: 0;
top: 0; bottom: 0;

padding: 5px;

background: rgba(255,0,0,0.5);
color: white;
}
a { /* most <a>s will probably be on a dark bg */
cursor: pointer !important;
color: #CCC;
} a:hover {
color: #DDD;
} a:active {
color: #AAA;
}
</style>
<link rel="stylesheet" type="text/css" href="gui.css">
</head>
<body>
<script>onerror=function(err,url,line){document.body.style.background="red"};</script>
<script>
var _$errs=document.createElement("div");
_$errs.className = "onerror";
onerror=function(err,url,line){
_$errs.innerHTML+="<a href='"+url+"'>"+url+"</a>, line "+line+"<br><p>"+err+"</p><hr>";
document.body.appendChild(_$errs);
}
</script>

<canvas id="main"/>

<script src="aa.js"></script>
<script src="am.js"></script>
<script src="pe.js"></script>
<script src="be.js"></script>

<script src="room.js"></script>
<script src="u.js"></script>
Expand Down
98 changes: 51 additions & 47 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@

const TS = 32;
TS = 32;

//(function(_main_){
var canvas = document.querySelector("canvas");
var mainctx = canvas.getContext("2d");
addEventListener('contextmenu',function(e){return!!e.preventDefault()});
//addEventListener('mousedown',function(e){return!!e.preventDefault()});

var editing = true;

var gui = new GUI();

var u, le, game;

var aa = new ArtAssets(mainctx, whenceBeAssetsLoaded, whenceAnUpdateDothForsooth);
var am = new ArtManager(aa, gui);

var u, le, game;

function whenceAnUpdateDothForsooth(){
am.update();
}
function whenceBeAssetsLoaded(){
console.log("Assets loaded.");
am.update();
try {
try{
u = new Universe(mainctx);
var room = new Room("starting area",2,2,38/2,24/2,aa);
room.rows[6][5]={
Expand All @@ -30,20 +33,19 @@ const TS = 32;
u.addRoom(room2);
le = new LevelEditor(u, mainctx);
game = new Game(u, mainctx);
} catch(e){
}catch(e){
gui.M().title("Something didn't work!").content(e.message).position("bottom");
}
}
function whenceAnUpdateDothForsooth(){
am.update();
}

if(window.requestAnimationFrame){
requestAnimationFrame(function animate(){
requestAnimationFrame(animate);
var req = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame;
if(req){
var animate = function(){
req(animate);
step();
});
};
req(animate);
}else{
console.log("Wow, no requestAnimationFrame? Lamesauce.");
setTimeout(step,10);
}

Expand All @@ -64,38 +66,40 @@ const TS = 32;
var mainScreen = null;
var mainScreenTurnOn = function(){
mainScreen = gui.M()
.title("Controls")
.position("center")
.content(
"<button id='show-art-manager'>Show Art Asset Manager</button>"+
"<br><button id='open-pixel-editor'>Open Pixel Editor</button>"+
"<br><button id='about'>About</button>"
).$("#show-art-manager",function($e){
$e.onclick = function(e){
am.show();
};
}).$("#open-pixel-editor",function($e){
$e.onclick = function(e){
new PixelEditor(gui,null,function(img){
console.log("~update(img){ window.unsaved = img.src; }()");
window.unsaved = img.src;
});
};
}).$("#about",function($e){
$e.onclick = function(e){
var m=gui.M().title("About").position("center").content(
"<p>This is an abstracted modular game framework with integrated pixel editor and realtime asset manager and a level editor with dynamic block type definitions and a skeletal character animator and inverse kinematics and a game.</p>"
+"<p>Well, so far just a pixel editor and realtime asset manager...</p>"
+"<p>...</p>"
+"<p><a href='https://github.com/1j01/amg'>It's on github.</a></p>"
);
m.$m.style.width="500px";
m.$m.style.maxWidth="80vw";
m.$c.style.maxHeight="80vh";
m.$c.style.overflowY="auto";
m.$c.style.overflowX="auto";
};
});
.title("Controls")
.position("center")
.content(
"<button id='show-art-manager'>Show Art Asset Manager</button>"+
"<br><button id='open-pixel-editor'>Open Pixel Editor</button>"+
"<br><button id='about'>About</button>"
).$("#show-art-manager",function($e){
$e.onclick = function(e){
am.show();
};
}).$("#open-pixel-editor",function($e){
$e.onclick = function(e){
new PixelEditor(gui,null,function(img){
console.log("window.unsaved = img.src;");
window.unsaved = img.src;
},function(img, shiftKey){
window.open(img.src);
});
};
}).$("#about",function($e){
$e.onclick = function(e){
var m=gui.M().title("About").position("center").content(
"<p>This is an abstracted modular game framework with integrated pixel editor and realtime asset manager and a level editor with dynamic block type definitions and a skeletal character animator and inverse kinematics and a game.</p>"
+"<p>Well, so far just a pixel editor and realtime asset manager...</p>"
+"<p>...</p>"
+"<p><a href='https://github.com/1j01/amg'>It's on github.</a></p>"
);
m.$m.style.width="500px";
m.$m.style.maxWidth="80vw";
m.$c.style.maxHeight="80vh";
m.$c.style.overflowY="auto";
m.$c.style.overflowX="auto";
};
});
mainScreen.onclose = function(){
mainScreen=false;
return true;
Expand All @@ -114,7 +118,7 @@ const TS = 32;
}
}
});
//var pe = new PixelEditor(gui);
//var pe = new PixelEditor(gui,..?);
mainScreenTurnOn();
//})();

0 comments on commit 4420450

Please sign in to comment.