http://www.carm3d.com/PureBasicForum/Shake_Issue.MP4
Can anyone tell me why the LCD graphic elements are not shaking correctly? The LCD elements are sprites, where the case is made of drawn elements.
HOWEVER... the rounded border of the screen and the shadow around the edge of the screen are ALSO sprites... All of the sprites are in the same procedure.. The shaking calculation occurs before even entering the procedure. It makes no sense to me why some sprites earlier in the procedure are off, and the ones near the end are locked perfectly.
Any ideas?
Why are SOME of my sprites out of alignment?
Re: Why are SOME of my sprites out of alignment?
You say it's done right. It looks wrong.
No way to know without code.
It looks too be a scaling issue. The inward elements seem to be moving twice (or another multiple) as much in each direction as the outer elements. If all directions moved have an equal and opposite move (i.e left then right) everything will match up in relation to each other again at the end. If floats or other scaling is used it could be a rounding error due to the outer elements being large and the inner ones small.
No way to know without code.
It looks too be a scaling issue. The inward elements seem to be moving twice (or another multiple) as much in each direction as the outer elements. If all directions moved have an equal and opposite move (i.e left then right) everything will match up in relation to each other again at the end. If floats or other scaling is used it could be a rounding error due to the outer elements being large and the inner ones small.
Re: Why are SOME of my sprites out of alignment?
Indeed. It does look wrong.
OKay here is the procedure where all of the sprites are drawn. Near the bottom where it says "; Screen Rounded Border" are the border sprites which draw perfectly in sync with the case.
Code: Select all
Procedure Screen_GameSprites()
Define DispSuff.s = "LCD"
; ************************************************
; **************** BEGIN SHADOWS *****************
; ************************************************
; ; Shake Sprite issue compensation
; If ShakeMode = 2
; CenterX = ((CenterXHome - CenterX) * 0.5) + CenterXHome
; CenterY = ((CenterYHome - CenterY) * 0.5) + CenterYHome
; CornerX = CenterX - 640
; CornerY = CenterY - 360
; EndIf
If DrawShad = 1
If ShowLives = 1
Select GameLives
Case 1
DrawSprite("Life1Shad", CornerX + 255, CornerY + 128, LCDShadVal, 2)
Case 2
DrawSprite("Life2Shad", CornerX + 286, CornerY + 128, LCDShadVal, 2)
Case 3
DrawSprite("Life3Shad", CornerX + 317, CornerY + 128, LCDShadVal, 2)
Case 4
DrawSprite("Life4Shad", CornerX + 348, CornerY + 128, LCDShadVal, 2)
EndSelect
EndIf
If WaveCompMode = 1
DrawSprite("WaveShad", CornerX + 171, CornerY + 139, LCDShadVal, 2)
DrawSprite("CompleteShad", CornerX + 167, CornerY + 164, LCDShadVal, 2)
EndIf
If DrawBonus = 1
DrawSprite("BonusShad", CornerX + 253, CornerY + 191, LCDShadVal, 2)
EndIf
If WildCardInventory = 1
DrawSprite("InvWildShad", CornerX + 165, CornerY + 207, LCDShadVal, 2)
EndIf
If DrawUAPShield = 1
DrawSprite("InvUAPShShad", CornerX + 194, CornerY + 205, LCDShadVal, 2)
EndIf
If DrawMegaWep = 1
DrawSprite("InvMegaShad", CornerX + 230, CornerY + 207, LCDShadVal, 2)
EndIf
If DrawWow = 1
DrawSprite("WowShad", CornerX + 345, CornerY + 150, LCDShadVal, 2)
EndIf
; Score, Underline, Comma Shadows
Protected ScoX.w = 442
For i = 0 To 7
If ScoreDisplay(i) <> -1
ScoStr = GetScoreDigitString(ScoreDisplay(i))
DrawSprite(ScoStr + "Shad", CornerX + ScoX, CornerY + 129, LCDShadVal, 2)
EndIf
If DrawUnderline(i) = 1
DrawSprite("UnderlineShad", CornerX + ScoX + 2, CornerY + 213, LCDShadVal, 2)
EndIf
ScoX + 47
If i = 1 Or i = 4
ScoX + 6
EndIf
If i = 1 And DrawCommaB = 1
DrawSprite("CommaShad", CornerX + ScoX + 1, CornerY + 205, LCDShadVal, 2)
EndIf
If i = 4 And DrawCommaA = 1
DrawSprite("CommaShad", CornerX + ScoX + 1, CornerY + 205, LCDShadVal, 2)
EndIf
Next i
If NewHighScoreDispMode = 1
DrawSprite("NewShad", CornerX + 837, CornerY + 135, LCDShadVal, 2)
EndIf
If NewHighScoreDispMode = 0 Or NewHighScoreDispMode = 1
DrawSprite("HighShad", CornerX + 837, CornerY + 158, LCDShadVal, 2)
DrawSprite("ScoreShad", CornerX + 835, CornerY + 185, LCDShadVal, 2)
ElseIf NewHighScoreDispMode = 2
DrawSprite("ScoreShad", CornerX + 835, CornerY + 185, LCDShadVal, 2)
EndIf
; Past Match Shadow
;DrawSprite(ScoStr + "Shad", CornerX + 933, CornerY + 134, LCDShadVal, 2)
;If ScoreVal < 8
; DrawSprite("PlusShad", CornerX + 988, CornerY + 160, LCDShadVal, 2)
;Else
; DrawSprite("MinusShad", CornerX + 988, CornerY + 160, LCDShadVal, 2)
;EndIf
;DrawSprite(ScoStr + "Shad", CornerX + 1007, CornerY + 134, LCDShadVal, 2)
; Player Shadow
If GameActiveMode = 2
DrawSprite(PlyStr + "Shad", CornerX + 168, CornerY + 259, LCDShadVal, 2)
EndIf
EnX = CornerX + 234
EnY = CornerY + 246
For i = 0 To 8
For j = 0 To 15
If BigDigit(i,j) = 1
Select j
Case 0
DrawSprite("Seg00Shad", EnX + 29, EnY - 11, LCDShadVal, 2)
Case 1
DrawSprite("Seg00Shad", EnX + 63 , EnY - 11, LCDShadVal, 2)
Case 2
DrawSprite("Seg02Shad", EnX + 18, EnY - 11, LCDShadVal, 2)
Case 3
DrawSprite("Seg03Shad", EnX + 34, EnY + 1, LCDShadVal, 2)
Case 4
DrawSprite("Seg04Shad", EnX + 52, EnY - 6, LCDShadVal, 2)
Case 5
DrawSprite("Seg05Shad", EnX + 63, EnY, LCDShadVal, 2)
Case 6
DrawSprite("Seg06Shad", EnX + 87, EnY - 11, LCDShadVal, 2)
Case 7
DrawSprite("Seg07Shad", EnX + 24, EnY + 59, LCDShadVal, 2)
Case 8
DrawSprite("Seg08Shad", EnX + 59, EnY + 59, LCDShadVal, 2)
Case 9
DrawSprite("Seg09Shad", EnX + 13, EnY + 65, LCDShadVal, 2)
Case 10
DrawSprite("Seg10Shad", EnX + 25, EnY + 71, LCDShadVal, 2)
Case 11
DrawSprite("Seg11Shad", EnX + 49, EnY + 65, LCDShadVal, 2)
Case 12
DrawSprite("Seg12Shad", EnX + 62, EnY + 71, LCDShadVal, 2)
Case 13
DrawSprite("Seg13Shad", EnX + 82, EnY + 66, LCDShadVal, 2)
Case 14
DrawSprite("Seg14Shad", EnX + 19, EnY + 137, LCDShadVal, 2)
Case 15
DrawSprite("Seg14Shad", EnX + 53, EnY + 137, LCDShadVal, 2)
EndSelect
EndIf
Next j
EnX = EnX + 90
Next i
If Draw2X = 1
DrawSprite("2XShad", CornerX + 157, CornerY + 415, LCDShadVal, 2)
ElseIf Draw3X = 1
DrawSprite("3XShad", CornerX + 194, CornerY + 415, LCDShadVal, 2)
ElseIf Draw4X = 1
DrawSprite("4XShad", CornerX + 221, CornerY + 415, LCDShadVal, 2)
EndIf
If GameMode = 0 Or GameMode = 1
DrawSprite("ClassicShad", CornerX + 414, CornerY + 414, LCDShadVal, 2)
EndIf
If GameMode = 2 Or GameMode = 3
DrawSprite("RemixShad", CornerX + 520, CornerY + 414, LCDShadVal, 2)
EndIf
If GameMode = 1 Or GameMode = 3
DrawSprite("SurvivalShad", CornerX + 601, CornerY + 414, LCDShadVal, 2)
EndIf
If GameOver = #True
DrawSprite("GameOverShad", CornerX + 827, CornerY + 414, LCDShadVal, 2)
EndIf
DrawSprite("NoteShad", CornerX + 1041, CornerY + 414, LCDShadVal, 2)
EndIf
; **************** END SHADOWS *****************
; Score, Underlines, Commas
ScoX = 474
For i = 0 To 7
If LCDCrosstalk > 0
DrawSprite("Sco8" + DispSuff, CornerX + ScoX, CornerY + 141, LCDCrosstalk, 1)
EndIf
If ScoreDisplay(i) <> -1
ScoStr = GetScoreDigitString(ScoreDisplay(i))
DrawSprite(ScoStr + DispSuff, CornerX + ScoX, CornerY + 141, 255, 1)
EndIf
If DrawUnderline(i) = 1
DrawSprite("Underline" + DispSuff, CornerX + ScoX - 2, CornerY + 225, 255, 1)
Else : DrawSprite("Underline" + DispSuff, CornerX + ScoX - 2, CornerY + 225, LCDCrosstalk, 1)
EndIf
ScoX + 47
If i = 1 Or i = 4
ScoX + 6
EndIf
If i = 4
If DrawCommaA = 1
DrawSprite("Comma" + DispSuff, CornerX + ScoX - 10, CornerY + 211, 255, 1)
ElseIf LCDCrosstalk > 0
DrawSprite("Comma" + DispSuff, CornerX + ScoX - 10, CornerY + 211, LCDCrosstalk, 1)
EndIf
EndIf
If i = 1
If DrawCommaB = 1
DrawSprite("Comma" + DispSuff, CornerX + ScoX - 10, CornerY + 211, 255, 1)
ElseIf LCDCrosstalk > 0
DrawSprite("Comma" + DispSuff, CornerX + ScoX - 10, CornerY + 211, LCDCrosstalk, 1)
EndIf
EndIf
Next i
; Player
If LCDCrosstalk > 0
DrawSprite("PlayAll" + DispSuff, CornerX + 200, CornerY + 270, LCDCrosstalk, 1)
EndIf
If GameActiveMode = 2
DrawSprite(PlyStr + DispSuff, CornerX + 200, CornerY + 270, 255, 1)
EndIf
If NewHighScoreDispMode = 1
DrawSprite("New" + DispSuff, CornerX + 865, CornerY + 145, 255, 1)
ElseIf LCDCrosstalk > 0 : DrawSprite("New" + DispSuff, CornerX + 865, CornerY + 145, LCDCrosstalk, 1)
EndIf
If NewHighScoreDispMode = 0 Or NewHighScoreDispMode = 1
DrawSprite("High" + DispSuff, CornerX + 863, CornerY + 170, 255, 1)
DrawSprite("Score" + DispSuff, CornerX + 861, CornerY + 196, 255, 1)
ElseIf NewHighScoreDispMode = 2
If LCDCrosstalk > 0 : DrawSprite("High" + DispSuff, CornerX + 863, CornerY + 170, LCDCrosstalk, 1)
EndIf
DrawSprite("Score" + DispSuff, CornerX + 861, CornerY + 196, 255, 1)
ElseIf LCDCrosstalk > 0
DrawSprite("High" + DispSuff, CornerX + 863, CornerY + 170, LCDCrosstalk, 1)
DrawSprite("Score" + DispSuff, CornerX + 861, CornerY + 196, LCDCrosstalk, 1)
EndIf
;Past Match
If LCDCrosstalk > 0
DrawSprite("Sco8" + DispSuff, CornerX + 966, CornerY + 146, LCDCrosstalk, 1)
EndIf
;DrawSprite(ScoStr + DispSuff, CornerX + 966, CornerY + 146, 255, 1)
If LCDCrosstalk > 0
DrawSprite("Plus" + DispSuff, CornerX + 1014, CornerY + 173, LCDCrosstalk, 1)
EndIf
;If ScoreVal < 8
; DrawSprite("Plus" + DispSuff, CornerX + 1014, CornerY + 173, 255, 1)
;Else
; DrawSprite("Minus" + DispSuff, CornerX + 1014, CornerY + 173, 255, 1)
;EndIf
If LCDCrosstalk > 0
DrawSprite("Sco8" + DispSuff, CornerX + 1040, CornerY + 146, LCDCrosstalk, 1)
EndIf
;DrawSprite(ScoStr + DispSuff, CornerX + 1040, CornerY + 146, 255, 1)
If WaveCompMode = 1
DrawSprite("Wave" + DispSuff, CornerX + 195, CornerY + 151, 255, 1)
DrawSprite("Complete" + DispSuff, CornerX + 194, CornerY + 176, 255, 1)
Else
DrawSprite("Wave" + DispSuff, CornerX + 195, CornerY + 151, LCDCrosstalk, 1)
DrawSprite("Complete" + DispSuff, CornerX + 194, CornerY + 176, LCDCrosstalk, 1)
EndIf
If DrawBonus = 1
DrawSprite("Bonus" + DispSuff, CornerX + 282, CornerY + 204, 255, 1)
Else : DrawSprite("Bonus" + DispSuff, CornerX + 282, CornerY + 204, LCDCrosstalk, 1)
EndIf
If DrawWow = 1
DrawSprite("Wow" + DispSuff, CornerX + 369, CornerY + 158, 255, 1)
Else : DrawSprite("Wow" + DispSuff, CornerX + 369, CornerY + 158, LCDCrosstalk, 1)
EndIf
Define DrawLife.b = 0
Select GameLives
Case 1
If ShowLives = 1 : DrawLife = 1 : EndIf
Case 2
If ShowLives = 1 : DrawLife = 2 : EndIf
Case 3
If ShowLives = 1 : DrawLife = 3 : EndIf
Case 4
If ShowLives = 1 : DrawLife = 4 : EndIf
EndSelect
If DrawLife = 1
DrawSprite("Life1" + DispSuff, CornerX + 285, CornerY + 140, 255, 1)
Else : DrawSprite("Life1" + DispSuff, CornerX + 285, CornerY + 140, LCDCrosstalk, 1)
EndIf
If DrawLife = 2
DrawSprite("Life2" + DispSuff, CornerX + 316, CornerY + 140, 255, 1)
Else : DrawSprite("Life2" + DispSuff, CornerX + 316, CornerY + 140, LCDCrosstalk, 1)
EndIf
If DrawLife = 3
DrawSprite("Life3" + DispSuff, CornerX + 347, CornerY + 140, 255, 1)
Else : DrawSprite("Life3" + DispSuff, CornerX + 347, CornerY + 140, LCDCrosstalk, 1)
EndIf
If DrawLife = 4
DrawSprite("Life4" + DispSuff, CornerX + 378, CornerY + 140, 255, 1)
Else : DrawSprite("Life4" + DispSuff, CornerX + 378, CornerY + 140, LCDCrosstalk, 1)
EndIf
If WildCardInventory = #True
DrawSprite("InvWild" + DispSuff, CornerX + 193, CornerY + 217, 255, 1)
Else : DrawSprite("InvWild" + DispSuff, CornerX + 193, CornerY + 217, LCDCrosstalk, 1)
EndIf
If DrawUAPShield = 1
DrawSprite("InvShUAP" + DispSuff, CornerX + 222, CornerY + 215, 255, 1)
Else : DrawSprite("InvShUAP" + DispSuff, CornerX + 222, CornerY + 215, LCDCrosstalk, 1)
EndIf
If DrawMegaWep = 1
DrawSprite("InvMega" + DispSuff, CornerX + 259, CornerY + 217, 255, 1)
Else : DrawSprite("InvMega" + DispSuff, CornerX + 259, CornerY + 217, LCDCrosstalk, 1)
EndIf
EnX = CornerX + 230
EnY = CornerY + 246
Define DigitOpacity.a
For i = 0 To 8
For j = 0 To 15
If BigDigit(i,j) = 1 : DigitOpacity = 255
Else : DigitOpacity = LCDCrosstalk : EndIf
Select j
Case 0
DrawSprite("Seg00" + DispSuff, EnX + 46, EnY, DigitOpacity, 1)
Case 1
DrawSprite("Seg01" + DispSuff, EnX + 45, EnY, DigitOpacity, 1)
Case 2
DrawSprite("Seg02" + DispSuff, EnX + 44, EnY, DigitOpacity, 1)
Case 3
DrawSprite("Seg03" + DispSuff, EnX + 45, EnY, DigitOpacity, 1)
Case 4
DrawSprite("Seg04" + DispSuff, EnX + 45, EnY, DigitOpacity, 1)
Case 5
DrawSprite("Seg05" + DispSuff, EnX + 45, EnY, DigitOpacity, 1)
Case 6
DrawSprite("Seg06" + DispSuff, EnX + 45, EnY, DigitOpacity, 1)
Case 7
DrawSprite("Seg07" + DispSuff, EnX + 44, EnY, DigitOpacity, 1)
Case 8
DrawSprite("Seg08" + DispSuff, EnX + 45, EnY, DigitOpacity, 1)
Case 9
DrawSprite("Seg09" + DispSuff, EnX + 44, EnY, DigitOpacity, 1)
Case 10
DrawSprite("Seg10" + DispSuff, EnX + 45, EnY, DigitOpacity, 1)
Case 11
DrawSprite("Seg11" + DispSuff, EnX + 45, EnY, DigitOpacity, 1)
Case 12
DrawSprite("Seg12" + DispSuff, EnX + 45, EnY, DigitOpacity, 1)
Case 13
DrawSprite("Seg13" + DispSuff, EnX + 45, EnY, DigitOpacity, 1)
Case 14
DrawSprite("Seg14" + DispSuff, EnX + 44, EnY, DigitOpacity, 1)
Case 15
DrawSprite("Seg15" + DispSuff, EnX + 45, EnY, DigitOpacity, 1)
EndSelect
Next j
EnX = EnX + 90
Next i
If Draw2X = 1
DrawSprite("2X" + DispSuff, CornerX + 186, CornerY + 427, 255, 1)
Else : DrawSprite("2X" + DispSuff, CornerX + 186, CornerY + 427, LCDCrosstalk, 1)
EndIf
If Draw3X = 1
DrawSprite("3X" + DispSuff, CornerX + 218, CornerY + 427, 255, 1)
Else : DrawSprite("3X" + DispSuff, CornerX + 218, CornerY + 427, LCDCrosstalk, 1)
EndIf
If Draw4X = 1
DrawSprite("4X" + DispSuff, CornerX + 247, CornerY + 427, 255, 1)
Else : DrawSprite("4X" + DispSuff, CornerX + 247, CornerY + 427, LCDCrosstalk, 1)
EndIf
If GameMode = 0 Or GameMode = 1
DrawSprite("Classic" + DispSuff, CornerX + 441, CornerY + 426, 255, 1)
Else
DrawSprite("Classic" + DispSuff, CornerX + 441, CornerY + 426, LCDCrosstalk, 1)
EndIf
If GameMode = 2 Or GameMode = 3
DrawSprite("Remix" + DispSuff, CornerX + 550, CornerY + 426, 255, 1)
Else
DrawSprite("Remix" + DispSuff, CornerX + 550, CornerY + 426, LCDCrosstalk, 1)
EndIf
If GameMode = 1 Or GameMode = 3
DrawSprite("Survival" + DispSuff, CornerX + 630, CornerY + 426, 255, 1)
Else
DrawSprite("Survival" + DispSuff, CornerX + 630, CornerY + 426, LCDCrosstalk, 1)
EndIf
If GameOver = #True
DrawSprite("GameOver" + DispSuff, CornerX + 853, CornerY + 426, 255, 1)
Else
DrawSprite("GameOver" + DispSuff, CornerX + 853, CornerY + 426, LCDCrosstalk, 1)
EndIf
DrawSprite("Note" + DispSuff, CornerX + 1070, CornerY + 426, 255, 1)
If UseDispIncandescent = 1 And DispIncandescentOn = 1 And Lighting = 0
;nothing
ElseIf DrawBezShad = 1
; Bezel Shadow
ClipSprite(BezelShadsprite, 0, 0, 21, 373) ; Left Bezel Shadow
DisplayTransparentSprite(BezelShadsprite, CornerX + 170, CornerY + 105, LCDShadVal, RGB(SprShadR, SprShadG, SprShadB))
ClipSprite(BezelShadsprite, 22, 0, 918, 30) ; Top Bezel Shadow
DisplayTransparentSprite(BezelShadsprite, CornerX + 191, CornerY + 105, LCDShadVal, RGB(SprShadR, SprShadG, SprShadB))
EndIf
; Screen Rounded Border
ClipSprite(ScreenSprite, 0, 0, 17, 20) ; NW
DisplayTransparentSprite(ScreenSprite, CornerX + 170, CornerY + 105)
ClipSprite(ScreenSprite, 923, 0, 17, 20) ; NE
DisplayTransparentSprite(ScreenSprite, CornerX + 1093, CornerY + 105)
ClipSprite(ScreenSprite, 0, 353, 19, 21) ; SW
DisplayTransparentSprite(ScreenSprite, CornerX + 170, CornerY + 458)
ClipSprite(ScreenSprite, 921, 355, 19, 19) ; SE
DisplayTransparentSprite(ScreenSprite, CornerX + 1091, CornerY + 460)
ClipSprite(ScreenSprite, 18, 0, 905, 1) ; Bar-Top
DisplayTransparentSprite(ScreenSprite, CornerX + 188, CornerY + 105)
ClipSprite(ScreenSprite, 0, 20, 1, 333) ; Bar-Left
DisplayTransparentSprite(ScreenSprite, CornerX + 170, CornerY + 125)
ClipSprite(ScreenSprite, 939, 20, 1, 335) ; Bar-Right
DisplayTransparentSprite(ScreenSprite, CornerX + 1109, CornerY + 125)
ClipSprite(ScreenSprite, 19, 373, 902, 1) ; Bar-Bottom
DisplayTransparentSprite(ScreenSprite, CornerX + 189, CornerY + 478)
; ********** Standard Fade **********
If FadeSequence = 0
FadeSpeed = 25
FadeReq = 2
FadeComplete = #False
FadeSequence = 1
EndIf
If FadeSequence = 1 And FadeComplete = #True
; If something is to be triggered after fade-in
FadeSequence = 2
EndIf
If FadeSequence = 3
FadeComplete = #False
FadeSpeed = 25
FadeReq = 1
FadeSequence = 4
LockInput = 0
EndIf
If FadeSequence = 4 And FadeComplete = #True
GameStart = 0
GameActiveMode = 0
NewHighScoreDispMode = 0
WaveDisplayMode = 0
GameWave = 0
WaveSpawnCount = 0
WaveCompMode = 0
GameOver = #False
ShowLives = 0
FreeSprite(DispSprite(0))
FreeSprite(DispSprite(1))
FreeSprite(DispSprite(2))
FreeSprite(DispSprite(3))
DispSprite(0) = 0 : DispSprite(1) = 0
DispSprite(2) = 0 : DispSprite(3) = 0
FadeSequence = 5
EndIf
; *************** END FADE ***************
EndProcedure
Re: Why are SOME of my sprites out of alignment?
Examining the code shows certain facts.Carm3D wrote: Tue May 06, 2025 2:51 am OKay here is the procedure where all of the sprites are drawn. Near the bottom where it says "; Screen Rounded Border" are the border sprites which draw perfectly in sync with the case.
- Coordinates for sprites seem to be all based on the variables CornerX & CornerY and don't vary based on 'shaking'
- The border sprites and corners are the only one displayed in the procedure
- All interior sprites (on game screen) and their shadows are displayed (assumed) via the DrawSprite() procedure
- The code for the DrawSprite() procedure is not shown
Re: Why are SOME of my sprites out of alignment?
CornerX and CornerY are modified as the shaking happens, along with CenterX and CenterY. This is the DrawSprite procedure:Demivec wrote: Tue May 06, 2025 5:34 am Conclusion: The displacement inconsistency in the display of inner sprites and the border sprites is due to the code in the DrawSprite() procedure.
Code: Select all
Procedure DrawSprite(Name.s, X.w, Y.w, Int.a, M.b)
If FindMapElement(DispSpr(), Name)
With DispSpr()
ClipSprite(DispSprite(\Sheet), \X, \Y, \Width, \Height)
Select M
Case 0 ; No override
DisplayTransparentSprite(DispSprite(\Sheet), (CornerX + X) + DispSpr()\XOff, (CornerY + Y) + DispSpr()\YOff, Int)
Case 1 ; Override SprColR(G,B)
DisplayTransparentSprite(DispSprite(\Sheet), (CornerX + X) + DispSpr()\XOff, (CornerY + Y) + DispSpr()\YOff, Int, RGB(SprColR, SprColG, SprColB))
Case 2 ; Override SprShadR(G,B)
DisplayTransparentSprite(DispSprite(\Sheet), (CornerX + X) + DispSpr()\XOff, (CornerY + Y) + DispSpr()\YOff, Int, RGB(SprShadR, SprShadG, SprShad))
EndSelect
EndWith
EndIf
EndProcedure
Re: Why are SOME of my sprites out of alignment?
Observations:Carm3D wrote: Tue May 06, 2025 12:51 pmCornerX and CornerY are modified as the shaking happens, along with CenterX and CenterY. This is the DrawSprite procedure:Demivec wrote: Tue May 06, 2025 5:34 am Conclusion: The displacement inconsistency in the display of inner sprites and the border sprites is due to the code in the DrawSprite() procedure.
- You don't make use of CenterX or CenterY in either of the procedures DrawSprite() or Screen_GameSprites().
- You pass coordinates into DrawSprite() that are based off of CornerX & CornerY.
- Inside DrawSprite() you take those coordinates and again add the values of CornerX & CornerY to them.
- in your video recording showing the miss alignment of the inner sprites compared to the border sprites, for each displacement of the border sprites from the norm there is a corresponding displacement of the inner sprites by twice as much.
Proposed solution: remove CornerX & CornerY from all statements and expressions in DrawSprite(). If needed, uncomment the calculation of and incorporation of the values CenterX & CenterY in procedure Screen_GameSprites().
Re: Why are SOME of my sprites out of alignment?
If I remove CornerX and CornerY, how do I position the sprites?Demivec wrote: Tue May 06, 2025 1:45 pm Proposed solution: remove CornerX & CornerY from all statements and expressions in DrawSprite(). If needed, uncomment the calculation of and incorporation of the values CenterX & CenterY in procedure Screen_GameSprites().
Re: Why are SOME of my sprites out of alignment?
Code: Select all
centerx-(spritewidth(mysprite)/2)
Re: Why are SOME of my sprites out of alignment?
I fixed it!Demivec wrote: Tue May 06, 2025 1:45 pmProposed solution: remove CornerX & CornerY from all statements and expressions in DrawSprite(). If needed, uncomment the calculation of and incorporation of the values CenterX & CenterY in procedure Screen_GameSprites().
The DrawSprite procedure now uses the alternative CornerX and CornerY... And I made this change to the Shaker procedure:
Code: Select all
Case 2
progress.f = ShakeCount / 3.0
ease.f = 0.5 - 0.5 * Cos(progress * #PI) ; cosine ease-out
; Calculate the offset between old and target
dx.f = ShakeX - ShakeOldX
dy.f = ShakeY - ShakeOldY
; Interpolate between old and new
CenterX = ShakeOldX + dx * ease
CenterY = ShakeOldY + dy * ease
CornerX = CenterX - 640
CornerY = CenterY - 360
CornerXAlt = CenterXHome - 640
CornerYAlt = CenterYHome - 360
ShakeCount + 1
If ShakeCount = 2
; Move to the next step
CenterX = ShakeX
CenterY = ShakeY
ShakeOldX = ShakeX
ShakeOldY = ShakeY
ShakeMode = 1
ShakeVal - 1
If ShakeVal = -1
ShakeMode = 3
EndIf
EndIf