@@ -210,80 +210,76 @@ function App() {
210210 } , 1000 ) ;
211211 } , [ ] ) ;
212212
213- const sliceBomb = useCallback (
214- async ( bombId : number ) => {
215- if ( ! wallet || ! wallet . address ) return ;
216- try {
217- await window . bombMutex . acquire ( ) ;
218- const bomb = bombs . find ( ( b ) => b . id === bombId ) ;
219- if ( ! bomb || bomb . sliced || window . slicedBombs . has ( bombId ) ) return ;
220-
221- // Vibrate for 200ms when slicing a bomb (longer vibration for bombs)
222- if ( "vibrate" in navigator ) {
223- navigator . vibrate ( [ 1000 ] ) ;
224- }
213+ const sliceBomb = async ( bombId : number ) => {
214+ if ( ! wallet || ! wallet . address ) return ;
215+ try {
216+ await window . bombMutex . acquire ( ) ;
217+ const bomb = bombs . find ( ( b ) => b . id === bombId ) ;
218+ if ( ! bomb || bomb . sliced || window . slicedBombs . has ( bombId ) ) return ;
219+
220+ // Vibrate for 200ms when slicing a bomb (longer vibration for bombs)
221+ if ( "vibrate" in navigator ) {
222+ navigator . vibrate ( [ 1000 ] ) ;
223+ }
225224
226- // Play bomb sound
227- const bombAudio = new Audio ( bombSound ) ;
228- bombAudio . play ( ) ;
225+ // Play bomb sound
226+ const bombAudio = new Audio ( bombSound ) ;
227+ bombAudio . play ( ) ;
229228
230- // Create explosion effect instead of juice effect
231- createExplosionEffect ( bomb . x , bomb . y ) ;
229+ // Create explosion effect instead of juice effect
230+ createExplosionEffect ( bomb . x , bomb . y ) ;
232231
233- // Apply cumulative penalty
234- const newPenalty = bombPenalty + 10 ;
235- setBombPenalty ( newPenalty ) ;
236- localStorage . setItem ( "bombPenalty" , newPenalty . toString ( ) ) ;
232+ // Apply cumulative penalty
233+ const newPenalty = bombPenalty + 10 ;
234+ setBombPenalty ( newPenalty ) ;
235+ localStorage . setItem ( "bombPenalty" , newPenalty . toString ( ) ) ;
237236
238- // Trigger score shake animation
239- setIsScoreShaking ( true ) ;
240- setTimeout ( ( ) => setIsScoreShaking ( false ) , 500 ) ;
237+ // Trigger score shake animation
238+ setIsScoreShaking ( true ) ;
239+ setTimeout ( ( ) => setIsScoreShaking ( false ) , 500 ) ;
241240
242- setBombs ( ( prev ) => prev . map ( ( b ) => ( b . id === bombId ? { ...b , sliced : true } : b ) ) ) ;
241+ setBombs ( ( prev ) => prev . map ( ( b ) => ( b . id === bombId ? { ...b , sliced : true } : b ) ) ) ;
243242
244- window . slicedBombs . add ( bombId ) ;
245- } finally {
246- window . bombMutex . release ( ) ;
247- }
248- } ,
249- [ bombs , bombPenalty , createExplosionEffect ]
250- ) ;
243+ window . slicedBombs . add ( bombId ) ;
244+ } finally {
245+ window . bombMutex . release ( ) ;
246+ }
247+ } ;
251248
252- const sliceOrange = useCallback (
253- async ( orangeId : number ) => {
254- if ( ! wallet || ! wallet . address ) return ;
255- try {
256- await window . orangeMutex . acquire ( ) ;
257- const orange = oranges . find ( ( o ) => o . id === orangeId ) ;
258- if ( ! orange || orange . sliced || window . slicedOranges . has ( orangeId ) ) return ;
259-
260- // Vibrate for 50ms when slicing an orange
261- if ( "vibrate" in navigator ) {
262- navigator . vibrate ( 150 ) ;
263- }
249+ const sliceOrange = async ( orangeId : number ) => {
250+ if ( ! wallet || ! wallet . address ) return ;
251+ try {
252+ await window . orangeMutex . acquire ( ) ;
253+ const orange = oranges . find ( ( o ) => o . id === orangeId ) ;
254+ if ( ! orange || orange . sliced || window . slicedOranges . has ( orangeId ) ) return ;
264255
265- // Play random slice sound
266- const sliceSounds = [ slice1 , slice2 , slice3 ] ;
267- const randomSound = sliceSounds [ Math . floor ( Math . random ( ) * sliceSounds . length ) ] ;
268- const audio = new Audio ( randomSound ) ;
269- audio . play ( ) ;
270-
271- // Créer l'effet de jus
272- createJuiceEffect ( orange . x , orange . y ) ;
273-
274- // Only send blob tx if no bomb penalty is active
275- if ( bombPenalty === 0 ) {
276- // Send blob tx
277- const blobTransfer = transfer ( "faucet" , wallet . address , "oranj" , BigInt ( 1 ) , 1 ) ;
278- const blobClick = blob_click ( 0 ) ;
279-
280- const identity = `${ wallet . address } @${ blobClick . contract_name } ` ;
281- const blobTx : BlobTransaction = {
282- identity,
283- blobs : [ blobTransfer , blobClick ] ,
284- } ;
285- const txHash = await nodeService . sendBlobTx ( blobTx ) ;
256+ // Vibrate for 50ms when slicing an orange
257+ if ( "vibrate" in navigator ) {
258+ navigator . vibrate ( 150 ) ;
259+ }
286260
261+ // Play random slice sound
262+ const sliceSound = [ slice1 , slice2 , slice3 ] ;
263+ const audio = new Audio ( sliceSound [ Math . floor ( Math . random ( ) * sliceSound . length ) ] ) ;
264+ // Reset audio if already playing
265+ audio . currentTime = 0 ;
266+ audio . play ( ) ;
267+
268+ // Créer l'effet de jus
269+ createJuiceEffect ( orange . x , orange . y ) ;
270+
271+ // Only send blob tx if no bomb penalty is active
272+ if ( bombPenalty === 0 ) {
273+ // Send blob tx
274+ const blobTransfer = transfer ( "faucet" , wallet . address , "oranj" , BigInt ( 1 ) , 1 ) ;
275+ const blobClick = blob_click ( 0 ) ;
276+
277+ const identity = `${ wallet . address } @${ blobClick . contract_name } ` ;
278+ const blobTx : BlobTransaction = {
279+ identity,
280+ blobs : [ blobTransfer , blobClick ] ,
281+ } ;
282+ nodeService . sendBlobTx ( blobTx ) . then ( ( txHash ) => {
287283 // Add transaction to the list
288284 setTransactions ( ( prev ) =>
289285 [
@@ -294,24 +290,23 @@ function App() {
294290 ...prev ,
295291 ] . slice ( 0 , 10 )
296292 ) ; // Keep only the last 10 transactions
293+ } ) ;
297294
298- setCount ( ( c ) => c + 1 ) ;
299- } else {
300- // Reduce bomb penalty
301- const newPenalty = bombPenalty - 1 ;
302- setBombPenalty ( newPenalty ) ;
303- localStorage . setItem ( "bombPenalty" , newPenalty . toString ( ) ) ;
304- }
295+ setCount ( ( c ) => c + 1 ) ;
296+ } else {
297+ // Reduce bomb penalty
298+ const newPenalty = bombPenalty - 1 ;
299+ setBombPenalty ( newPenalty ) ;
300+ localStorage . setItem ( "bombPenalty" , newPenalty . toString ( ) ) ;
301+ }
305302
306- setOranges ( ( prev ) => prev . map ( ( o ) => ( o . id === orangeId ? { ...o , sliced : true } : o ) ) ) ;
303+ setOranges ( ( prev ) => prev . map ( ( o ) => ( o . id === orangeId ? { ...o , sliced : true } : o ) ) ) ;
307304
308- window . slicedOranges . add ( orangeId ) ;
309- } finally {
310- window . orangeMutex . release ( ) ;
311- }
312- } ,
313- [ oranges , bombPenalty , wallet ?. address ]
314- ) ;
305+ window . slicedOranges . add ( orangeId ) ;
306+ } finally {
307+ window . orangeMutex . release ( ) ;
308+ }
309+ } ;
315310
316311 const createSliceEffect = useCallback ( ( points : { x : number ; y : number } [ ] ) => {
317312 if ( ! gameAreaRef . current || points . length < 2 ) return ;
@@ -778,10 +773,8 @@ function App() {
778773 className = { `orange ${ orange . sliced ? "sliced" : "" } ` }
779774 style = {
780775 {
781- left : `${ orange . x } px` ,
782- top : `${ orange . y } px` ,
783776 "--rotation" : `${ orange . rotation } deg` ,
784- transform : `translate(-50%, -50%) rotate(${ orange . rotation } deg)` ,
777+ transform : `translateX( ${ orange . x } px) translateY( ${ orange . y } px) translate(-50%, -50%) rotate(${ orange . rotation } deg)` ,
785778 } as React . CSSProperties
786779 }
787780 />
@@ -791,8 +784,8 @@ function App() {
791784 className = "orange-half top"
792785 style = {
793786 {
794- left : `${ orange . x } px` ,
795- top : `${ orange . y } px` ,
787+ "--x-offset" : `${ orange . x } px` ,
788+ "--y-offset" : `${ orange . y } px` ,
796789 "--rotation" : `${ orange . rotation } deg` ,
797790 "--fly-distance" : "-50px" ,
798791 transform : `translate(-50%, -50%) rotate(${ orange . rotation } deg)` ,
@@ -803,8 +796,8 @@ function App() {
803796 className = "orange-half bottom"
804797 style = {
805798 {
806- left : `${ orange . x } px` ,
807- top : `${ orange . y } px` ,
799+ "--x-offset" : `${ orange . x } px` ,
800+ "--y-offset" : `${ orange . y } px` ,
808801 "--rotation" : `${ orange . rotation } deg` ,
809802 "--fly-distance" : "50px" ,
810803 transform : `translate(-50%, -50%) rotate(${ orange . rotation } deg)` ,
@@ -821,10 +814,8 @@ function App() {
821814 className = { `bomb ${ bomb . sliced ? "sliced" : "" } ` }
822815 style = {
823816 {
824- left : `${ bomb . x } px` ,
825- top : `${ bomb . y } px` ,
826817 "--rotation" : `${ bomb . rotation } deg` ,
827- transform : `translate(-50%, -50%) rotate(${ bomb . rotation } deg)` ,
818+ transform : `translateX( ${ bomb . x } px) translateY( ${ bomb . y } px) translate(-50%, -50%) rotate(${ bomb . rotation } deg)` ,
828819 } as React . CSSProperties
829820 }
830821 />
@@ -834,23 +825,23 @@ function App() {
834825 className = "bomb-half top"
835826 style = {
836827 {
837- left : `${ bomb . x } px` ,
838- top : `${ bomb . y } px` ,
828+ "--x-offset" : `${ bomb . x } px` ,
829+ "--y-offset" : `${ bomb . y } px` ,
839830 "--rotation" : `${ bomb . rotation } deg` ,
840831 "--fly-distance" : "-50px" ,
841- transform : `translate(-50%, -50%) rotate(${ bomb . rotation } deg)` ,
832+ transform : `translateX( ${ bomb . x } px) translateY( ${ bomb . y } px) translate(-50%, -50%) rotate(${ bomb . rotation } deg)` ,
842833 } as React . CSSProperties
843834 }
844835 />
845836 < div
846837 className = "bomb-half bottom"
847838 style = {
848839 {
849- left : `${ bomb . x } px` ,
850- top : `${ bomb . y } px` ,
840+ "--x-offset" : `${ bomb . x } px` ,
841+ "--y-offset" : `${ bomb . y } px` ,
851842 "--rotation" : `${ bomb . rotation } deg` ,
852843 "--fly-distance" : "50px" ,
853- transform : `translate(-50%, -50%) rotate(${ bomb . rotation } deg)` ,
844+ transform : `translateX( ${ bomb . x } px) translateY( ${ bomb . y } px) translate(-50%, -50%) rotate(${ bomb . rotation } deg)` ,
854845 } as React . CSSProperties
855846 }
856847 />
@@ -864,8 +855,9 @@ function App() {
864855 className = "orange-juice"
865856 style = {
866857 {
867- left : `${ particle . x } px` ,
868- top : `${ particle . y } px` ,
858+ /*left: `${particle.x}px`,
859+ top: `${particle.y}px`,*/
860+ transform : `translateX(${ particle . x } px) translateY(${ particle . y } px)` ,
869861 opacity : Math . max ( 0 , 1 - particle . time / 1.5 ) ,
870862 } as React . CSSProperties
871863 }
0 commit comments