Skip to content

Commit

Permalink
Add an SVG background as the lander
Browse files Browse the repository at this point in the history
  • Loading branch information
ndorfin committed Feb 17, 2024
1 parent a2ccb06 commit 495a90a
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 9 deletions.
7 changes: 5 additions & 2 deletions assets/css/wc/lander-vehicle.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ lander-vehicle {
position: absolute;
inset-block-start: calc(var(--lander_position_y) * 1%);
inset-inline-start: calc(var(--lander_position_x) * 1%);
inline-size: calc(5 * var(--unit_root));
inline-size: calc(2.5 * var(--unit_root));
block-size: calc(5 * var(--unit_root));
background-color: gold;
background-size: contain;
background-image: url('../../img/lander.svg');
background-position: 50% 50%;
background-repeat: no-repeat;
transform-origin: 50% 50%;
transition-property: transform;
transition-duration: 1s;
Expand Down
2 changes: 1 addition & 1 deletion assets/css/wc/vehicle-booster.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ vehicle-booster {
inset-block-start: 99%;
inset-inline-start: 50%;
block-size: calc(var(--booster_length) * var(--unit_root));
inline-size: var(--unit_root);
inline-size: calc(var(--unit_root) / 2);
transform: var(--booster_default_translate) var(--booster_scale_default);
transform-origin: 50% 0%;
background-color: red;
Expand Down
18 changes: 18 additions & 0 deletions assets/img/lander.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions assets/img/rocket.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 1 addition & 6 deletions assets/mjs/wc/game-engine.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ export default class GameEngine extends GameElement {

#gameLoop = function () {
this.#gameDuration++;

// if (this.#gameDuration > 1_000) {
// this.stopGame();
// }
}

startGame() {
Expand All @@ -61,7 +57,7 @@ export default class GameEngine extends GameElement {

stopGame() {
this.#gameEnded = true;
console.log('game ended after duration', this.#gameDuration);
console.log('Game ended after duration', this.#gameDuration);
document.removeEventListener('keyup', this.handleKeyboardInterrupts);
window.clearInterval(this.#gameInterval);
}
Expand All @@ -72,7 +68,6 @@ export default class GameEngine extends GameElement {
}

handleKeyboardInterrupts(event) {
console.log('event.key', event.key);
switch (event.key) {
case 'Enter':
if (this.#gameStarted && !this.#gameRunning) {
Expand Down

0 comments on commit 495a90a

Please sign in to comment.