@@ -46,8 +46,8 @@ export default class Actions {
4646 //this.actions.splice(i, 1)
4747
4848 // Otherwise, this is faster
49- this . actions [ i ] = this . actions [ this . actions . length - 1 ]
50- this . actions [ i ] . finish ( round )
49+ [ this . actions [ i ] , this . actions [ this . actions . length - 1 ] ] = [ this . actions [ this . actions . length - 1 ] , this . actions [ i ] ]
50+ this . actions [ this . actions . length - 1 ] . finish ( round )
5151 this . actions . pop ( )
5252
5353 i --
@@ -385,10 +385,14 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
385385 [ schema . Action . CatScratch ] : class CatScratchAction extends Action < schema . CatScratch > {
386386 draw ( match : Match , ctx : CanvasRenderingContext2D ) : void {
387387 // cat scratching animation
388-
389388 const body = match . currentRound . bodies . getById ( this . robotId )
390389 const pos = match . map . indexToLocation ( this . actionData . loc ( ) )
391390 const coords = renderUtils . getRenderCoords ( pos . x , pos . y , match . map . dimension , true )
391+
392+ const dir = body . direction
393+ body . textureOverride = true
394+ body . imgPath = `robots/cat/cat_scratch_${ dir } .png`
395+
392396 const reflected = body . pos . x < pos . x
393397
394398 const interpolationFactor = match . getInterpolationFactor ( )
@@ -407,12 +411,11 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
407411 }
408412 ctx . stroke ( )
409413 ctx . globalAlpha = 1
410- body . imgPath = `robots/cat/cat_scratch_${ body . direction } .png`
411414 }
412415
413416 finish ( round : Round ) : void {
414417 const body = round . bodies . getById ( this . robotId )
415- body . imgPath = 'robots/cat/cat.png'
418+ body . textureOverride = false
416419 }
417420 } ,
418421 [ schema . Action . CatPounce ] : class CatPounceAction extends Action < schema . CatPounce > {
@@ -421,6 +424,7 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
421424 const body = round . bodies . getById ( this . robotId )
422425 const startPos = round . map . indexToLocation ( this . actionData . startLoc ( ) )
423426 const endPos = round . map . indexToLocation ( this . actionData . endLoc ( ) )
427+ console . log ( 'pounce from' , startPos , 'to' , endPos )
424428 }
425429 draw ( match : Match , ctx : CanvasRenderingContext2D ) : void {
426430 // cat pouncing animation
@@ -431,6 +435,7 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
431435 const endCoords = renderUtils . getRenderCoords ( endPos . x , endPos . y , match . map . dimension , true )
432436 const angle = Math . atan2 ( endPos . y - startPos . y , endPos . x - startPos . x )
433437
438+ body . textureOverride = true
434439 let texture : string
435440 if ( angle >= ( 7 * Math . PI ) / 4 || angle <= Math . PI / 4 ) {
436441 texture = 'robots/cat/cat_pounce_5.png'
@@ -454,7 +459,7 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
454459 }
455460 finish ( round : Round ) : void {
456461 const body = round . bodies . getById ( this . robotId )
457- body . imgPath = 'robots/cat/cat.png'
462+ body . textureOverride = false
458463 }
459464 } ,
460465 [ schema . Action . PlaceTrap ] : class PlaceTrapAction extends Action < schema . PlaceTrap > {
@@ -508,7 +513,8 @@ export const ACTION_DEFINITIONS: Record<schema.Action, typeof Action<ActionUnion
508513 draw ( match : Match , ctx : CanvasRenderingContext2D ) : void {
509514 // trap triggering animation
510515 const body = match . currentRound . bodies . getById ( this . robotId )
511- const pos = match . map . indexToLocation ( this . actionData . loc ( ) )
516+ // const pos = match.map.indexToLocation(this.actionData.loc())
517+ const pos = body . getInterpolatedCoords ( match )
512518 const coords = renderUtils . getRenderCoords ( pos . x , pos . y , match . map . dimension , true )
513519
514520 const size = body . size - 1
0 commit comments