cppman Posted September 9, 2006 Share Posted September 9, 2006 Hey, I got bored a few minutes ago, and was trying some stuff, practicing collision detection, and came up with this. Basically it is a really simple screensaver, where the AutoIt logo moves around and bounces off each wall... expandcollapse popup#include <guiconstants.au3> ;startup #cs if ($CmdLine[0] > 0) Then if (StringInStr($CmdLine[1], "/c")) Then $speed = InputBox("Speed!", "enter a number 1-10, 1 being the slowest.") $back_c = InputBox("Background Color!", "Enter a hexadecimal color to be used as the background", "0x010080") $size = InputBox("Size!", "Enter a number between 1 and 300 1 being the smallest!", "200") _Configure($speed, $back_c, $size) EndIf Else EndIf if (RegRead("HKEY_LOCAL_MACHINE\Software\AutoItScreenSaver\", "speed") <> "") Then $IMAGE_HSPEED = RegRead("HKEY_LOCAL_MACHINE\Software\AutoItScreenSaver\", "speed") $IMAGE_VSPEED = RegRead("HKEY_LOCAL_MACHINE\Software\AutoItScreenSaver\", "speed") - 2 $BACKGROUND_COLOR = RegRead("HKEY_LOCAL_MACHINE\Software\AutoItScreenSaver\", "background_color") $IMAGE_WIDTH = RegRead("HKEY_LOCAL_MACHINE\Software\AutoItScreenSaver\", "image_size") $IMAGE_HEIGHT = RegRead("HKEY_LOCAL_MACHINE\Software\AutoItScreenSaver\", "image_size") / 2 Else _Configure(5, 0x010080, 200) $IMAGE_HSPEED = 5 $IMAGE_VSPEED = 3 $BACKGROUND_COLOR = 0x010080 $IMAGE_WIDTH = 200 $IMAGE_HEIGHT = 100 EndIf #ce ;Configure ;IMAGE 010080 Global $IMAGE_HSPEED = 5 Global $IMAGE_VSPEED = 2 Global $IMAGE_X = 25 Global $IMAGE_Y = 25 Global Const $IMAGE_WIDTH = 200 Global Const $IMAGE_HEIGHT = 100 Global Const $MAX_X = @DesktopWidth Global Const $MAX_Y = @DesktopHeight GLobal Const $MIN_X = 0 Global Const $MIN_Y = 0 GUICreate("", @DesktopWidth, @DesktopHeight, 0, 0, $WS_POPUP) Global $IMAGE = GUICtrlCreatePic("logo.jpg", $IMAGE_X, $IMAGE_Y, $IMAGE_WIDTH, $IMAGE_HEIGHT) GUISetBkColor(0x010080) GUISetState() while (GUIGetMsg() <> -3) UpdateSprites() ControlMove("", "", $IMAGE, $IMAGE_X, $IMAGE_Y) ;GUICtrlSetPos($image, $IMAGE_X, $IMAGE_Y, $IMAGE_WIDTH, $IMAGE_HEIGHT) WEnd Func UpdateSprites() $IMAGE_X += $IMAGE_HSPEED $IMAGE_Y += $IMAGE_VSPEED if ($IMAGE_X >= ($MAX_X-$IMAGE_WIDTH)) Then $IMAGE_HSPEED *= -1 if ($IMAGE_X <= ($MIN_X)) Then $IMAGE_HSPEED *= -1 if ($IMAGE_Y >= ($MAX_Y-$IMAGE_HEIGHT)) Then $IMAGE_VSPEED *= -1 if ($IMAGE_Y <= ($MIN_Y)) Then $IMAGE_VSPEED *= -1 EndFunc #cs Func _Configure($speed, $background_color, $image_size) RegWrite("HKEY_LOCAL_MACHINE\Software\AutoItScreenSaver\", "speed", "REG_SZ", $speed) RegWrite("HKEY_LOCAL_MACHINE\Software\AutoItScreenSaver\", "background_color", "REG_SZ", $background_color) RegWrite("HKEY_LOCAL_MACHINE\Software\AutoItScreenSaver\", "image_size", "REG_SZ", $image_size) EndFunc #ce if you want to use it as a screensaver, just uncomment what is commented. put this logo in the same directory as the script: Miva OS Project Link to comment Share on other sites More sharing options...
DrGamut Posted September 9, 2006 Share Posted September 9, 2006 Haha, neat. Good work. The drawing method produces quite a bit of flicker, though. Link to comment Share on other sites More sharing options...
RazerM Posted September 9, 2006 Share Posted September 9, 2006 No flicker for me. Nice work. My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop. Link to comment Share on other sites More sharing options...
cppman Posted September 9, 2006 Author Share Posted September 9, 2006 thanks! I don't get any flicker either(just a little tiny bit in the bottom corner of the image), but the way i was gonna do it before GUICtrlSetPos() made alot of flicker, so I used ControlSetPos() and it worked fine. Miva OS Project Link to comment Share on other sites More sharing options...
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