Simple jumping game: continue with jquery or switch to html5 canvas?












2














I'm coding for fun with the secret ambition of making a fun little game for mobile. So I started out building this little jumping game with Javascript and jQuery.



The game relies heavy on css transformations to do the animations. This way it is not nessecary to do the hard animations work by javascript. I suspect it is also more efficient, but I dont know for sure.



I think it is going ok, but I would love feedback on what should/ could be better/ smarter coded. Also I have this nagging feeling that I should ditch this approach and start over with html5 canvas instead. What are your thoughts?



(The jsfiddle works better: https://jsfiddle.net/hpvl/z7vw03ud/36/ )






 
function makeObstacleRND(){
if (Math.random()>0.7){makeObstacle()}
}

function makeObstacle(){
var el = document.getElementById('world');
var st = window.getComputedStyle(el, null);
var tr = st.getPropertyValue("transform");

var values = tr.split('(')[1];
values = values.split(')')[0];
values = values.split(',');
var a = values[0]*1;
var b = values[1]*-1;
var c = values[2]*-1;
var d = values[3]*1;


//var mymatrix='matrix('+a+','+b+','+c+','+d+', 0, 0)'
//var mymatrix='matrix(1,0,0,1, 0, 0)'
var mymatrix='matrix('+a+','+b+','+c+','+d+',0,0)'
console.log(mymatrix)

$clone = $('#stock .base').clone( true ).css('transform',mymatrix).appendTo("#world") .delay(6000).queue(function() {$(this).remove()})

}

function checkObstacle(element) {
return element.className=='obstacle';
}



function checkCollision(){
$el=$('#player');
var myX=400;
var myY=235;
var myY=$el.position().top + $el.offset().top -50 //this is not working ok yet
$('#sensor').css('top',myY+'px').css('left',myX+'px')
console.log(myY);
myelements=document.elementsFromPoint(myX, myY)
isobstacle=(typeof myelements.find(checkObstacle)!="undefined")

if(isobstacle){
$('#player').css('background-color','red')
}
else{
$('#player').css('background-color','green')
}
}

var checkCollisionInterval=setInterval(checkCollision, 100);
var makeObstacleRNDInterval=setInterval(makeObstacleRND, 600);


$( "body" ).keydown(function(e){
e.stopPropagation();
e.preventDefault();
var $el=$('#player');
if (!$el.hasClass( "jump" )){
$('#player').addClass('jump')
$('#gaia').addClass('bump')
var timeoutforremoveclass=setTimeout(ready2jump, 280);
}
})

function ready2jump(){
$('#player').removeClass('jump')
$('#gaia').removeClass('bump')
}

#world{
background-image: url('https://hyperalbum.com/jump/earth-3228308_19202.png');
background-position: center;
background-repeat: no-repeat;
background-size: cover;

position: absolute;

width: 1000px;
height: 1000px;
animation:spin 10s linear infinite;

}
#gaia{
position: absolute;
top: 240px;
left: -100px;

}


@keyframes spin { 100% { transform:rotate(-360deg); } }


.base{
position: absolute;
top: 0px;
left: 0px;
height: 40px;
margin-top: 480px;
margin-bottom: 480px;
width: 1000px;
display: block;

}

.obstacle {
position: absolute;
top: 0px;
left: 1000px;
display: block;
height: 40px;
width: 40px;
background: blue;
}

#stock {display: none}

#player {
position: absolute;
left: 360px;
top: 140px;
height: 100px;
width: 40px;
background: green;

}

.jump{ animation: jump 0.3s linear 0s normal ;}
.bump{ animation: bump 0.3s linear 0s normal ;}

@keyframes jump {
0%{
transform: translateY(0);
}
10%{
transform: translateY(-140px);
}

100%{
transform: translateY(0px);
}
}

@keyframes bump {
0%{
transform: translateY(0);
}
10%{
transform: translateY(12px);
}

40%{
transform: translateY(0px);
}

80%{
transform: translateY(6px);
}

100%{
transform: translateY(0px);
}
}

#sensor{height: 2px; width:2px; display: block; position: absolute; background-color: orange}

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div id="gaia">
<div id="world">
</div>
</div>

<div id="player" href="#">

</div>


<!--<div id="sensor"></div>-->

<div id="stock">
<div class="base">
<div class="obstacle"></div>
</div>
</div>












share|improve this question









New contributor




Hans Dash is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 2




    The current question title, which states your concerns about the code, applies to too many questions on this site to be useful. The site standard is for the title to simply state the task accomplished by the code. Please see How to Ask for examples, and revise the title accordingly.
    – Mathias Ettinger
    Dec 17 at 15:06
















2














I'm coding for fun with the secret ambition of making a fun little game for mobile. So I started out building this little jumping game with Javascript and jQuery.



The game relies heavy on css transformations to do the animations. This way it is not nessecary to do the hard animations work by javascript. I suspect it is also more efficient, but I dont know for sure.



I think it is going ok, but I would love feedback on what should/ could be better/ smarter coded. Also I have this nagging feeling that I should ditch this approach and start over with html5 canvas instead. What are your thoughts?



(The jsfiddle works better: https://jsfiddle.net/hpvl/z7vw03ud/36/ )






 
function makeObstacleRND(){
if (Math.random()>0.7){makeObstacle()}
}

function makeObstacle(){
var el = document.getElementById('world');
var st = window.getComputedStyle(el, null);
var tr = st.getPropertyValue("transform");

var values = tr.split('(')[1];
values = values.split(')')[0];
values = values.split(',');
var a = values[0]*1;
var b = values[1]*-1;
var c = values[2]*-1;
var d = values[3]*1;


//var mymatrix='matrix('+a+','+b+','+c+','+d+', 0, 0)'
//var mymatrix='matrix(1,0,0,1, 0, 0)'
var mymatrix='matrix('+a+','+b+','+c+','+d+',0,0)'
console.log(mymatrix)

$clone = $('#stock .base').clone( true ).css('transform',mymatrix).appendTo("#world") .delay(6000).queue(function() {$(this).remove()})

}

function checkObstacle(element) {
return element.className=='obstacle';
}



function checkCollision(){
$el=$('#player');
var myX=400;
var myY=235;
var myY=$el.position().top + $el.offset().top -50 //this is not working ok yet
$('#sensor').css('top',myY+'px').css('left',myX+'px')
console.log(myY);
myelements=document.elementsFromPoint(myX, myY)
isobstacle=(typeof myelements.find(checkObstacle)!="undefined")

if(isobstacle){
$('#player').css('background-color','red')
}
else{
$('#player').css('background-color','green')
}
}

var checkCollisionInterval=setInterval(checkCollision, 100);
var makeObstacleRNDInterval=setInterval(makeObstacleRND, 600);


$( "body" ).keydown(function(e){
e.stopPropagation();
e.preventDefault();
var $el=$('#player');
if (!$el.hasClass( "jump" )){
$('#player').addClass('jump')
$('#gaia').addClass('bump')
var timeoutforremoveclass=setTimeout(ready2jump, 280);
}
})

function ready2jump(){
$('#player').removeClass('jump')
$('#gaia').removeClass('bump')
}

#world{
background-image: url('https://hyperalbum.com/jump/earth-3228308_19202.png');
background-position: center;
background-repeat: no-repeat;
background-size: cover;

position: absolute;

width: 1000px;
height: 1000px;
animation:spin 10s linear infinite;

}
#gaia{
position: absolute;
top: 240px;
left: -100px;

}


@keyframes spin { 100% { transform:rotate(-360deg); } }


.base{
position: absolute;
top: 0px;
left: 0px;
height: 40px;
margin-top: 480px;
margin-bottom: 480px;
width: 1000px;
display: block;

}

.obstacle {
position: absolute;
top: 0px;
left: 1000px;
display: block;
height: 40px;
width: 40px;
background: blue;
}

#stock {display: none}

#player {
position: absolute;
left: 360px;
top: 140px;
height: 100px;
width: 40px;
background: green;

}

.jump{ animation: jump 0.3s linear 0s normal ;}
.bump{ animation: bump 0.3s linear 0s normal ;}

@keyframes jump {
0%{
transform: translateY(0);
}
10%{
transform: translateY(-140px);
}

100%{
transform: translateY(0px);
}
}

@keyframes bump {
0%{
transform: translateY(0);
}
10%{
transform: translateY(12px);
}

40%{
transform: translateY(0px);
}

80%{
transform: translateY(6px);
}

100%{
transform: translateY(0px);
}
}

#sensor{height: 2px; width:2px; display: block; position: absolute; background-color: orange}

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div id="gaia">
<div id="world">
</div>
</div>

<div id="player" href="#">

</div>


<!--<div id="sensor"></div>-->

<div id="stock">
<div class="base">
<div class="obstacle"></div>
</div>
</div>












share|improve this question









New contributor




Hans Dash is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 2




    The current question title, which states your concerns about the code, applies to too many questions on this site to be useful. The site standard is for the title to simply state the task accomplished by the code. Please see How to Ask for examples, and revise the title accordingly.
    – Mathias Ettinger
    Dec 17 at 15:06














2












2








2







I'm coding for fun with the secret ambition of making a fun little game for mobile. So I started out building this little jumping game with Javascript and jQuery.



The game relies heavy on css transformations to do the animations. This way it is not nessecary to do the hard animations work by javascript. I suspect it is also more efficient, but I dont know for sure.



I think it is going ok, but I would love feedback on what should/ could be better/ smarter coded. Also I have this nagging feeling that I should ditch this approach and start over with html5 canvas instead. What are your thoughts?



(The jsfiddle works better: https://jsfiddle.net/hpvl/z7vw03ud/36/ )






 
function makeObstacleRND(){
if (Math.random()>0.7){makeObstacle()}
}

function makeObstacle(){
var el = document.getElementById('world');
var st = window.getComputedStyle(el, null);
var tr = st.getPropertyValue("transform");

var values = tr.split('(')[1];
values = values.split(')')[0];
values = values.split(',');
var a = values[0]*1;
var b = values[1]*-1;
var c = values[2]*-1;
var d = values[3]*1;


//var mymatrix='matrix('+a+','+b+','+c+','+d+', 0, 0)'
//var mymatrix='matrix(1,0,0,1, 0, 0)'
var mymatrix='matrix('+a+','+b+','+c+','+d+',0,0)'
console.log(mymatrix)

$clone = $('#stock .base').clone( true ).css('transform',mymatrix).appendTo("#world") .delay(6000).queue(function() {$(this).remove()})

}

function checkObstacle(element) {
return element.className=='obstacle';
}



function checkCollision(){
$el=$('#player');
var myX=400;
var myY=235;
var myY=$el.position().top + $el.offset().top -50 //this is not working ok yet
$('#sensor').css('top',myY+'px').css('left',myX+'px')
console.log(myY);
myelements=document.elementsFromPoint(myX, myY)
isobstacle=(typeof myelements.find(checkObstacle)!="undefined")

if(isobstacle){
$('#player').css('background-color','red')
}
else{
$('#player').css('background-color','green')
}
}

var checkCollisionInterval=setInterval(checkCollision, 100);
var makeObstacleRNDInterval=setInterval(makeObstacleRND, 600);


$( "body" ).keydown(function(e){
e.stopPropagation();
e.preventDefault();
var $el=$('#player');
if (!$el.hasClass( "jump" )){
$('#player').addClass('jump')
$('#gaia').addClass('bump')
var timeoutforremoveclass=setTimeout(ready2jump, 280);
}
})

function ready2jump(){
$('#player').removeClass('jump')
$('#gaia').removeClass('bump')
}

#world{
background-image: url('https://hyperalbum.com/jump/earth-3228308_19202.png');
background-position: center;
background-repeat: no-repeat;
background-size: cover;

position: absolute;

width: 1000px;
height: 1000px;
animation:spin 10s linear infinite;

}
#gaia{
position: absolute;
top: 240px;
left: -100px;

}


@keyframes spin { 100% { transform:rotate(-360deg); } }


.base{
position: absolute;
top: 0px;
left: 0px;
height: 40px;
margin-top: 480px;
margin-bottom: 480px;
width: 1000px;
display: block;

}

.obstacle {
position: absolute;
top: 0px;
left: 1000px;
display: block;
height: 40px;
width: 40px;
background: blue;
}

#stock {display: none}

#player {
position: absolute;
left: 360px;
top: 140px;
height: 100px;
width: 40px;
background: green;

}

.jump{ animation: jump 0.3s linear 0s normal ;}
.bump{ animation: bump 0.3s linear 0s normal ;}

@keyframes jump {
0%{
transform: translateY(0);
}
10%{
transform: translateY(-140px);
}

100%{
transform: translateY(0px);
}
}

@keyframes bump {
0%{
transform: translateY(0);
}
10%{
transform: translateY(12px);
}

40%{
transform: translateY(0px);
}

80%{
transform: translateY(6px);
}

100%{
transform: translateY(0px);
}
}

#sensor{height: 2px; width:2px; display: block; position: absolute; background-color: orange}

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div id="gaia">
<div id="world">
</div>
</div>

<div id="player" href="#">

</div>


<!--<div id="sensor"></div>-->

<div id="stock">
<div class="base">
<div class="obstacle"></div>
</div>
</div>












share|improve this question









New contributor




Hans Dash is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I'm coding for fun with the secret ambition of making a fun little game for mobile. So I started out building this little jumping game with Javascript and jQuery.



The game relies heavy on css transformations to do the animations. This way it is not nessecary to do the hard animations work by javascript. I suspect it is also more efficient, but I dont know for sure.



I think it is going ok, but I would love feedback on what should/ could be better/ smarter coded. Also I have this nagging feeling that I should ditch this approach and start over with html5 canvas instead. What are your thoughts?



(The jsfiddle works better: https://jsfiddle.net/hpvl/z7vw03ud/36/ )






 
function makeObstacleRND(){
if (Math.random()>0.7){makeObstacle()}
}

function makeObstacle(){
var el = document.getElementById('world');
var st = window.getComputedStyle(el, null);
var tr = st.getPropertyValue("transform");

var values = tr.split('(')[1];
values = values.split(')')[0];
values = values.split(',');
var a = values[0]*1;
var b = values[1]*-1;
var c = values[2]*-1;
var d = values[3]*1;


//var mymatrix='matrix('+a+','+b+','+c+','+d+', 0, 0)'
//var mymatrix='matrix(1,0,0,1, 0, 0)'
var mymatrix='matrix('+a+','+b+','+c+','+d+',0,0)'
console.log(mymatrix)

$clone = $('#stock .base').clone( true ).css('transform',mymatrix).appendTo("#world") .delay(6000).queue(function() {$(this).remove()})

}

function checkObstacle(element) {
return element.className=='obstacle';
}



function checkCollision(){
$el=$('#player');
var myX=400;
var myY=235;
var myY=$el.position().top + $el.offset().top -50 //this is not working ok yet
$('#sensor').css('top',myY+'px').css('left',myX+'px')
console.log(myY);
myelements=document.elementsFromPoint(myX, myY)
isobstacle=(typeof myelements.find(checkObstacle)!="undefined")

if(isobstacle){
$('#player').css('background-color','red')
}
else{
$('#player').css('background-color','green')
}
}

var checkCollisionInterval=setInterval(checkCollision, 100);
var makeObstacleRNDInterval=setInterval(makeObstacleRND, 600);


$( "body" ).keydown(function(e){
e.stopPropagation();
e.preventDefault();
var $el=$('#player');
if (!$el.hasClass( "jump" )){
$('#player').addClass('jump')
$('#gaia').addClass('bump')
var timeoutforremoveclass=setTimeout(ready2jump, 280);
}
})

function ready2jump(){
$('#player').removeClass('jump')
$('#gaia').removeClass('bump')
}

#world{
background-image: url('https://hyperalbum.com/jump/earth-3228308_19202.png');
background-position: center;
background-repeat: no-repeat;
background-size: cover;

position: absolute;

width: 1000px;
height: 1000px;
animation:spin 10s linear infinite;

}
#gaia{
position: absolute;
top: 240px;
left: -100px;

}


@keyframes spin { 100% { transform:rotate(-360deg); } }


.base{
position: absolute;
top: 0px;
left: 0px;
height: 40px;
margin-top: 480px;
margin-bottom: 480px;
width: 1000px;
display: block;

}

.obstacle {
position: absolute;
top: 0px;
left: 1000px;
display: block;
height: 40px;
width: 40px;
background: blue;
}

#stock {display: none}

#player {
position: absolute;
left: 360px;
top: 140px;
height: 100px;
width: 40px;
background: green;

}

.jump{ animation: jump 0.3s linear 0s normal ;}
.bump{ animation: bump 0.3s linear 0s normal ;}

@keyframes jump {
0%{
transform: translateY(0);
}
10%{
transform: translateY(-140px);
}

100%{
transform: translateY(0px);
}
}

@keyframes bump {
0%{
transform: translateY(0);
}
10%{
transform: translateY(12px);
}

40%{
transform: translateY(0px);
}

80%{
transform: translateY(6px);
}

100%{
transform: translateY(0px);
}
}

#sensor{height: 2px; width:2px; display: block; position: absolute; background-color: orange}

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div id="gaia">
<div id="world">
</div>
</div>

<div id="player" href="#">

</div>


<!--<div id="sensor"></div>-->

<div id="stock">
<div class="base">
<div class="obstacle"></div>
</div>
</div>








 
function makeObstacleRND(){
if (Math.random()>0.7){makeObstacle()}
}

function makeObstacle(){
var el = document.getElementById('world');
var st = window.getComputedStyle(el, null);
var tr = st.getPropertyValue("transform");

var values = tr.split('(')[1];
values = values.split(')')[0];
values = values.split(',');
var a = values[0]*1;
var b = values[1]*-1;
var c = values[2]*-1;
var d = values[3]*1;


//var mymatrix='matrix('+a+','+b+','+c+','+d+', 0, 0)'
//var mymatrix='matrix(1,0,0,1, 0, 0)'
var mymatrix='matrix('+a+','+b+','+c+','+d+',0,0)'
console.log(mymatrix)

$clone = $('#stock .base').clone( true ).css('transform',mymatrix).appendTo("#world") .delay(6000).queue(function() {$(this).remove()})

}

function checkObstacle(element) {
return element.className=='obstacle';
}



function checkCollision(){
$el=$('#player');
var myX=400;
var myY=235;
var myY=$el.position().top + $el.offset().top -50 //this is not working ok yet
$('#sensor').css('top',myY+'px').css('left',myX+'px')
console.log(myY);
myelements=document.elementsFromPoint(myX, myY)
isobstacle=(typeof myelements.find(checkObstacle)!="undefined")

if(isobstacle){
$('#player').css('background-color','red')
}
else{
$('#player').css('background-color','green')
}
}

var checkCollisionInterval=setInterval(checkCollision, 100);
var makeObstacleRNDInterval=setInterval(makeObstacleRND, 600);


$( "body" ).keydown(function(e){
e.stopPropagation();
e.preventDefault();
var $el=$('#player');
if (!$el.hasClass( "jump" )){
$('#player').addClass('jump')
$('#gaia').addClass('bump')
var timeoutforremoveclass=setTimeout(ready2jump, 280);
}
})

function ready2jump(){
$('#player').removeClass('jump')
$('#gaia').removeClass('bump')
}

#world{
background-image: url('https://hyperalbum.com/jump/earth-3228308_19202.png');
background-position: center;
background-repeat: no-repeat;
background-size: cover;

position: absolute;

width: 1000px;
height: 1000px;
animation:spin 10s linear infinite;

}
#gaia{
position: absolute;
top: 240px;
left: -100px;

}


@keyframes spin { 100% { transform:rotate(-360deg); } }


.base{
position: absolute;
top: 0px;
left: 0px;
height: 40px;
margin-top: 480px;
margin-bottom: 480px;
width: 1000px;
display: block;

}

.obstacle {
position: absolute;
top: 0px;
left: 1000px;
display: block;
height: 40px;
width: 40px;
background: blue;
}

#stock {display: none}

#player {
position: absolute;
left: 360px;
top: 140px;
height: 100px;
width: 40px;
background: green;

}

.jump{ animation: jump 0.3s linear 0s normal ;}
.bump{ animation: bump 0.3s linear 0s normal ;}

@keyframes jump {
0%{
transform: translateY(0);
}
10%{
transform: translateY(-140px);
}

100%{
transform: translateY(0px);
}
}

@keyframes bump {
0%{
transform: translateY(0);
}
10%{
transform: translateY(12px);
}

40%{
transform: translateY(0px);
}

80%{
transform: translateY(6px);
}

100%{
transform: translateY(0px);
}
}

#sensor{height: 2px; width:2px; display: block; position: absolute; background-color: orange}

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div id="gaia">
<div id="world">
</div>
</div>

<div id="player" href="#">

</div>


<!--<div id="sensor"></div>-->

<div id="stock">
<div class="base">
<div class="obstacle"></div>
</div>
</div>





 
function makeObstacleRND(){
if (Math.random()>0.7){makeObstacle()}
}

function makeObstacle(){
var el = document.getElementById('world');
var st = window.getComputedStyle(el, null);
var tr = st.getPropertyValue("transform");

var values = tr.split('(')[1];
values = values.split(')')[0];
values = values.split(',');
var a = values[0]*1;
var b = values[1]*-1;
var c = values[2]*-1;
var d = values[3]*1;


//var mymatrix='matrix('+a+','+b+','+c+','+d+', 0, 0)'
//var mymatrix='matrix(1,0,0,1, 0, 0)'
var mymatrix='matrix('+a+','+b+','+c+','+d+',0,0)'
console.log(mymatrix)

$clone = $('#stock .base').clone( true ).css('transform',mymatrix).appendTo("#world") .delay(6000).queue(function() {$(this).remove()})

}

function checkObstacle(element) {
return element.className=='obstacle';
}



function checkCollision(){
$el=$('#player');
var myX=400;
var myY=235;
var myY=$el.position().top + $el.offset().top -50 //this is not working ok yet
$('#sensor').css('top',myY+'px').css('left',myX+'px')
console.log(myY);
myelements=document.elementsFromPoint(myX, myY)
isobstacle=(typeof myelements.find(checkObstacle)!="undefined")

if(isobstacle){
$('#player').css('background-color','red')
}
else{
$('#player').css('background-color','green')
}
}

var checkCollisionInterval=setInterval(checkCollision, 100);
var makeObstacleRNDInterval=setInterval(makeObstacleRND, 600);


$( "body" ).keydown(function(e){
e.stopPropagation();
e.preventDefault();
var $el=$('#player');
if (!$el.hasClass( "jump" )){
$('#player').addClass('jump')
$('#gaia').addClass('bump')
var timeoutforremoveclass=setTimeout(ready2jump, 280);
}
})

function ready2jump(){
$('#player').removeClass('jump')
$('#gaia').removeClass('bump')
}

#world{
background-image: url('https://hyperalbum.com/jump/earth-3228308_19202.png');
background-position: center;
background-repeat: no-repeat;
background-size: cover;

position: absolute;

width: 1000px;
height: 1000px;
animation:spin 10s linear infinite;

}
#gaia{
position: absolute;
top: 240px;
left: -100px;

}


@keyframes spin { 100% { transform:rotate(-360deg); } }


.base{
position: absolute;
top: 0px;
left: 0px;
height: 40px;
margin-top: 480px;
margin-bottom: 480px;
width: 1000px;
display: block;

}

.obstacle {
position: absolute;
top: 0px;
left: 1000px;
display: block;
height: 40px;
width: 40px;
background: blue;
}

#stock {display: none}

#player {
position: absolute;
left: 360px;
top: 140px;
height: 100px;
width: 40px;
background: green;

}

.jump{ animation: jump 0.3s linear 0s normal ;}
.bump{ animation: bump 0.3s linear 0s normal ;}

@keyframes jump {
0%{
transform: translateY(0);
}
10%{
transform: translateY(-140px);
}

100%{
transform: translateY(0px);
}
}

@keyframes bump {
0%{
transform: translateY(0);
}
10%{
transform: translateY(12px);
}

40%{
transform: translateY(0px);
}

80%{
transform: translateY(6px);
}

100%{
transform: translateY(0px);
}
}

#sensor{height: 2px; width:2px; display: block; position: absolute; background-color: orange}

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div id="gaia">
<div id="world">
</div>
</div>

<div id="player" href="#">

</div>


<!--<div id="sensor"></div>-->

<div id="stock">
<div class="base">
<div class="obstacle"></div>
</div>
</div>






javascript jquery html5 canvas cordova






share|improve this question









New contributor




Hans Dash is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Hans Dash is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Dec 17 at 15:26





















New contributor




Hans Dash is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Dec 17 at 14:53









Hans Dash

1143




1143




New contributor




Hans Dash is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Hans Dash is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Hans Dash is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 2




    The current question title, which states your concerns about the code, applies to too many questions on this site to be useful. The site standard is for the title to simply state the task accomplished by the code. Please see How to Ask for examples, and revise the title accordingly.
    – Mathias Ettinger
    Dec 17 at 15:06














  • 2




    The current question title, which states your concerns about the code, applies to too many questions on this site to be useful. The site standard is for the title to simply state the task accomplished by the code. Please see How to Ask for examples, and revise the title accordingly.
    – Mathias Ettinger
    Dec 17 at 15:06








2




2




The current question title, which states your concerns about the code, applies to too many questions on this site to be useful. The site standard is for the title to simply state the task accomplished by the code. Please see How to Ask for examples, and revise the title accordingly.
– Mathias Ettinger
Dec 17 at 15:06




The current question title, which states your concerns about the code, applies to too many questions on this site to be useful. The site standard is for the title to simply state the task accomplished by the code. Please see How to Ask for examples, and revise the title accordingly.
– Mathias Ettinger
Dec 17 at 15:06















active

oldest

votes











Your Answer





StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
});
});
}, "mathjax-editing");

StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "196"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






Hans Dash is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f209834%2fsimple-jumping-game-continue-with-jquery-or-switch-to-html5-canvas%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes








Hans Dash is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















Hans Dash is a new contributor. Be nice, and check out our Code of Conduct.













Hans Dash is a new contributor. Be nice, and check out our Code of Conduct.












Hans Dash is a new contributor. Be nice, and check out our Code of Conduct.
















Thanks for contributing an answer to Code Review Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f209834%2fsimple-jumping-game-continue-with-jquery-or-switch-to-html5-canvas%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Список кардиналов, возведённых папой римским Каликстом III

Deduzione

Mysql.sock missing - “Can't connect to local MySQL server through socket”