Hallo.
Ich habe zurzeit ein Problem, und zwar ein Hintergrund hinzuzu fügen. Ich habe es mit einiges Versucht. Ich habe es zurzeit jetzt mit diesen hier versucht:
Code
$hGui = GUICreate("")
GUICtrlCreateGifEx($hGui, @ScriptDir & "\background.gif", 0, 0)
GUISetState()
While Sleep(50)
Wend
Es klappt aber immer noch nicht bei mir! Falls der Hauptcode gebraucht wird, ich habe aber das mit den Hintergrund rausgenommen.
C
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=x.ico
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#NoTrayIcon
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <Misc.au3>
#CopyRight bis v1.0 TheShadowAE
#CopyRight von v2.0 Wuseum (Edierer)
_GDIPlus_Startup()
#Region ### START Koda GUI section ### Form=
global $title="Doodle Run!"
global $winx=323
global $winy=238
$Form1 = GUICreate($title, $winx, $winy, 192, 124)
GUISetIcon("x.ico")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
if FileExists(@ScriptDir&"\images\mr.gif")=0 then
msgbox(48,"Fehler","Bild(er) wurde(n) nicht gefunden")
Exit
EndIf
for $x=1 to 10
if FileExists(@ScriptDir&"\images\m"&$x&".gif")=0 Then
msgbox(48,"Fehler","Bild(er) wurde(n) nicht gefunden")
Exit
EndIf
Next
dim $img[10]
$img[0]=_GDIPlus_ImageLoadFromFile(@ScriptDir&"\images\m1.gif")
$img[1]=_GDIPlus_ImageLoadFromFile(@ScriptDir&"\images\m2.gif")
$img[2]=_GDIPlus_ImageLoadFromFile(@ScriptDir&"\images\m3.gif")
$img[3]=_GDIPlus_ImageLoadFromFile(@ScriptDir&"\images\m4.gif")
$img[4]=_GDIPlus_ImageLoadFromFile(@ScriptDir&"\images\m5.gif")
$img[5]=_GDIPlus_ImageLoadFromFile(@ScriptDir&"\images\m6.gif")
$img[6]=_GDIPlus_ImageLoadFromFile(@ScriptDir&"\images\m7.gif")
$img[7]=_GDIPlus_ImageLoadFromFile(@ScriptDir&"\images\m8.gif")
$img[8]=_GDIPlus_ImageLoadFromFile(@ScriptDir&"\images\m9.gif")
$img[9]=_GDIPlus_ImageLoadFromFile(@ScriptDir&"\images\m10.gif")
global $imgrock=_GDIPlus_ImageLoadFromFile(@ScriptDir&"\images\mr.gif")
global $gra=_GDIPlus_GraphicsCreateFromHWND($Form1)
global $buffer=_GDIPlus_BitmapCreateFromGraphics($winx,$winy,$gra)
global $backgra=_GDIPlus_ImageGetGraphicsContext($buffer)
global $pen=_GDIPlus_PenCreate(0xFF0000BB,3)
_GDIPlus_GraphicsSetSmoothingMode($backgra,2)
global $imgx=_GDIPlus_ImageGetWidth($img[0])
global $imgy=_GDIPlus_ImageGetHeight($img[0])
global $xspeed=-3
global const $xnorm=-3
global $yjump=-5
global $gravs=13
global const $maxgrav=2
global const $ynorm=0
global $yspeed=0
global $mx=($winx/2)-($imgx/2)
global $my=($winy/2)-$imgy
global $score=0
dim $line[5][2][2]
global $timer=TimerInit()
global $rockets=0
global $rocket=TimerInit()
global $rocks=0
global $ron=0
global $skill=0
$line[0][0][0]=0
$line[0][0][1]=($winy/2)
$line[0][1][0]=$winx
$line[0][1][1]=($winy/2)
Opt("GUIOnEventMode", 1)
GUISetOnEvent($GUI_EVENT_CLOSE,"ende")
$sprite=TimerInit()
$sksp=0
$image=0
While 1
for $x=0 to UBound($line,1)-1
if $line[$x][1][0]<=0 then newrand($x)
Next
if WinActive($title)=0 then
WinWaitActive($title)
$skill=TimerDiff($timer)
EndIf
_WinAPI_RedrawWindow($Form1, "", "", $RDW_UPDATENOW + $RDW_FRAME)
_GDIPlus_GraphicsClear($backgra,0xFFFFFFFF)
$d=TimerDiff($sprite)-$sksp
if $d>=25 Then
$sksp=TimerDiff($sprite)
$image+=1
EndIf
if $image>ubound($img)-1 Then $image=0
if $ron=0 Then
_GDIPlus_GraphicsDrawImage($backgra,$img[$image],$mx,$my)
Else
_GDIPlus_GraphicsDrawImage($backgra,$imgrock,$mx,$my)
EndIf
for $x=0 to UBound($line,1)-1
_GDIPlus_GraphicsDrawLine($backgra,$line[$x][0][0],$line[$x][0][1],$line[$x][1][0],$line[$x][1][1],$pen)
Next
_GDIPlus_GraphicsDrawString($backgra,"Punkte: "&round($score,0),5,5,"Arial",12)
_GDIPlus_GraphicsDrawImageRect($gra,$buffer,0,0,$winx,$winy)
$yspeed=grav($yspeed,$gravs)
if $yspeed>$maxgrav then $yspeed=$maxgrav
for $x=0 to UBound($line,1)-1
if $line[$x][0][0]<=$mx+$imgx and $line[$x][1][0]>=$mx Then
if ($my+$imgy<=$line[$x][0][1] and $my+$imgy+2>=$line[$x][0][1]) or ($my+$imgy+$yspeed<=$line[$x][0][1] and $my+$imgy+$yspeed+2>=$line[$x][0][1]) then
$yspeed=0
if _IsPressed("26") Then $yspeed=$yjump
EndIf
EndIf
Next
if _IsPressed("27") Then
if $rockets>0 and $ron=0 Then
$rockets-=1
$rocksc=TimerDiff($rocket)
$ron=1
$xspeed=-7
EndIf
EndIf
if $ron=1 Then
if TimerDiff($rocket)-$rocksc>3000 Then
$ron=0
if $score<0 then $xspeed=$xnorm
if $score>=0 then $xspeed=$xnorm+1
if $score>=0 then $xspeed=$xnorm+2
Else
$yspeed=-100
$xspeed=-100
EndIf
EndIf
if TimerDiff($rocket)-$rocks>0 Then
$rockets+=0
$rocks=TimerDiff($rocket)
EndIf
$my+=$yspeed
if $my+$imgy>$winy then death()
$score+=TimerDiff($timer)-$skill
$skill=TimerDiff($timer)
for $x=0 to UBound($line,1)-1
$line[$x][0][0]+=$xspeed
$line[$x][1][0]+=$xspeed
Next
if $score>= 20000 then $xspeed=-4
if $score>= 30000 then $xspeed=-5
if $score>= 40000 then $xspeed=-6
if $score>= 50000 then $xspeed=-7
if $score>= 60000 then $xspeed=-8
if $score>= 70000 then $xspeed=-9
if $score>= 100000 then $xspeed=-10
sleep(10)
WEnd
func ende()
_GDIPlus_ImageDispose($imgrock)
_GDIPlus_ImageDispose($img)
_GDIPlus_BitmapDispose($buffer)
_GDIPlus_GraphicsDispose($backgra)
_GDIPlus_GraphicsDispose($gra)
_GDIPlus_Shutdown()
Exit
EndFunc
Func grav($pluswert,$staerke=10)
$pluswert=$pluswert+Abs($pluswert/5*1.001+2.5)/($staerke)
Return $pluswert
EndFunc
func death()
_GDIPlus_GraphicsDrawString($backgra,"Drücke 'ENTER' um erneut zu spielen! ",-5,50,"Arial",12)
_GDIPlus_GraphicsDrawString($backgra,"Game over! ",-5,50,"Arial",36)
_GDIPlus_GraphicsDrawImageRect($gra,$buffer,0,0,$winx,$winy)
while not _IsPressed("0D")
if WinActive($title)=0 then
WinWaitActive($title)
$skill=TimerDiff($timer)
EndIf
_WinAPI_RedrawWindow($Form1, "", "", $RDW_UPDATENOW + $RDW_FRAME)
_GDIPlus_GraphicsDrawImageRect($gra,$buffer,0,0,$winx,$winy)
sleep(50)
WEnd
$xspeed=$xnorm
$skill=TimerDiff($timer)
$mx=($winx/2)-($imgx/2)
$my=($winy/2)-$imgy
$score=0
$yspeed=$ynorm
for $x=0 to (UBound($line,1)-1)/2
$y=mod($x,2)
Next
$line[0][0][0]=0
$line[0][0][1]=($winy/2)
$line[0][1][0]=$winx
$line[0][1][1]=($winy/2)
$ron=0
EndFunc
func newrand($wer)
$line[$wer][0][0]=$winx
$line[$wer][0][1]=Random($imgy,$winy-10,1)
$line[$wer][1][0]=Random(50,200,1)+$winx
$line[$wer][1][1]=$line[$wer][0][1]
$line[$wer][0][0]-=75
EndFunc
Alles anzeigen
MfG Wusi. ![]()