diff --git a/src/Components/Preview/Preview.tsx b/src/Components/Preview/Preview.tsx
index aea7f32..aad3d2c 100644
--- a/src/Components/Preview/Preview.tsx
+++ b/src/Components/Preview/Preview.tsx
@@ -92,14 +92,14 @@ export default function Preview({active}:PrevProps):React.ReactElement {
width: props.width,
height: props.height
})
- setReady(false);
- if(timeout_ref.current !== 0){
- clearTimeout(timeout_ref.current);
- }
- timeout_ref.current = setTimeout(()=>{
- setReady(true);
- addKey(curr => curr + 1);
- },500)
+ // setReady(false);
+ // if(timeout_ref.current !== 0){
+ // clearTimeout(timeout_ref.current);
+ // }
+ // timeout_ref.current = setTimeout(()=>{
+ // setReady(true);
+ // addKey(curr => curr + 1);
+ // },500)
},[width_ref.current])
diff --git a/src/Components/Tracks/updatedTracks.tsx b/src/Components/Tracks/updatedTracks.tsx
index 4a3a4f1..6b84fdd 100644
--- a/src/Components/Tracks/updatedTracks.tsx
+++ b/src/Components/Tracks/updatedTracks.tsx
@@ -64,6 +64,14 @@ const UpdatedTracks = ({width,height,Player,events,options,sound,number_of_white
}
},[events])
+ useEffect(()=>{
+ if(blocks){
+ blocks.handle_resize(width,height,width/number_of_white_keys);
+ console.log('resize')
+ }
+
+ },[width,height]);
+
useEffect(()=>{
if(blocks === undefined && pianoWhite.current && mainCtx.current && pianoBlack.current && gradCtx.current && EffectCtx.current){
const context = mainCtx.current.getContext('2d')
diff --git a/src/Helpers/Blocks/pianoInteraction.ts b/src/Helpers/Blocks/pianoInteraction.ts
index c56b38c..f44c0f9 100644
--- a/src/Helpers/Blocks/pianoInteraction.ts
+++ b/src/Helpers/Blocks/pianoInteraction.ts
@@ -25,6 +25,13 @@ export default class pianoInteraction{
})
}
+ public handle_resize(width:number, height:number):void {
+ this.black_key_height = (height-this.cnavas_offSet) / 1.5 + 5;
+ this.white_key_height = (height-this.cnavas_offSet) + 2;
+ this.width = width;
+ this.height = height;
+ }
+
public render():void {
this.white_ctx.clearRect(0,0,this.width,this.height);
this.black_ctx.clearRect(0,0,this.width,this.height);
diff --git a/src/Helpers/Blocks/updatedBlocks.ts b/src/Helpers/Blocks/updatedBlocks.ts
index 8ac56a9..38e5c7f 100644
--- a/src/Helpers/Blocks/updatedBlocks.ts
+++ b/src/Helpers/Blocks/updatedBlocks.ts
@@ -47,6 +47,15 @@ class Block{
this.pauseTime += time
}
+ /**
+ * Put the block in different x_position
+ * @param pos_x: new x position of the block
+ */
+ public block_alter_x_pos(pos_x: number){
+ //I think the Y does not need to change, only the x position
+ this.pos_x = pos_x;
+ }
+
/**
* Static method to calculate y position of a block if it existed, returns number
* @param speed_y
@@ -122,7 +131,7 @@ class Blocks{
private effect_manager: EffectsManager
private sound_manager:soundManager | undefined
- constructor(canvases: blocks_canvases, private options:OptionsType, private height:number, private width:number, nr_of_keys:number, key_width:number){
+ constructor(canvases: blocks_canvases, private options:OptionsType, private height:number, private width:number, private nr_of_keys:number, private key_width:number){
this.blocks = []
this.notes_to_add = [];
this.ctx = canvases.mainCtx;
@@ -288,6 +297,26 @@ class Blocks{
this.notes_to_add = [];
}
+
+ /**
+ * Method handles the resize of the canvas, it needs to rerender the blocks
+ * @param width
+ * @param height
+ */
+ public handle_resize(width:number,height:number, key_width: number):void {
+ this.key_width = key_width;
+ this.width = width;
+ this.height = height;
+ this.key_positions_map = this.__create_key_position_map(width, this.nr_of_keys, this.key_width);
+ this.height = height - (height / 5);
+ this.key_interactor.handle_resize(width,height / 5);
+ this.effect_manager.handle_resize(width, height - (height / 5));
+ this.positions_to_render_line = this.RenderOctaveLines()
+ this.blocks.forEach(block =>{
+ block.block_alter_x_pos(this.key_positions_map[block.noteNumber].position);
+ })
+ }
+
/**
* Function creates a map of key positions
*/
diff --git a/src/Helpers/Effects/DesignedEffects/Blank.ts b/src/Helpers/Effects/DesignedEffects/Blank.ts
index f5a399e..6aee557 100644
--- a/src/Helpers/Effects/DesignedEffects/Blank.ts
+++ b/src/Helpers/Effects/DesignedEffects/Blank.ts
@@ -18,4 +18,8 @@ export default class Blank extends _Effect{
public update_effect(): void {
}
+
+ public handle_resze(width: number, height: number): void {
+
+ }
}
\ No newline at end of file
diff --git a/src/Helpers/Effects/DesignedEffects/Sparks.ts b/src/Helpers/Effects/DesignedEffects/Sparks.ts
index b55a4eb..a4bc5c0 100644
--- a/src/Helpers/Effects/DesignedEffects/Sparks.ts
+++ b/src/Helpers/Effects/DesignedEffects/Sparks.ts
@@ -57,6 +57,11 @@ class Sparks extends Effect{
this.ctx.closePath()
}
+ public handle_resze(width: number, height: number): void {
+ this.width = width;
+ this.height = height;
+ }
+
public update_effect(): void {
const new_effects:Spark[] = [];
this.sparks.forEach(spark =>{
diff --git a/src/Helpers/Effects/DesignedEffects/Squared.ts b/src/Helpers/Effects/DesignedEffects/Squared.ts
index 907fb60..179a14d 100644
--- a/src/Helpers/Effects/DesignedEffects/Squared.ts
+++ b/src/Helpers/Effects/DesignedEffects/Squared.ts
@@ -75,6 +75,11 @@ class Squared extends Effect{
//Render Effects
}
+ public handle_resze(width: number, height: number): void {
+ this.width = width;
+ this.height = height;
+ }
+
public update_effect(): void {
const new_effects:Array
= [];
this.effects.map(efect =>{
diff --git a/src/Helpers/Effects/EffectsManager.ts b/src/Helpers/Effects/EffectsManager.ts
index 20baf77..5bac777 100644
--- a/src/Helpers/Effects/EffectsManager.ts
+++ b/src/Helpers/Effects/EffectsManager.ts
@@ -11,7 +11,7 @@ import { Options } from '../../Utils/TypesForOptions';
export default class EffectsManager{
private effects:Effect;
- constructor(private ctx:CanvasRenderingContext2D, width:number,private height:number, private key_width:number,effect_type:string, options:Options){
+ constructor(private ctx:CanvasRenderingContext2D, width:number, private height:number, private key_width:number,private effect_type:string,private options:Options){
switch(effect_type){
case 'Sparks':
this.effects = new Sparks(ctx, width, height, 1, 6,);
@@ -28,6 +28,10 @@ export default class EffectsManager{
}
}
+ public handle_resize(width:number, height: number){
+ this.height = height;
+ this.effects.handle_resze(width, height);
+ }
public generate_effect(pos_x:number):void{
this.effects.create_effect(pos_x, this.height, this.key_width);
diff --git a/src/Helpers/Effects/_Effect.ts b/src/Helpers/Effects/_Effect.ts
index 9720170..18ebf20 100644
--- a/src/Helpers/Effects/_Effect.ts
+++ b/src/Helpers/Effects/_Effect.ts
@@ -24,6 +24,11 @@ export default abstract class Effect{
*/
public abstract update_effect():void;
+ /**
+ * Method handles the resize of the screen
+ */
+ public abstract handle_resze(width:number, height:number):void;
+
/**
* Method clears the Canvas
*/
diff --git a/src/Pages/Play/Play.tsx b/src/Pages/Play/Play.tsx
index d202131..7f30781 100644
--- a/src/Pages/Play/Play.tsx
+++ b/src/Pages/Play/Play.tsx
@@ -39,7 +39,10 @@ export default function Play():React.ReactElement{
},[])
const resize_listener = useCallback(()=>{
- window.location.reload()
+ set_width_height({
+ width: window.innerWidth,
+ height: window.innerHeight
+ })
},[]);
const focus_listener = useCallback(()=>{
diff --git a/src/Pages/PlayLive/PlayLive.scss b/src/Pages/PlayLive/PlayLive.scss
new file mode 100644
index 0000000..e69de29
diff --git a/src/Pages/PlayLive/PlayLive.tsx b/src/Pages/PlayLive/PlayLive.tsx
new file mode 100644
index 0000000..4a297f2
--- /dev/null
+++ b/src/Pages/PlayLive/PlayLive.tsx
@@ -0,0 +1,12 @@
+import React from 'react'
+import "./PlayLive.scss"
+
+export default function PlayLive() {
+ return (
+
+
WORK IN PROGRESS
+ IF YOU SEE THIS, YOU HAVE DOWNLOADED PAGE FROM AVANT BRANCH
+ Then please be patient :)
+
+ )
+}
diff --git a/src/Utils/handleOptionsChange.ts b/src/Utils/handleOptionsChange.ts
index c4faacc..ebf7334 100644
--- a/src/Utils/handleOptionsChange.ts
+++ b/src/Utils/handleOptionsChange.ts
@@ -22,9 +22,6 @@ const handleOptionsChange = (event:ChangeEvent | {target:{name
case 'Image':
currentOptions.backgroundImage = event.target.value
break;
- case 'speed':
- currentOptions.speed = parseInt(event.target.value);
- break;
case 'playSpeed':
currentOptions.playSpeed = parseInt(event.target.value);
break;