Skip to content

Commit

Permalink
presentation
Browse files Browse the repository at this point in the history
  • Loading branch information
gabonator committed Mar 5, 2023
1 parent d56663e commit 47c6620
Show file tree
Hide file tree
Showing 8 changed files with 368 additions and 28 deletions.
Binary file added 2023/Programming3/prezentacia.pdf
Binary file not shown.
4 changes: 4 additions & 0 deletions 2023/Programming3/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,9 @@ Ako budeme hru ďalej rozvíjať, závisí od šikovnosti účastníkov. Možnos

- [Priprava pre ucastnikov](priprava/priprava.md)

## Prezentacia

- [Prezentacia](prezentacia.pdf)

## Ulohy
- [Zoznam uloh](ulohy.md)
111 changes: 111 additions & 0 deletions 2023/Programming3/ukazky/kluce.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<div id="hra"></div>

<script>
var hra = document.getElementById("hra");

for (var y=0; y<10; y++)
{
for (var x=0; x<10; x++)
hra.innerHTML += `<span id='cell_${x}_${y}'></span>`;
hra.innerHTML += "<br>";
}

var mapa = [
"##########",
"# #e #",
"# ## # #",
"# # #d#",
"# x ###d#",
"# # #",
"# #. #####",
"# # d k#",
"#k# # k#",
"##########"];

for (var y=0; y<10; y++)
{
for (var x=0; x<10; x++)
{
var cell = document.getElementById(`cell_${x}_${y}`);
cell.style.display = "inline-block";
cell.style.overflow = "hidden";
cell.style.width = "55px";
cell.style.height = "55px";// = "display: inline-block; width:50px; height:50px; clip:rect(0px, 0px, 50px, 50px)";
cell.style.background = "url(tiles.png)";
cell.style.backgroundRepeat = "no-repeat";
cell.style.fontSize = "40px"
cell.style.textAlign = "center";
cell.style.lineHeight = "60px"
switch (mapa[y][x])
{
case "#": cell.style.backgroundPosition = "-4px -2px"; break;
case " ":
case "k":
case "d":
case "e":
switch (Math.floor(Math.random()*4))
{
case 0: cell.style.backgroundPosition = "-2px -128px"; break;
case 1: cell.style.backgroundPosition = "-126px -128px"; break;
case 2: cell.style.backgroundPosition = "-250px -128px"; break;
case 3: cell.style.backgroundPosition = "-374px -128px"; break;
}
break;
}
switch (mapa[y][x])
{
case "k": cell.innerHTML = "&#x1f511;"; break;
case "d": cell.innerHTML = "&#x1f6aa;"; break;
case "e": cell.innerHTML = "&#x1F353;"; break;
}
}
}

var x = 5;
var y = 5;

var leftKey = 37, upKey = 38, rightKey = 39, downKey = 40, spaceKey = 32;
document.addEventListener("keydown", e => {
switch (e.keyCode)
{
case leftKey: pohyb(-1, 0); break;
case rightKey: pohyb(+1, 0); break;
case upKey: pohyb(0, -1); break;
case downKey: pohyb(0, +1); break;
}
});

String.prototype.replaceAt = function(index, replacement) {
return this.substring(0, index) + replacement + this.substring(index + replacement.length);
}

pohyb(0, 0);
var klucov = 0;
function pohyb(dx, dy)
{
if (mapa[y+dy][x+dx] == "e")
{
mapa[y+dy] = mapa[y+dy].replaceAt(x+dx, " ");
alert("Hura!");
}
if (mapa[y+dy][x+dx] == "k")
{
klucov++;
mapa[y+dy] = mapa[y+dy].replaceAt(x+dx, " ");
}
if (mapa[y+dy][x+dx] == "d" && klucov > 0)
{
klucov--;
mapa[y+dy] = mapa[y+dy].replaceAt(x+dx, " ");
}
if (mapa[y+dy][x+dx] != " ")
return;

var cell = document.getElementById(`cell_${x}_${y}`);
cell.innerHTML = ""
x = x + dx;
y = y + dy;
var cell = document.getElementById(`cell_${x}_${y}`);
cell.innerHTML = "&#x1f600;"
}
</script>
155 changes: 155 additions & 0 deletions 2023/Programming3/ukazky/sokoban.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
<div id="hra"></div>

<script>
var hra = document.getElementById("hra");

for (var y=0; y<13; y++)
{
for (var x=0; x<19; x++)
hra.innerHTML += `<span id='cell_${x}_${y}'></span>`;
hra.innerHTML += "<br>";
}

var mapa = [
" ",
" ##### ",
" # # ",
" #x # ",
" ### x## ",
" # x x # ",
"### # ## # ######",
"# # ## ##### ..#",
"# x x ..#",
"##### ### # ## ..#",
" # #########",
" ####### ",
" ",
" "];

for (var y=0; y<13; y++)
{
mapa[y] = mapa[y].split("");
for (var x=0; x<19; x++)
{
var cell = document.getElementById(`cell_${x}_${y}`);
cell.style.display = "inline-block";
cell.style.overflow = "hidden";
cell.style.width = "55px";
cell.style.height = "55px";// = "display: inline-block; width:50px; height:50px; clip:rect(0px, 0px, 50px, 50px)";
cell.style.background = "url(tiles.png)";
cell.style.backgroundRepeat = "no-repeat";
cell.style.fontSize = "40px"
cell.style.textAlign = "center";
cell.style.lineHeight = "60px"
switch (mapa[y][x])
{
case "#": cell.style.backgroundPosition = "-4px -2px"; break;
case " ":
case "k":
case "d":
case "e":
case ".":
case "x":
switch (Math.floor(Math.random()*4))
{
case 0: cell.style.backgroundPosition = "-2px -128px"; break;
case 1: cell.style.backgroundPosition = "-126px -128px"; break;
case 2: cell.style.backgroundPosition = "-250px -128px"; break;
case 3: cell.style.backgroundPosition = "-374px -128px"; break;
}
break;
}
switch (mapa[y][x])
{
case "k": cell.innerHTML = "&#x1f511;"; break;
case "d": cell.innerHTML = "&#x1f6aa;"; break;
case "e": cell.innerHTML = "&#x1F353;"; break;
case "x": cell.innerHTML = "&#x1F30d;"; break;
case ".": cell.innerHTML = "&#x1F310;"; break;
}
}
}

var x = 11;
var y = 9;

var leftKey = 37, upKey = 38, rightKey = 39, downKey = 40, spaceKey = 32;
document.addEventListener("keydown", e => {
switch (e.keyCode)
{
case leftKey: pohyb(-1, 0); break;
case rightKey: pohyb(+1, 0); break;
case upKey: pohyb(0, -1); break;
case downKey: pohyb(0, +1); break;
}
});

String.prototype.replaceAt = function(index, replacement) {
return this.substring(0, index) + replacement + this.substring(index + replacement.length);
}

pohyb(0, 0);
var klucov = 0;
function pohyb(dx, dy)
{
if (mapa[y+dy][x+dx] == "x")
{
if (mapa[y+dy*2][x+dx*2] == " ")
{
mapa[y+dy][x+dx] = " ";
mapa[y+dy*2][x+dx*2] = "x";
var cell = document.getElementById(`cell_${x+dx*2}_${y+dy*2}`);
cell.innerHTML = "&#x1F30d;"
}
if (mapa[y+dy*2][x+dx*2] == ".")
{
mapa[y+dy][x+dx] = " ";
mapa[y+dy*2][x+dx*2] = "X";
var cell = document.getElementById(`cell_${x+dx*2}_${y+dy*2}`);
cell.innerHTML = "&#x1F315;"
}
}
if (mapa[y+dy][x+dx] == "X")
{
if (mapa[y+dy*2][x+dx*2] == " ")
{
mapa[y+dy][x+dx] = ".";
mapa[y+dy*2][x+dx*2] = "x";
var cell = document.getElementById(`cell_${x+dx*2}_${y+dy*2}`);
cell.innerHTML = "&#x1F30d;"
}
if (mapa[y+dy*2][x+dx*2] == ".")
{
mapa[y+dy][x+dx] = ".";
mapa[y+dy*2][x+dx*2] = "X";
var cell = document.getElementById(`cell_${x+dx*2}_${y+dy*2}`);
cell.innerHTML = "&#x1F315;"
}
}

if (mapa[y+dy][x+dx] == "e")
{
mapa[y+dy][x+dx] = " ";
alert("Hura!");
}
if (mapa[y+dy][x+dx] == "k")
{
klucov++;
mapa[y+dy][x+dx] = " ";
}
if (mapa[y+dy][x+dx] == "d" && klucov > 0)
{
klucov--;
mapa[y+dy][x+dx] = " ";
}
if (mapa[y+dy][x+dx] != " " && mapa[y+dy][x+dx] != ".")
return;

var cell = document.getElementById(`cell_${x}_${y}`);
cell.innerHTML = mapa[y][x] == "." ? "&#x1F310;" : "";
x = x + dx;
y = y + dy;
var cell = document.getElementById(`cell_${x}_${y}`);
cell.innerHTML = "&#x1f600;"
}
</script>
11 changes: 11 additions & 0 deletions 2023/Programming3/ukazky/tile.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<span id="cell"></span>
<script>
var cell = document.getElementById(`cell`);
cell.style.display = "inline-block";
cell.style.overflow = "hidden";
cell.style.width = "55px";
cell.style.height = "55px";
cell.style.background = "url(tiles.png)";
cell.style.backgroundRepeat = "no-repeat";
cell.style.backgroundPosition = "-250px -128px";
</script>
Binary file added 2023/Programming3/ukazky/tiles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions 2023/Programming3/ukazky/utf.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<span id="cell"></span>

<script>
var cell = document.getElementById(`cell`)
cell.style.display = "inline-block"
cell.style.overflow = "hidden"
cell.style.width = "55px"
cell.style.height = "55px"
cell.style.fontSize = "40px"
cell.style.textAlign = "center"
cell.style.lineHeight = "60px"
cell.style.background = "#d0d0d0"
cell.innerHTML = "&#x1f511;"
</script>
Loading

0 comments on commit 47c6620

Please sign in to comment.