commit
69b6cafb28
@ -0,0 +1,3 @@
|
||||
.idea
|
||||
/custom/*
|
||||
!/custom/.gitkeep
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,14 @@
|
||||
*{margin:0;padding:0;font-family:arial, 'sans-serif';}
|
||||
fieldset{line-height:6px}
|
||||
fieldset br{clear:both;}
|
||||
.case{display:none;width:10px;height:10px;}
|
||||
.labelcase{width:10px;height:10px;/*margin:-4px 0;*/margin:0;padding:0;background:#000;display:block;line-height:10px;font-size:7px;border:1px solid #AAA;float:left;}
|
||||
.labelSelected{background-color:#FFF;}
|
||||
.start{background:green;}
|
||||
.end{background:blue;}
|
||||
.flagover{background-color:yellow;}
|
||||
a{margin-top:10px;}
|
||||
nav{width:300px; margin:10px auto 0;}
|
||||
h3{margin:10px 0;}
|
||||
|
||||
ol li{padding-left:18px;background:url(../img/bullet_blue.png) center left no-repeat;}
|
@ -0,0 +1,4 @@
|
||||
*{margin:0;padding:0;font-family:arial, 'sans-serif'; font-size:.9em;}
|
||||
#board{width:300px;height:300px; margin:0 auto;background-color:#FFF;}
|
||||
/*#start{display:block;}*/
|
||||
nav{width:300px; margin:10px auto 0;}
|
After Width: | Height: | Size: 289 B |
After Width: | Height: | Size: 671 B |
After Width: | Height: | Size: 672 B |
@ -0,0 +1,71 @@
|
||||
function genereCheckbox(l,h){
|
||||
var checkbox = '';
|
||||
for(j=0; j<h; j++){
|
||||
for(k=0; k<l; k++)
|
||||
checkbox += '<input type="checkbox" class="case" name="check'+j+'-'+k+'" id="check'+j+'-'+k+'"/><label for="check'+j+'-'+k+'" class="labelcase"> </label>';
|
||||
checkbox += '<br/>';
|
||||
}
|
||||
return checkbox;
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
var droppableOpts = {
|
||||
hoverClass: "flagover",
|
||||
drop: function( event, ui ) {
|
||||
var drag = ui.draggable;
|
||||
if(drag.attr('id') == 'start'){
|
||||
if($(this).hasClass('end')){
|
||||
alert('Warning : you can\'t have the same starting and ending point');
|
||||
}else{
|
||||
$('label').removeClass('start');
|
||||
$(this).addClass("start");
|
||||
$('#startingPoint').val($(this).attr('for'));
|
||||
}
|
||||
}else if(drag.attr('id') == 'end'){
|
||||
if($(this).hasClass('start')){
|
||||
alert('Warning : you can\'t have the same starting and ending point');
|
||||
}else{
|
||||
$('label').removeClass('end');
|
||||
$(this).addClass("end");
|
||||
$('#endingPoint').val($(this).attr('for'));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var options = '';
|
||||
for(i=5; i<=50; i++) options = options + '<option value="'+i+'">'+i+'</option>';
|
||||
$('select').html(options);
|
||||
$('fieldset').html(genereCheckbox(5,5));
|
||||
$('select').change(function(){
|
||||
$('fieldset').html(genereCheckbox($('#largeur').val(),$('#hauteur').val()));
|
||||
});
|
||||
$('.case').live('change',function(){
|
||||
if($(this).is(":checked")){
|
||||
$('label[for="'+$(this).attr('id')+'"]').addClass("labelSelected").droppable(droppableOpts);
|
||||
}else{
|
||||
$('label[for="'+$(this).attr('id')+'"]').removeClass("labelSelected").droppable('destroy');
|
||||
}
|
||||
});
|
||||
|
||||
function check(w){
|
||||
var hasIt = false;
|
||||
$('label').each(function(){
|
||||
if($(this).hasClass(w)){
|
||||
console.log('has it :D');
|
||||
hasIt = true;
|
||||
}
|
||||
});
|
||||
return hasIt;
|
||||
}
|
||||
|
||||
$("#start, #end").draggable({revert: "invalid"});
|
||||
$(".labelSelected").droppable(droppableOpts);
|
||||
|
||||
$('#save').click(function(){
|
||||
if(!check('start') || !check('end')){
|
||||
alert('We need a starting and a ending point');
|
||||
return false;
|
||||
}
|
||||
$('form').eq(0).submit();
|
||||
});
|
||||
});
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="assets/css/editor.css" />
|
||||
<link rel="stylesheet" type="text/css" href="assets/css/css3buttons.css" />
|
||||
<script src="assets/js/jquery.min.js"></script>
|
||||
<script src="assets/js/jquery-ui.min.js"></script>
|
||||
<script src="assets/js/editor.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<nav>
|
||||
<a href="editor.html" title="Play" class="left pill button">Play</a><a href="list/" title="Custom laby list" class="right pill button">Custom laby list</a>
|
||||
</nav>
|
||||
<form action="save.php" method="POST">
|
||||
<label for="largeur">Width : </label><select name="largeur" id="largeur"></select>
|
||||
<label for="hauteur">Height : </label><select name="hauteur" id="hauteur"></select>
|
||||
Start : <img src="assets/img/flag_green.png" id="start" /> | End : <img src="assets/img/flag_blue.png" id="end" />
|
||||
<fieldset></fieldset>
|
||||
<input type="hidden" id="startingPoint" name="startingPoint" value="" />
|
||||
<input type="hidden" id="endingPoint" name="endingPoint" value="" />
|
||||
<a href="#" id="save" class="positive primary button">Save</a>
|
||||
</form>
|
||||
<h3>How to edit your level</h3>
|
||||
<ol>
|
||||
<li>Choose the size of your labyrinth</li>
|
||||
<li>Click on squares to build your labyrinth (don't forget that you can't go diagonally)</li>
|
||||
<li>Drag'n drop both flags on one of the white square to indicate a start and ending point</li>
|
||||
<li>Save it!</li>
|
||||
</ol>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,9 @@
|
||||
currentPosition = [2,4]; // x - y
|
||||
finalPosition = [1,0];
|
||||
level = [
|
||||
[0,1,0,0,0], // 0
|
||||
[0,1,1,1,0], // 1
|
||||
[0,0,0,1,0], // 2
|
||||
[0,0,1,1,0], // 3
|
||||
[0,0,1,0,0], // 4
|
||||
];
|
@ -0,0 +1,10 @@
|
||||
currentPosition = [1,1];
|
||||
finalPosition = [7,3];
|
||||
|
||||
level = [
|
||||
[0,0,0,0,0,0,0,0,0,0,0],
|
||||
[0,1,1,1,1,1,1,1,1,1,0],
|
||||
[0,0,0,1,0,1,0,1,0,1,0],
|
||||
[0,0,0,1,0,1,0,1,0,1,0],
|
||||
[0,0,0,0,0,0,0,0,0,0,0],
|
||||
];
|
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
session_start();
|
||||
$currentFile = !empty($_SESSION['file']) ? $_SESSION['file'] : null;
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="index.css" />
|
||||
<style>
|
||||
#board{width:300px;height:300px; margin:200px auto;}
|
||||
#start{display:block;}
|
||||
.current{background-color:yellow;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="board">
|
||||
<?php
|
||||
$folder =new DirectoryIterator('../custom/');
|
||||
|
||||
foreach($folder as $file){
|
||||
if(!$file->isDir()){
|
||||
echo '<a href="http://labs.shikiryu.com/experimental-games/2/?level='.substr($file->getFileName(), 0, -3).'" title="laby '.substr($file->getFileName(), 0, -3).'"';
|
||||
if($currentFile !== null && $currentFile == $file->getFileName()) echo ' class="current"';
|
||||
echo '>laby '.substr($file->getFileName(), 0, -3).'</a><br/>';
|
||||
}
|
||||
}
|
||||
?></div>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
session_start();
|
||||
$startingPoint = $_POST['startingPoint'];
|
||||
$endingPoint = $_POST['endingPoint'];
|
||||
$largeur = (int)$_POST['largeur'];
|
||||
$hauteur = (int)$_POST['hauteur'];
|
||||
$cases = array();
|
||||
foreach($_POST as $n=>$v){
|
||||
if(!in_array($n, array('startingPoint','endingPoint','largeur','hauteur'))){
|
||||
$coord = getCoordForCase($n);
|
||||
$cases[$coord[0]][$coord[1]] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
function getCoordForPt($t){
|
||||
if (preg_match('/^check(\d{1,2})-(\d{1,2})$/', $t, $m) !== 0) {
|
||||
return '[' . $m[2] . ',' . $m[1] . ']';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function getCoordForCase($t){
|
||||
if (preg_match('/^check(\d{1,2})-(\d{1,2})$/', $t, $m) !== 0) {
|
||||
return [$m[1], $m[2]];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$level = '[';
|
||||
for($i=0; $i<$hauteur; $i++){
|
||||
$level .= '[';
|
||||
for($j=0; $j<$largeur; $j++){
|
||||
if(!empty($cases[$i][$j])) {
|
||||
$level .= '1,';
|
||||
} else {
|
||||
$level .= '0,';
|
||||
}
|
||||
}
|
||||
$level = substr($level, 0, -1).'],';
|
||||
}
|
||||
$level = substr($level, 0, -1).'];';
|
||||
$file = '';
|
||||
$file .= 'currentPosition = '.getCoordForPt($startingPoint).';';
|
||||
$file .= 'finalPosition ='.getCoordForPt($endingPoint).';';
|
||||
$file .= 'level = '.$level;
|
||||
$tod = gettimeofday();
|
||||
$finalFilename = $tod['sec'].mt_rand(0,50).'.js';
|
||||
file_put_contents(__DIR__ .'/custom/'.$finalFilename, $file);
|
||||
$_SESSION['file'] = $finalFilename;
|
||||
header('Location: list/');
|
Loading…
Reference in new issue