Skip to content

Commit

Permalink
12345
Browse files Browse the repository at this point in the history
  • Loading branch information
ZafeerA123 committed Oct 31, 2023
1 parent 10727a6 commit 8e42bf3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 27 deletions.
28 changes: 25 additions & 3 deletions _posts/2023-10-19-Gametest1.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,22 @@ document.addEventListener("keyup",myCharacter.handleKeyup.bind(myCharacter));
// Make the E key related to boxObject1 disappear
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
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
showEKeySprite = false;
}
}
}
});
Expand Down Expand Up @@ -211,8 +227,14 @@ function frame(){ //when a frame is updated
console.log("Now press the E key");
showEKeySprite = true;
}


if (checkForOverlap(myCharacterObject, boxstackObject2)) {
console.log("Now press the E key");
showEKeySprite = true;
}
if (checkForOverlap(myCharacterObject, boxstackObject1)) {
console.log("Now press the E key");
showEKeySprite = true;
}

display.draw(1); //type 1 = with camera offset, type 2 = without camera offset

Expand Down Expand Up @@ -242,4 +264,4 @@ window.addEventListener('keydown', function(e) { //prevent space from moving scr
});

frame();
</script>
</script>
25 changes: 1 addition & 24 deletions _posts/2023-10-26-MiniGametest4.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ var characterYSpeed = 0; // Vertical speed of the character
var characterSpriteSheet = new Image();
characterSpriteSheet.src = "/Group/images/Game/walking-sprite.png";
var myCharacterObject = new Object("character", characterSpriteSheet,[44,54],[100,133],[0,500],5,1);
//main character death
var deathSpriteSheet = new Image();
deathSpriteSheet.src = "/Group/images/Game/deathsprite.png";
var deathObject = new Object("death", deathSpriteSheet, [24,54],[54,133],[0,1500],23,1);
var showdeathObject = false;

//potato monster
var monsterSpriteSheet = new Image();
Expand Down Expand Up @@ -91,7 +86,7 @@ var characterYSpeed = 0; // Vertical speed of the character

//text

var display = new subDisplay(canvas,[windowObject1,windowObject2,windowObject3,windowObject4,windowObject5,backgroundObject,elevatorObject,myCharacterObject,deathObject,monsterObject]);
var display = new subDisplay(canvas,[windowObject1,windowObject2,windowObject3,windowObject4,windowObject5,backgroundObject,elevatorObject,myCharacterObject,monsterObject]);

var fps = 22;
var active = true;
Expand Down Expand Up @@ -235,32 +230,14 @@ function frame(){ //when a frame is updated
}
if (checkForOverlap(myCharacterObject, monsterObject) || checkForOverlap(myCharacterObject, monsterObject)) {
console.log("test");
showdeathObject = true;
}

//console.log("fired")

display.draw(1); //type 1 = with camera offset, type 2 = without camera offset

// Draw the character or death sprite based on isCharacterAlive
if (isCharacterAlive) {
display.draw(1); // Draw the character if it's alive
} else {
// Draw the "deathsprite.png" in the character's position
var characterPosition = myCharacterObject.ReturnPosition();
deathObject.OverridePosition(characterPosition);
deathObject.UpdateFrame();
display.draw(1); // Draw the death sprite
}

canvas.getContext("2d").drawImage(hiddenCanvas,0,0); //draw shadows overtop

// Drawing the death sprite
if (showdeathObject) {
if (currentFrame % Math.round(fps/2)==0){
deathObject.UpdateFrame()
}
}
//run function again
setTimeout(function() {
if(active==true){
Expand Down

0 comments on commit 8e42bf3

Please sign in to comment.