Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Touch Screen Arrows and Organized the files #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Added Touch Screen Arrows and Organized the files
Hello, it would be my pleasure actually to add some small changes to your awesome game, thought it will be helpful for all of us

Thanks in advance
  • Loading branch information
HassanDabary committed Apr 9, 2023

Verified

This commit was signed with the committer’s verified signature.
lballabio Luigi Ballabio
commit f7fbec2e3a770489ed046a190bf766c2dff44f09
13 changes: 13 additions & 0 deletions .hintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": [
"development"
],
"hints": {
"axe/text-alternatives": [
"default",
{
"document-title": "off"
}
]
}
}
File renamed without changes
File renamed without changes
File renamed without changes
307 changes: 307 additions & 0 deletions img/debug.log

Large diffs are not rendered by default.

Binary file added img/down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/top.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
103 changes: 92 additions & 11 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<html>

<head>

<script src='Box2dWeb.min.js'></script>
<script src="Three.js"></script>
<script src="keyboard.js"></script>
<script src="jquery.js"></script>
<script src="maze.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" >
<script src='js/Box2dWeb.min.js'></script>
<script src="js/Three.js"></script>
<script src="js/keyboard.js"></script>
<script src="js/jquery.js"></script>
<script src="js/maze.js"></script>

<script>

@@ -23,9 +23,9 @@
ballMesh = undefined,
ballRadius = 0.25,
keyAxis = [0, 0],
ironTexture = THREE.ImageUtils.loadTexture('/ball.png'),
planeTexture = THREE.ImageUtils.loadTexture('/concrete.png'),
brickTexture = THREE.ImageUtils.loadTexture('/brick.png'),
ironTexture = THREE.ImageUtils.loadTexture('img/ball.png'),
planeTexture = THREE.ImageUtils.loadTexture('img/concrete.png'),
brickTexture = THREE.ImageUtils.loadTexture('img/brick.png'),
gameState = undefined,

// Box2D shortcuts
@@ -249,9 +249,46 @@

function onMoveKey(axis) {
keyAxis = axis.slice(0);
console.log(axis);
console.log('here')
}



var timerId;

function pressLeft() {
onMoveKey([-1, 0]);
timerId = setInterval(function () {
onMoveKey([-1, 0]);
}, 15);
}

function pressRight() {
onMoveKey([1, 0]);
timerId = setInterval(function () {
onMoveKey([1, 0]);
}, 15);
}

function pressDown() {
onMoveKey([0, -1]);
timerId = setInterval(function () {
onMoveKey([0, -1]);
}, 15);
}

function pressUp() {
onMoveKey([0, 1]);
timerId = setInterval(function () {
onMoveKey([0, 1]);
}, 15);
}

function releaseKey() {
clearInterval(timerId);
}

jQuery.fn.centerv = function () {
wh = window.innerHeight;
h = this.outerHeight();
@@ -290,9 +327,10 @@
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

// Bind keyboard and resize events.
// Bind keyboard and resize events.
KeyboardJS.bind.axis('left', 'right', 'down', 'up', onMoveKey);
KeyboardJS.bind.axis('h', 'l', 'j', 'k', onMoveKey);

$(window).resize(onResize);


@@ -304,6 +342,8 @@

})





</script>
@@ -343,7 +383,37 @@
color: yellow;
font-weight: bold;
}
#controllers {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: fixed;
bottom: 0;
right: 0;
height: 100px; /* adjust height as needed */
}

#controllers img {
width: 50px;
height: 50px;
margin: 5px;
cursor: pointer;
}

#controllers img:not(:first-child) {
margin-top: 10px;
}

@media only screen and (max-width: 600px) {
#controllers img {
width: 40px;
height: 40px;
margin: 3px;
}
}


</style>

</head>
@@ -365,7 +435,18 @@
<div id='level'>
Level 1
</div>

<div id="controllers" style="position:fixed; bottom:40px; right:20;">
<div class="row">
<img src="/img/top.png" onmousedown="pressUp()" onmouseup="releaseKey()" onmouseout="releaseKey()">
</div>
<div class="row">
<img src="/img/left.png" onmousedown="pressLeft()" onmouseup="releaseKey()" onmouseout="releaseKey()" style="margin-right:20px;">
<img src="/img/right.png" onmousedown="pressRight()" onmouseup="releaseKey()" onmouseout="releaseKey()" style="margin-left:20px;">
</div>
<div class="row">
<img src="/img/down.png" onmousedown="pressDown()" onmouseup="releaseKey()" onmouseout="releaseKey()">
</div>
</div>
</body>

</html>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.