E1M1 Posted December 12, 2009 Posted December 12, 2009 Hi I tried to create my own mario game,I created sky but if I try create ground, AutoIt just won't draw it, It draws only sky(actually It draws grounds but since it's behind the sky, you just cant see it).How I can make script that paints sky as background picture and all other things on it so that all other level objects would be in front of sky? #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Mario", 640, 480) GUISetBkColor(0x000000) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Level() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func Level() $LevelWidth = 640 AddSky($LevelWidth) AddGround(0,420,320,60) EndFunc Func AddSky($LevelWidth) GUICtrlCreatePic("sky.bmp",0,0,$LevelWidth,480) EndFunc Func AddGround($left,$top,$width,$height) GUICtrlCreatePic("ground.bmp",$left,$top,$width,$height,$GUI_ONTOP) EndFunc edited
picea892 Posted December 12, 2009 Posted December 12, 2009 Exciting project. Maybe when you are further along I'll contribute a GDI shrub or something... I thin what you need is $WS_CLIPSIBLINGS. You will all need guisetstate(@SW_DISABLE) for the background
E1M1 Posted December 12, 2009 Author Posted December 12, 2009 I tried to add guictrlsetstate(-1,@SW_DISABLE) to sky and $WS_CLIPSIBLINGS to sky but It didn't work then I tried to add it for ground but it didn't work thatway too. edited
E1M1 Posted December 12, 2009 Author Posted December 12, 2009 I developed it a bit but when I press right arrow to move my char my char disapears. Images are posted as attatchments. expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> Dim $char $CharLeft = 10 $CharTop = 371 #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Mario", 640, 480) GUISetBkColor(0x000000) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $dll = DllOpen("user32.dll") Level() While GUIGetMsg() <> -3 Sleep ( 25 ) If _IsPressed("27", $dll) Then $CharLeft += 1 GUICtrlSetPos($char,$CharLeft,$CharTop) EndIf WEnd Func Level() $LevelWidth = 640 AddChar(10,371,26,49) AddGround(0,420,320,60) AddGround(450,420,320,60) AddSky($LevelWidth) EndFunc Func AddSky($LevelWidth) GUICtrlCreatePic("sky.bmp",0,0,$LevelWidth,480,$GUI_DISABLE) EndFunc Func AddGround($left,$top,$width,$height) GUICtrlCreatePic("ground.bmp",$left,$top,$width,$height,$GUI_ONTOP) EndFunc Func AddChar($left,$top,$width,$height) $char = GUICtrlCreatePic("char.bmp",$left,$top,$width,$height,$GUI_ONTOP) EndFuncmario.zip edited
picea892 Posted December 12, 2009 Posted December 12, 2009 (edited) Add this line in after you move the guicontrol _WinAPI_RedrawWindow(GUICtrlGetHandle($char), "", "", BitOR($WM_ERASEBKGND, $RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME)) Edited December 12, 2009 by picea892
E1M1 Posted December 12, 2009 Author Posted December 12, 2009 (edited) Ok but now it ower writes ground if I move on ground :S but now the question is: Can I shoot and move at same time? At the moment my everything else freezes until missile ends. and how to summon other missile while another is flying? I wanna use something like this Summon();Cast 1st missile sleep();wait to cast 2nd missile, but keep 1st missile flying at same time summon();keep 1st missile flying and cast 2nd one at same time. ;2 missiles fly together ;and character is walking. expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Misc.au3> #Include <WinAPI.au3> Dim $char $CharLeftDefault = 10 $CharTopDefault = 371 $CharLeft = $CharLeftDefault $CharTop = $CharTopDefault $sv_speed = 10 $sv_gravity = 0.3 $titleBarHeitht = 25 $w_fireball_missile_speed = 20 $w_fireball_missile_Damage = 75 $w_iceblast_missile_speed = 2 $w_iceblast_missile_Damage = 30 #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Mario", 640, 480) GUISetBkColor(0x99D9EA) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $dll = DllOpen("user32.dll") Level() While GUIGetMsg() <> -3 Sleep(25) If _IsPressed("27", $dll) Then $CharLeft += $sv_speed GUICtrlSetPos($char, $CharLeft, $CharTop) _WinAPI_RedrawWindow(GUICtrlGetHandle($char), "", "", BitOR($WM_ERASEBKGND, $RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME)) ElseIf _IsPressed("25", $dll) Then $CharLeft -= $sv_speed GUICtrlSetPos($char, $CharLeft, $CharTop) _WinAPI_RedrawWindow(GUICtrlGetHandle($char), "", "", BitOR($WM_ERASEBKGND, $RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME)) ElseIf _IsPressed("28", $dll) Then $CharTop += $sv_speed GUICtrlSetPos($char, $CharLeft, $CharTop) _WinAPI_RedrawWindow(GUICtrlGetHandle($char), "", "", BitOR($WM_ERASEBKGND, $RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME)) ElseIf _IsPressed("26", $dll) Then $CharTop -= $sv_speed GUICtrlSetPos($char, $CharLeft, $CharTop) _WinAPI_RedrawWindow(GUICtrlGetHandle($char), "", "", BitOR($WM_ERASEBKGND, $RDW_INVALIDATE, $RDW_UPDATENOW, $RDW_FRAME)) ElseIf _IsPressed("11", $dll) Then $MissileID = Summon("doomimpball", $CharLeft, $CharTop) ShootMissile($MissileID, $CharLeft, $CharTop, $w_fireball_missile_speed) ;~ Summon("darkimpball") EndIf If $CharTop > 430 Then GameOver() EndIf $pos = WinGetPos($Form1) If PixelGetColor($pos[0] + $CharLeft, $pos[1] + $CharTop + 50 + $titleBarHeitht, $Form1) = 0x99D9EA Then $CharTop += $sv_speed * $sv_gravity GUICtrlSetPos($char, $CharLeft, $CharTop) EndIf WEnd Func Level() $LevelWidth = 640 AddChar(10, 371, 26, 49) AddGround(0, 420, 320, 60) AddGround(450, 420, 320, 60) AddSky($LevelWidth) EndFunc ;==>Level Func AddSky($LevelWidth) GUICtrlCreatePic("sky.bmp", 0, 0, $LevelWidth, 480, $GUI_DISABLE) EndFunc ;==>AddSky Func AddGround($left, $top, $width, $height) GUICtrlCreatePic("ground.bmp", $left, $top, $width, $height, $GUI_ONTOP) EndFunc ;==>AddGround Func AddChar($left, $top, $width, $height) $char = GUICtrlCreatePic("char.bmp", $left, $top, $width, $height, $GUI_ONTOP) EndFunc ;==>AddChar Func GameOver() MsgBox(0, 0, "Game Over") $CharLeft = $CharLeftDefault $CharTop = $CharTopDefault GUICtrlSetPos($char, $CharLeft, $CharTop) EndFunc ;==>GameOver Func Summon($sText, $iX, $iY) Return GUICtrlCreatePic("char.bmp", $iX, $iY, 26, 49) EndFunc ;==>Summon Func ShootMissile($ID, $iStartX, $iStartY, $missile_speed) While $iStartX < 640 $iStartX += $missile_speed Sleep(50) GUICtrlSetPos($ID, $iStartX, $iStartY) WEnd GUICtrlDelete($ID) EndFunc ;==>ShootMissile Edited December 12, 2009 by E1M1 edited
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now