Skip to content

Commit

Permalink
BOXES WORKING
Browse files Browse the repository at this point in the history
  • Loading branch information
ZafeerA123 committed Oct 31, 2023
1 parent 8323f2c commit 6f8caec
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions _posts/2023-10-19-Gametest1.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,42 +83,42 @@ document.addEventListener("keyup",myCharacter.handleKeyup.bind(myCharacter));
var showEKeySprite = false;
// Add the "E" key press event listener to handle the interaction with boxObject2
window.addEventListener('keydown', function (e) {
// Check if the pressed key is "E" (key code 69)
if (e.keyCode == 69) {
// Check if the player character is in contact with boxObject2
if (e.keyCode === 69) {
// Check for overlap with boxObject2
if (checkForOverlap(myCharacterObject, boxObject2)) {
// Make boxObject2 disappear
boxObject2.scale = [0, 0];
}
if (!checkForOverlap(myCharacterObject, boxObject2)) {
// Make the E key related to boxObject1 disappear
} else {
// Make the E key related to boxObject2 disappear if no overlap
showEKeySprite = false;
}
// Check if the player character is in contact with boxObject1

// Check for overlap with boxObject1
if (checkForOverlap(myCharacterObject, boxObject1)) {
// Make boxObject1 disappear
boxObject1.scale = [0, 0];
if (!checkForOverlap(myCharacterObject, boxObject1)) {
// Make the E key related to boxObject1 disappear
} else {
// Make the E key related to boxObject1 disappear if no overlap
showEKeySprite = false;
}
if (!checkForOverlap (myCharacterObject, boxstackObject2)) {
//Boxstackobject 1 dissapear
boxstackObject2.scale = [0, 0]
}
if (!checkForOverlap(myCharacterObject, boxstackObject2)) {
// Make the E key related to boxObject1 disappear

// Check for overlap with boxstackObject2
if (checkForOverlap(myCharacterObject, boxstackObject2)) {
// Make boxstackObject2 disappear
boxstackObject2.scale = [0, 0];
} else {
// Make the E key related to boxstackObject2 disappear if no overlap
showEKeySprite = false;
}
if (!checkForOverlap (myCharacterObject, boxstackObject1)) {
//Boxstackobject 1 dissapear
boxstackObject1.scale = [0, 0]
}
if (!checkForOverlap(myCharacterObject, boxstackObject1)) {
// Make the E key related to boxObject1 disappear

// Check for overlap with boxstackObject1
if (checkForOverlap(myCharacterObject, boxstackObject1)) {
// Make boxstackObject1 disappear
boxstackObject1.scale = [0, 0];
} else {
// Make the E key related to boxstackObject1 disappear if no overlap
showEKeySprite = false;
}
}
}
});
//text
Expand Down

0 comments on commit 6f8caec

Please sign in to comment.