Skip to content

Commit

Permalink
🐛 Fix bleeding edge on pet
Browse files Browse the repository at this point in the history
Change log:
 - Fix bleeding edge on pet
 - Change fps to 30
 - Limit scale min 0.1 max 1
  • Loading branch information
SeakMengs committed Oct 8, 2023
1 parent 773004f commit 434eeef
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src-tauri/src/app/default/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"language": "en",
"allowPetAboveTaskbar": false,
"allowPetInteraction": true,
"allowOverridePetScale": true,
"allowAutoStartUp": false,
"petScale": 1
"allowOverridePetScale": true,
"petScale": 0.7
}
6 changes: 4 additions & 2 deletions src/PhaserWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ function PhaserWrapper() {
appWindow.setIgnoreCursorEvents(true);

const phaserConfig: Phaser.Types.Core.GameConfig = {
type: Phaser.CANVAS,
type: Phaser.AUTO,
parent: phaserDom.current,
backgroundColor: '#ffffff0',
transparent: true,
roundPixels: true,
antialias: true,
scale: {
mode: Phaser.Scale.ScaleModes.RESIZE,
width: screenWidth,
Expand All @@ -45,7 +47,7 @@ function PhaserWrapper() {
},
},
fps: {
target: 144,
target: 30,
min: 30,
smoothStep: true,
},
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useSettingStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const useSettingStore = create<ISettingStoreState>()((set) => ({
setAllowOverridePetScale: (newBoolean) => {
set({allowOverridePetScale: newBoolean})
},
petScale: defaultSettings.petScale ?? 1,
petScale: defaultSettings.petScale ?? 0.7,
setPetScale: (petScale) => {
set({petScale: petScale})
},
Expand Down
5 changes: 3 additions & 2 deletions src/scenes/Pets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ export default class Pets extends Phaser.Scene {
case DispatchType.OverridePetScale:
this.allowOverridePetScale = event.payload.value as boolean;
this.allowOverridePetScale ?
this.scaleAllPets(this.petScale) : this.scaleAllPets(1);
this.scaleAllPets(this.petScale) :
this.scaleAllPets(defaultSettings.petScale);
break;
case DispatchType.ChangePetScale:
this.petScale = event.payload.value as number;
Expand Down Expand Up @@ -434,7 +435,7 @@ export default class Pets extends Phaser.Scene {

scalePet(pet: IPet, scaleValue: number): void {
const scaleX = pet.scaleX > 0 ? scaleValue : -scaleValue;
const scaleY = scaleValue > 0 ? scaleValue : -scaleValue;
const scaleY = pet.scaleY > 0 ? scaleValue : -scaleValue;
pet.setScale(scaleX, scaleY);
}

Expand Down
4 changes: 3 additions & 1 deletion src/ui/components/PhaserCanvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ function PhaserCanvas({ pet, playState }: PhaserCanvasProps) {
type: Phaser.CANVAS,
parent: phaserDom.current,
transparent: true,
roundPixels: true,
antialias: true,
scale: {
// mode: Phaser.Scale.ScaleModes.RESIZE,
width: CanvasSize,
Expand All @@ -26,7 +28,7 @@ function PhaserCanvas({ pet, playState }: PhaserCanvasProps) {
},
},
fps: {
target: 144,
target: 30,
min: 30,
smoothStep: true,
},
Expand Down
2 changes: 1 addition & 1 deletion src/ui/setting_tabs/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function Settings() {
checked: allowOverridePetScale,
dispatchType: DispatchType.OverridePetScale,
component: allowOverridePetScale &&
<Slider min={0.1} max={2} defaultValue={petScale} my={"md"} step={0.1} onChangeEnd={(value) => handleSettingChange(DispatchType.ChangePetScale, value)} />,
<Slider min={0.1} max={1} defaultValue={petScale} my={"sm"} step={0.1} onChangeEnd={(value) => handleSettingChange(DispatchType.ChangePetScale, value)} />,
}
];

Expand Down

0 comments on commit 434eeef

Please sign in to comment.