You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected behavior
I thought it would call the win() function (which is this:
functionwin(){// create a function that runs when you win$('.win').show();// show the message with JQuery$('.game').hide();// hide the rest of the game};
)
This is were the win() function is called:
classPlayer{// create a player sprite classconstructor(visibility){this.visibility=visibility;setInterval(function(){// repeat this with a interval in betweenif(Math.abs(parseInt($('.player').css('left'))-parseInt($('.enemy').css('left')))<parseInt($('.enemy').width())&&Math.abs(parseInt($('.player').css('top'))-$('.enemy').css('top'))<$('.enemy').height()){// if the player if touching the enemy...game_over();// then call the game_over function}elseif(Math.abs(parseInt($('.player').css('top'))-parseInt($('.treasure').css('top')))<parseInt($('.treasure').height())){// otherwise if the player is touching the treasure...win();// then call the win function};},1000);// do this each second$(document).on('keydown', ...
}}}
I fixed #12 but now the code to make you lose doesn't work too:
classPlayer{// create a player sprite classconstructor(visibility){...
setInterval(function(){// repeat this with a interval in betweenif(Math.abs(parseInt($('.player').css('left'))-parseInt($('.enemy').css('left')))<parseInt($('.enemy').width())&&Math.abs(parseInt($('.player').css('top'))-$('.enemy').css('top'))<$('.enemy').height()){// if the player if touching the enemy...game_over();// then call the game_over function}elseif(Math.abs(parseInt($('.player').css('top'))-parseInt($('.treasure').css('top')))<parseInt($('.treasure').height())){// otherwise if the player is touching the treasure...win();// then call the win function};},1000);// do this each second...
Describe the bug
When you make the player jump to get the treasure the
win()
function isn't called.To Reproduce
Steps to reproduce the behavior:
Expected behavior
I thought it would call the
win()
function (which is this:)
This is were the
win()
function is called:/cc @elijahparker
The text was updated successfully, but these errors were encountered: