-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request from UoB-COMSM0166/feature_UiAndDoorLogic_jh_20250228
Add images and door logic; Make boundary detections fit background image
- Loading branch information
Showing
21 changed files
with
181 additions
and
116 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class Door { | ||
constructor(x = rightBoundary, y = heightInPixel / 2 - doorSize.h / 2) { | ||
this.position = createVector(x, y); | ||
this.size = createVector(doorSize.w, doorSize.h); | ||
this.currentDoorImg = closedDoorImg; | ||
} | ||
|
||
display() { | ||
image(this.currentDoorImg, this.position.x, this.position.y, this.size.x, this.size.y); | ||
} | ||
|
||
open() { | ||
if (this.currentDoorImg === openDoorImg) return; | ||
this.currentDoorImg = openDoorImg; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
class Obstacle { | ||
constructor(x, y) { | ||
this.position = createVector(x, y); | ||
this.size = createVector(obstacleSize.w, obstacleSize.h); | ||
this.size = createVector(heightInPixel / 12, heightInPixel / 12); | ||
} | ||
|
||
display() { | ||
fill(100); | ||
rect(this.position.x, this.position.y, this.size.x, this.size.y); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
class Room { | ||
constructor() { | ||
this.savePoint = null; | ||
this.door = null; | ||
this.enemies = []; | ||
this.obstacles = []; | ||
} | ||
|
||
setup() { | ||
this.savePoint = new SavePoint(savePointParam.x, savePointParam.y); | ||
this.door = new Door(); | ||
this.generateObstacles(); | ||
this.generateEnemies(); | ||
startTime = millis(); | ||
} | ||
|
||
update() { | ||
image(officeRoomImg, 0, 0, widthInPixel, heightInPixel); | ||
this.savePoint.display(); | ||
this.updateObstacles(); | ||
this.updateEnemies(); | ||
this.updateDoor(); | ||
this.checkClearCondition(); | ||
} | ||
|
||
generateObstacles() { | ||
this.obstacles = []; | ||
const maxEntitySize = heightInPixel / 8; | ||
for (let i = 0; i < obstacleCount; i++) { | ||
let x = random(leftBoundary, rightBoundary - maxEntitySize); | ||
let y = random(topBoundary, bottomBoundary - maxEntitySize); | ||
this.obstacles.push(new Obstacle(x, y)); | ||
} | ||
} | ||
|
||
generateEnemies() { | ||
this.enemies = []; | ||
const maxEntitySize = heightInPixel / 8; | ||
for (let i = 0; i < enemyCount; i++) { | ||
let x = random(leftBoundary, rightBoundary - maxEntitySize); | ||
let y = random(topBoundary, bottomBoundary - maxEntitySize); | ||
let hp = random([smallEnemyHp, largeEnemyHp]); | ||
this.enemies.push(new Enemy(x, y, hp)); | ||
} | ||
} | ||
|
||
updateObstacles() { | ||
this.obstacles.forEach(o => o.display()); | ||
} | ||
|
||
updateEnemies() { | ||
this.enemies.forEach(e => { | ||
e.update(); | ||
e.display(); | ||
}); | ||
} | ||
|
||
updateDoor() { | ||
if (this.checkClearCondition()) this.door.open(); | ||
this.door.display(); | ||
} | ||
|
||
checkClearCondition() { | ||
return (this.enemies.length === 0 && player.hp > 0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.