🎉 Hello world (finally)!

main
Clement 2 years ago
commit 69b6cafb28
  1. 3
      .gitignore
  2. 87
      assets/css/css3buttons.css
  3. 14
      assets/css/editor.css
  4. 4
      assets/css/index.css
  5. BIN
      assets/img/bullet_blue.png
  6. BIN
      assets/img/flag_blue.png
  7. BIN
      assets/img/flag_green.png
  8. 71
      assets/js/editor.js
  9. 11631
      assets/js/jquery-ui.min.js
  10. 1
      assets/js/jquery.color.js
  11. 154
      assets/js/jquery.min.js
  12. 317
      assets/js/load.js
  13. BIN
      assets/sounds/come_get_some_x.wav
  14. BIN
      assets/sounds/gameover.wav
  15. BIN
      assets/sounds/gameover2.wav
  16. BIN
      assets/sounds/ko.mp3
  17. BIN
      assets/sounds/ko.wav
  18. BIN
      assets/sounds/ok.mp3
  19. BIN
      assets/sounds/ok.wav
  20. BIN
      assets/sounds/undefined.mp3
  21. BIN
      assets/sounds/undefined.wav
  22. BIN
      assets/sounds/welldone.wav
  23. 0
      custom/.gitkeep
  24. 31
      editor.html
  25. 30
      index.php
  26. 9
      level1.js
  27. 10
      level2.js
  28. 29
      list/index.php
  29. 50
      save.php

3
.gitignore vendored

@ -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;}

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 671 B

Binary file not shown.

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">&nbsp;</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,30 @@
<?php
$file = isset($_GET['level']) ? $_GET['level'] : null;
$custom = 'false';
$niveau = '1';
if ($file !== null && file_exists(__DIR__ .'/custom/'.$file.'.js')){
$custom = 'true';
$niveau = $file;
}
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="assets/css/index.css" />
<link rel="stylesheet" type="text/css" href="assets/css/css3buttons.css" />
<style>
#board{width:300px;height:300px; margin:200px auto;background-color:#FFF;}
#start{display:block;}
</style>
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/jquery.color.js"></script>
<script>
let niveau = <?=$niveau?>;
let custom = <?=$custom?>;
</script>
<script src="assets/js/load.js"></script>
</head>
<body>
<noscript>javascript must be activated to play this game.</noscript>
</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…
Cancel
Save