Dark_Neo
04-23-2004, 03:17 AM
I have a function to move the pupils in 2 eyes (it's an animation program) the problem is there are too many ElseIf statments, surely there must be a better way. Currently I have it so that I have 4 sliders that control the posistion of each pupil (2 sliders for each pupil) each slider has 3 positions, making a total of 9 posistions for the pupil, here's the code I've got:
Private Sub MoveEyes(eye As Integer, x As Integer, y As Integer)
offset = 0
If eye = 1 Then offset = 1800
If x = 0 And y = 0 Then
shpPupilsPreview(eye).Top = 960
shpPupilsPreview(eye).Left = 600 + offset
ElseIf x = 1 And y = 0 Then
shpPupilsPreview(eye).Top = 960
shpPupilsPreview(eye).Left = 720 + offset
ElseIf x = 2 And y = 0 Then
shpPupilsPreview(eye).Top = 960
shpPupilsPreview(eye).Left = 840 + offset
ElseIf x = 0 And y = 1 Then
shpPupilsPreview(eye).Top = 1080
shpPupilsPreview(eye).Left = 600 + offset
ElseIf x = 1 And y = 1 Then
shpPupilsPreview(eye).Top = 1080
shpPupilsPreview(eye).Left = 720 + offset
ElseIf x = 2 And y = 1 Then
shpPupilsPreview(eye).Top = 1080
shpPupilsPreview(eye).Left = 840 + offset
ElseIf x = 0 And y = 2 Then
shpPupilsPreview(eye).Top = 1200
shpPupilsPreview(eye).Left = 600 + offset
ElseIf x = 1 And y = 2 Then
shpPupilsPreview(eye).Top = 1200
shpPupilsPreview(eye).Left = 720 + offset
ElseIf x = 2 And y = 2 Then
shpPupilsPreview(eye).Top = 1200
shpPupilsPreview(eye).Left = 840 + offset
End If
End Sub
But I'm thinking of changing it so that there are 5 posistions for each slider. Making 25 posistions, this would require a massive amount of ElseIf's using my method. Also it creates another problem since the pupil can't go outside the eye, which would happen if both sliders where at their extremes (like if both where at 0 or 5, or one was at 0 and the other at 5) I would be gratefull for any ideas :D
Private Sub MoveEyes(eye As Integer, x As Integer, y As Integer)
offset = 0
If eye = 1 Then offset = 1800
If x = 0 And y = 0 Then
shpPupilsPreview(eye).Top = 960
shpPupilsPreview(eye).Left = 600 + offset
ElseIf x = 1 And y = 0 Then
shpPupilsPreview(eye).Top = 960
shpPupilsPreview(eye).Left = 720 + offset
ElseIf x = 2 And y = 0 Then
shpPupilsPreview(eye).Top = 960
shpPupilsPreview(eye).Left = 840 + offset
ElseIf x = 0 And y = 1 Then
shpPupilsPreview(eye).Top = 1080
shpPupilsPreview(eye).Left = 600 + offset
ElseIf x = 1 And y = 1 Then
shpPupilsPreview(eye).Top = 1080
shpPupilsPreview(eye).Left = 720 + offset
ElseIf x = 2 And y = 1 Then
shpPupilsPreview(eye).Top = 1080
shpPupilsPreview(eye).Left = 840 + offset
ElseIf x = 0 And y = 2 Then
shpPupilsPreview(eye).Top = 1200
shpPupilsPreview(eye).Left = 600 + offset
ElseIf x = 1 And y = 2 Then
shpPupilsPreview(eye).Top = 1200
shpPupilsPreview(eye).Left = 720 + offset
ElseIf x = 2 And y = 2 Then
shpPupilsPreview(eye).Top = 1200
shpPupilsPreview(eye).Left = 840 + offset
End If
End Sub
But I'm thinking of changing it so that there are 5 posistions for each slider. Making 25 posistions, this would require a massive amount of ElseIf's using my method. Also it creates another problem since the pupil can't go outside the eye, which would happen if both sliders where at their extremes (like if both where at 0 or 5, or one was at 0 and the other at 5) I would be gratefull for any ideas :D