Commit 911c8e04 authored by Davide Volta's avatar Davide Volta
Browse files

Now project10 works again

parent caa9654c
Pipeline #6384 skipped with stage
class FallManager
{
maxheight;
constructor (maxheight)
{
console.log("L'alterzza massima è " + maxheight);
this.maxheight = maxheight;
window.maxheight = maxheight;
}
class FallManager {
maxheight
tick()
{
this.setFallable();
this.fall();
constructor(maxheight) {
console.log('L\'alterzza massima è ' + maxheight)
this.maxheight = maxheight
window.maxheight = maxheight
}
fall()
{
let fallables = document.querySelectorAll(".fallable")
console.log(fallables);
for (let i = 0; i<fallables.length; i++)
{
var currentY = fallables[i].style.top.replace('px', '');
if (currentY<=this.maxheight) {
currentY = ++currentY +1;
fallables[i].style.top = currentY + 'px'
tick() {
this.setFallable()
this.fall()
}
fall() {
let fallables = document.querySelectorAll('.fallable')
console.log(fallables)
for (let i = 0; i < fallables.length; i++) {
var currentY = fallables[i].style.top.replace('px', '')
if (currentY <= this.maxheight) {
currentY = ++currentY + 1
fallables[i].style.top = currentY + 'px'
}
}
}
setFallable()
{
let usables = document.querySelectorAll(".real-usable");
for (let i =0; i<usables.length; i++) {
let random = Math.floor((Math.random() * 100) + 1);
if (random ==1 && !usables[i].classList.contains("fallable")) {
let _x = usables[i].getBoundingClientRect()["x"];
let _y = usables[i].getBoundingClientRect()["y"];
if (!usables[i].classList)
{
usables[i].classList = [];
}
usables[i].classList.add('fallable');
usables[i].style.top = _y + 'px';
usables[i].style.left = _x + 'px';
setFallable() {
let usables = document.querySelectorAll('.real-usable')
for (let i = 0; i < usables.length; i++) {
let random = Math.floor((Math.random() * 100) + 1)
if (random == 1 && !usables[i].classList.contains('fallable')) {
let _x = usables[i].getBoundingClientRect()['x']
let _y = usables[i].getBoundingClientRect()['y']
if (!usables[i].classList) {
usables[i].classList = []
}
usables[i].classList.add('fallable')
usables[i].style.top = _y + 'px'
usables[i].style.left = _x + 'px'
}
}
}
}
}
export default FallManager;
\ No newline at end of file
export default FallManager
\ No newline at end of file
......@@ -8,12 +8,9 @@ import bgmusic from './assets/bgmusic.mp3'
import shootSFX from './assets/shootSFX.mp3'
import PageParser from './PageParser'
import Ticker from './Ticker'
<<<<<<< HEAD
import FallManager from './FallManager';
=======
import {base64ToArrayBuffer} from './Utils'
import Multiplayer from './Multiplayer'
>>>>>>> c8d1f38460767211551f6ca83702b42a770ae056
class Game {
......@@ -27,12 +24,8 @@ class Game {
homeFinder = null
pageParser = null
ticker = null
<<<<<<< HEAD
fallmanager = null;
=======
multiplayer = null
>>>>>>> c8d1f38460767211551f6ca83702b42a770ae056
bgmusic = null
audioCtx = null
source = null
......@@ -66,7 +59,7 @@ class Game {
}
}*/
this.fallmanager = new FallManager(document.documentElement.scrollHeight);
//this.fallmanager = new FallManager(document.documentElement.scrollHeight);
this.homeFinder = new HomeFinder()
this.goal = this.homeFinder.selectGoal(true)
const oldOnclick = this.goal.onclick
......@@ -103,7 +96,7 @@ class Game {
this.ticker.add(this.gameFinishChecker)
this.ticker.add(this.UIManager)
this.UIManager.startTimer()
this.ticker.add(this.fallmanager)
//this.ticker.add(this.fallmanager)
}, this.delayBeforeStart)
this.playSound(this.bgmusic)
......
<<<<<<< HEAD
import { styles } from "ansi-colors";
=======
import Enemy from './Enemy'
>>>>>>> c8d1f38460767211551f6ca83702b42a770ae056
class PageParser {
......
......@@ -27,5 +27,4 @@
50% {
opacity: 0;
}
>>>>>>> c8d1f38460767211551f6ca83702b42a770ae056
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment