Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ugurkilci committed Jun 25, 2019
1 parent d40e6ee commit afe9af7
Show file tree
Hide file tree
Showing 21 changed files with 831 additions and 0 deletions.
Binary file added honeycomb/SnakeGame/GameOver.mp3
Binary file not shown.
Binary file added honeycomb/SnakeGame/SnakeEating.mp3
Binary file not shown.
27 changes: 27 additions & 0 deletions honeycomb/SnakeGame/snakeGame.html
@@ -0,0 +1,27 @@
<!doctype html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="snakeGame.js" type="text/javascript"></script>
<style>
</style>
</head>
<body style="margin: 0px;">
<canvas id="canvas" width="250px" height="250px">Hay Aksi, Tarayıcını Yükseltmelisin!</canvas>
<audio id="GamePlay" loop="loop" autoplay="autoplay">
</audio>
<audio id="GameOver">
<source src="GameOver.mp3" type="audio/mpeg" />
Tarayıcınız HTML5 ses desteklemiyor.
</audio>
<audio id="SnakeFood">
<source src="SnakeEating.mp3" type="audio/mpeg" />
Tarayıcınız HTML5 ses desteklemiyor.
</audio>
<br/>

<button id="pause">Dur dur</button>
<button id="play">Oynat</button>
<button id="Soundoff">Sesi kapat</button>
<button id="SoundOn">Ses a&ccedil;</button>
</body>
200 changes: 200 additions & 0 deletions honeycomb/SnakeGame/snakeGame.js
@@ -0,0 +1,200 @@

$(document).ready(function(){
var canvas = $("#canvas")[0];
var Context = canvas.getContext("2d");
var w = $("#canvas").width();
var h = $("#canvas").height();
var GameOver = $("audio#GameOver").get(0);
var GamePlay = $("audio#GamePlay").get(0);
var SnakeEating = $("audio#SnakeFood").get(0);
var cw = 10;
var direction;
var apple;
var score;
var SnakeArray;
$("button#play").hide();
$("button#Soundoff").hide();
function GameStart()
{
if (GamePlay.paused)
GamePlay.play();
direction = "right";
Paint_Snake();
create_apple();
score = 0;
Speed =40;
play();
}
function play()
{
if(typeof Game_Interval != "undefined") clearInterval(Game_Interval);
Game_Interval = setInterval(paint, Speed);
allowPressKeys = true;
$("button#Soundoff").removeAttr('disabled');
$("button#SoundOn").removeAttr('disabled');

}
function pause()
{
clearInterval(Game_Interval);
allowPressKeys = false;
$("button#Soundoff").attr('disabled','disabled');
$("button#SoundOn").attr('disabled','disabled');
}
GameStart();
function Paint_Snake()
{
var length = 3;
SnakeArray = [];
for(var i = length-1; i>=0; i--)
{
SnakeArray.push({x: i, y:0});
}
}

function create_apple()
{
apple = {
x: Math.round(Math.random()*(w-cw)/cw),
y: Math.round(Math.random()*(h-cw)/cw),
};
}

function paint()
{
YourScore="Puaniniz: "+score;
$("p#Score").html(YourScore);
Context.fillStyle = "#262425";
Context.fillRect(0, 0, w, h);
Context.strokeStyle = "#262425";
Context.strokeRect(0, 0, w, h);
var HeadX = SnakeArray[0].x;
var HeadY = SnakeArray[0].y;
if(direction == "right") HeadX++;
else if(direction == "left") HeadX--;
else if(direction == "up") HeadY--;
else if(direction == "down") HeadY++;
if(HeadX == -1 )
{
HeadX=w/cw-1;
}else if (HeadX==w/cw)
{
HeadX=0;
}
if(HeadY == -1)
{
HeadY=h/cw-1;
}
else if (HeadY == h/cw)
{
HeadY=0;
}

if(Ouroboros_Check(HeadX, HeadY, SnakeArray))
{
pause();
GamePlay.pause();
if(GameOver.paused)
GameOver.play();
alert("Oyun bitti - Puaniniz : "+score);
GameStart();
return;
}
if(HeadX == apple.x && HeadY == apple.y)
{
SnakeEating.play();
var tail = {x: HeadX, y: HeadY};
score++;
create_apple();

}
else
{
var tail = SnakeArray.pop();
tail.x = HeadX; tail.y = HeadY;
}
SnakeArray.unshift(tail);
for(var i = 0; i < SnakeArray.length; i++)
{
var c = SnakeArray[i];
Draw_pixel(c.x, c.y);
}
Draw_pixel(apple.x, apple.y);
}

function Draw_pixel(x, y)
{
Context.fillStyle = "#ff4d4d";
Context.fillRect(x*cw, y*cw, cw, cw);
Context.strokeStyle = "#ff4d4d";
Context.strokeRect(x*cw, y*cw, cw, cw);
}

function Ouroboros_Check(x, y, array)
{
for(var i = 0; i < array.length; i++)
{
if(array[i].x == x && array[i].y == y)
return true;
}
return false;
}

$("button#pause").click(function(){
$("button#pause").hide();
GamePlay.pause();
pause();
$("button#play").show();
});

$("button#Soundoff").click(function(){
$("button#Soundoff").hide();
GamePlay.play();
$("button#SoundOn").show();
});

$("button#SoundOn").click(function(){
$("button#SoundOn").hide();
GamePlay.pause();
$("button#Soundoff").show();
});

$("button#play").click(function(){
$("button#play").hide();
play();
GamePlay.play();
$("button#pause").show();
});

//Lets add the keyboard controls now
$(document).keydown(function(e){
if (!allowPressKeys){
return null;
}
var key = e.which;
switch(key)
{
case 37:
if(direction!="right") direction="left";
break;
case 38:
if(direction!="down") direction="up";
break;
case 39:
if(direction!="left") direction="right";
break;
case 40:
if(direction!="up") direction="down";
break;
default:
break;
}
})







})
2 changes: 2 additions & 0 deletions honeycomb/alt.php
@@ -0,0 +1,2 @@
<br>
Honeycomb &copy; 2016-<?php echo date("Y"); ?> - KILCI:XYZ
17 changes: 17 additions & 0 deletions honeycomb/css/genel.css
@@ -0,0 +1,17 @@
/*
Bir Uğur KILCI ürünüdür.
####
# # #### # # ### # # # # ### #
# # # # # # # ## # # # #
# # # # # # ## # # # # # #
### #### ### # # # # # ### ### #
www.ugurklc.blogspot.com
www.youtube.com/dusunenadamugur
www.facebook.com/dusunuveringari
www.twitter.com/ugur2nd
www.linkedin.com/ugur2nd
*/body {font-family:Times New Roman;background-attachment: fixed;background: #ad2d22;font-size: 15px;margin:0;}a:link, a:visited {color: #000;text-decoration: none;text-shadow: 0 0 5px rgba(0,0,0,0.2), 0 2px 2px rgba(0,0,0,0.0);}a:hover, a:active {color: #999;text-decoration: underline;}.text {margin: 25px auto;width: 500px;padding: 4px 4px;}.orta {margin: 200px auto;}.btn {padding: 4px 4px;}button{cursor:pointer;}.str1 {background-color: #fff;}

0 comments on commit afe9af7

Please sign in to comment.