Hallo liebe Leute,
ich habe mal eine Frage, und zwar:
Ob man Folgendes Skript verkürzen bzw. beschleunigen kann? Ich hab alles probiert aber mir fällt nichts ein.
Spoiler anzeigen
Func _Draw()
Local $Str2, $X = 0, $Y = 0
For $i2 = 0 To 6 Step 1
Switch $i2
Case 0
$Y = 0
Case 1
$Y = 80
Case 2
$Y = 160
Case 3
$Y = 240
Case 4
$Y = 320
Case 5
$Y = 400
Case 6
$Y = 480
EndSwitch
For $i = 0 To 6 Step 1
If $PlayerPosX - 3 + $i < 0 Or $PlayerPosX - 3 + $i > $Width - 1 Then
$Str2 = -9
Else
If $PlayerPosY - 3 + $i2 < 0 Or $PlayerPosY - 3 + $i2 > $Height - 1 Then
$Str2 = -9
Else
$Str2 = $aMap[$PlayerPosX - 3 + $i][$PlayerPosY - 3 + $i2]
EndIf
EndIf
Switch $i
Case 0
$X = 0
If $PlayerPosX - 3 + $i < 0 Or $PlayerPosX - 3 + $i > $Width - 1 Then
$Show[$i][$i2] = -9
Else
If $PlayerPosY - 3 + $i2 < 0 Or $PlayerPosY - 3 + $i2> $Height -1 Then
$Show[$i][$i2] = -9
Else
_Draw_Image($Str2,$Show[$i][$i2], $X, $Y)
EndIf
EndIf
Case 1
$X = 80
If $PlayerPosX - 3 + $i < 0 Or $PlayerPosX - 3 + $i > $Width - 1 Then
$Show[$i][$i2] = -9
Else
If $PlayerPosY - 3 + $i2< 0 Or $PlayerPosY - 3 + $i2 > $Height -1 Then
$Show[$i][$i2] = -9
Else
_Draw_Image($Str2,$Show[$i][$i2], $X, $Y)
EndIf
EndIf
Case 2
$X = 160
If $PlayerPosX - 3 + $i < 0 Or $PlayerPosX - 3 + $i > $Width - 1 Then
$Show[$i][$i2] = -9
Else
If $PlayerPosY - 3 + $i2 < 0 Or $PlayerPosY - 3 + $i2 > $Height -1 Then
$Show[$i][$i2] = -9
Else
_Draw_Image($Str2,$Show[$i][$i2], $X, $Y)
EndIf
EndIf
Case 3
$X = 240
If $PlayerPosX - 3 + $i < 0 Or $PlayerPosX - 3 + $i > $Width - 1 Then
$Show[$i][$i2] = -9
Else
If $PlayerPosY - 3 + $i2 < 0 Or $PlayerPosY - 3 + $i2 > $Height -1 Then
$Show[$i][$i2] = -9
Else
_Draw_Image($Str2,$Show[$i][$i2], $X, $Y)
EndIf
EndIf
Case 4
$X = 320
If $PlayerPosX - 3 + $i < 0 Or $PlayerPosX - 3 + $i > $Width - 1 Then
$Show[$i][$i2] = -9
Else
If $PlayerPosY - 3 + $i2 < 0 Or $PlayerPosY - 3 + $i2 > $Height -1 Then
$Show[$i][$i2] = -9
Else
_Draw_Image($Str2,$Show[$i][$i2], $X, $Y)
EndIf
EndIf
Case 5
$X = 400
If $PlayerPosX - 3 + $i < 0 Or $PlayerPosX - 3 + $i > $Width - 1 Then
$Show[$i][$i2] = -9
Else
If $PlayerPosY - 3 + $i2 < 0 Or $PlayerPosY - 3 + $i2 > $Height -1 Then
$Show[$i][$i2] = -9
Else
_Draw_Image($Str2,$Show[$i][$i2], $X, $Y)
EndIf
EndIf
Case 6
$X = 480
If $PlayerPosX - 3 + $i < 0 Or $PlayerPosX - 3 + $i > $Width - 1 Then
$Show[$i][$i2] = -9
Else
If $PlayerPosY - 3 + $i2 < 0 Or $PlayerPosY - 3 + $i2 > $Height -1 Then
$Show[$i][$i2] = -9
Else
_Draw_Image($Str2,$Show[$i][$i2], $X, $Y)
EndIf
EndIf
EndSwitch
Next
Next
EndFunc
Func _Draw_Image($s, $var, $x, $y)
Select
Case $s == 0
_IrrDraw2DImageElement( $gras, $x, $y, 0, 0,80, 80, $IRR_USE_ALPHA )
Case $s == 0.1
_IrrDraw2DImageElement( $gras2, $x, $y, 0, 0,80, 80, $IRR_USE_ALPHA )
Case $s == 0.2
_IrrDraw2DImageElement( $gras3, $x, $y, 0, 0,80, 80, $IRR_USE_ALPHA )
Case $s == 0.3
_IrrDraw2DImageElement( $gras4, $x, $y, 0, 0,80, 80, $IRR_USE_ALPHA )
Case $s == 1
If $aMap[$PlayerPosX - 1][$PlayerPosY] == 1 Or $aMap[$PlayerPosX + 1][$PlayerPosY] == 1 Or $aMap[$PlayerPosX][$PlayerPosY - 1] == 1 Or $aMap[$PlayerPosX][$PlayerPosY + 1] == 1 Then
_IrrDraw2DImageElement( $gras, $x, $y, 0, 0,80, 80, $IRR_USE_ALPHA )
Else
_IrrDraw2DImageElement( $gras, $x, $y, 0, 0,80, 80, $IRR_USE_ALPHA )
_IrrDraw2DImageElement( $player, $x, $y, 0, 0,80, 80, $IRR_USE_ALPHA )
EndIf
Case $s == 2
_IrrDraw2DImageElement( $stein, $x, $y, 0, 0,80, 80, $IRR_USE_ALPHA )
Case $s == 3
_IrrDraw2DImageElement( $wasser, $x, $y, 0, 0,80, 80, $IRR_USE_ALPHA )
Case $s == 5
_IrrDraw2DImageElement( $quest, $x, $y, 0, 0,80, 80, $IRR_USE_ALPHA )
EndSelect
_IrrDraw2DImageElement( $health_bar, 280, 517, 0, 0,280, 43, $IRR_USE_ALPHA )
If $Health >= 50 Then
_IrrDraw2DImageElement( $health_green, 283, 517, 0, 0,2.73 * $Health, 41, $IRR_USE_ALPHA )
Else
If $Health < 50 And $Health >= 25 Then
_IrrDraw2DImageElement( $health_yellow, 283, 517, 0, 0,2.73 * $Health, 41, $IRR_USE_ALPHA )
Else
If $Health < 25 And $Health > 0 Then
_IrrDraw2DImageElement( $health_red, 283, 517, 0, 0,2.73 * $Health, 41, $IRR_USE_ALPHA )
EndIf
EndIf
EndIf
If $Health == 0 Then
MsgBox(48,$Str[8],"You are Dead")
_exit()
EndIf
If $Quest_Draw == 1 Then
If $Level = $Quest_1[2] Then
_IrrDraw2DImageElement( $quest_gui, 0, 400, 0, 0,560, 560, $IRR_USE_ALPHA )
$Quest_Text = _IrrAddStaticText($Str_Quest[1], 10, 410, 540, 540, $IRR_GUI_NO_BORDER, $IRR_GUI_WRAP)
EndIf
Else
_IrrGUIClear()
$Stop_Save = 0
EndIf
EndFunc