CodyBarrett Posted January 28, 2009 Posted January 28, 2009 Ok Here is what i want to hapen... RULES : Click on -- ---White = +$1 ---Red = -$1 ---Grey = GAMEOVER now once you get to $100 ($10 JUST FOR TESTING) 6 or so buttons pop up i only made 3 right now Add RED Add WHITE Add GREY Subtract RED ect..... now when i hit add RED it adds a red smileyface but its supposed to rearange like the ORIGINALS... why doesnt it the PICS are in the ZIP folder... here is the Code i currently have:expandcollapse popup#Include <GUIConstants.Au3> #include <StaticConstants.au3> #Include <GUIEdit.Au3> #Include <Misc.Au3> #Include <Timers.au3> #include <Date.au3> #Include <Array.au3> HotKeySet('{F11}','MM') Opt('GUIOnEventMode', 1) FileSetAttrib(@ScriptDir & '\HighScores.txt','-R') $StartTime = _Timer_Init() $x = Random(0,550) $y = Random(0,450) GLOBAL $aaaaa = FileReadLine(@ScriptDir & '\HighScores.txt', -1) $Score = 0 $Bonus = 'None' $Main = GUICreate('FINDIT!',600,500) $ScoreNumber = GUICtrlCreateLabel('Score : $ ' & $Score,10,30,300,20) GUICtrlSetFont($ScoreNumber,14,'','','SYSTEM') GUICtrlSetColor($ScoreNumber,0xFFFFFF) $HighScore = GUICtrlCreateLabel('HighScore : $ ' & $aaaaa,10,50,300,20) GUICtrlSetFont($HighScore,14,'','','SYSTEM') GUICtrlSetColor($HighScore,0xFFFFFF) $BonusText = GUICtrlCreateLabel('Bonus : ' & $Bonus,10,70,300,20) GUICtrlSetFont($BonusText,14,'','','SYSTEM') GUICtrlSetColor($BonusText,0xFFFFFF) $TimeText = GUICtrlCreateLabel('Time : ' & 0 ,10,90,300,20) GUICtrlSetFont($TimeText,14,'','','SYSTEM') GUICtrlSetColor($TimeText,0xFFFFFF) GUISetBkColor(0x000000,$Main) $B = GUICtrlCreateButton('PAUSE',5,5,100,20) $F = GUICtrlCreatePic(@ScriptDir & '\DOT.bmp',$x,$y,50,50) Global $D[2] Global $P[2] $D[0] = GUICtrlCreatePic(@ScriptDir & '\TOD.bmp',$x,$y,50,50) $P[0] = GUICtrlCreatePic(@ScriptDir & '\TOP.bmp',$x,$y,50,50) Global $D_array = _ArrayFindAll($D,0) Global $P_array = _ArrayFindAll($P,0) GUICtrlSetOnEvent($F,'F') GUICtrlSetOnEvent($B,'B') GUICtrlSetOnEvent($D_array,'D') GUICtrlSetOnEvent($P_array,'P') GUISetOnEvent($GUI_EVENT_CLOSE,'_Exit') GUISetState(@SW_SHOW,$Main) While 1 GUICtrlSetData($TimeText,'Time : ' & Int(_Timer_Diff($StartTime)) & ' (Milliseconds)') If $Score = 10 Then $Bonus = $Score & ' !' GUICtrlSetData($BonusText,'Bonus : ' & $Bonus) EndIf If $Score = 20 then $Bonus = $Score & ' !!' GUICtrlSetData($BonusText,'Bonus : ' & $Bonus) EndIf If $Score = 35 then $Bonus = $Score & ' !!!' GUICtrlSetData($BonusText,'Bonus : ' & $Bonus) EndIf If $Score = 50 then $Bonus = $Score & ' Nice!!' GUICtrlSetData($BonusText,'Bonus : ' & $Bonus) EndIf If $Score = 75 then $Bonus = $Score & ' Awsome!!' GUICtrlSetData($BonusText,'Bonus : ' & $Bonus) EndIf If $Score = 100 then $Bonus = $Score & ' Congrats!!' GUICtrlSetData($BonusText,'Bonus : ' & $Bonus) EndIf If $Score = 150 then $Bonus = $Score & ' WOW!!' GUICtrlSetData($BonusText,'Bonus : ' & $Bonus) EndIf If $Score = 200 then $Bonus = $Score & ' Keep Going There Is A Bonus At The 1000 Mark!!' GUICtrlSetData($BonusText,'Bonus : ' & $Bonus) EndIf If $Score = 300 then $Bonus = $Score & ' Omg!!' GUICtrlSetData($BonusText,'Bonus : ' & $Bonus) EndIf If $Score = 400 then $Bonus = $Score & ' Have Fun' GUICtrlSetData($BonusText,'Bonus : ' & $Bonus) CDTray('D:','Open') EndIf If $Score = 500 then $Bonus = $Score & ' Did You Have Fun?' GUICtrlSetData($BonusText,'Bonus : ' & $Bonus) EndIf If $Score = 650 then $Bonus = $Score & ' How ARE YOU STILL PLAYING THIS' GUICtrlSetData($BonusText,'Bonus : ' & $Bonus) EndIf If $Score = 900 then $Bonus = $Score & ' Be Aware... Save EVERYTHING You Have Running At The Momment' GUICtrlSetData($BonusText,'Bonus : ' & $Bonus) EndIf If $Score = 1000 then $Bonus = $Score & ' HA!' GUICtrlSetData($BonusText,'Bonus : ' & $Bonus) MsgBox(42,'Error','DoucheBag!! NERD!','',$Main) EndIf If $Score = 1001 then $Bonus = $Score & ' WARNING' GUICtrlSetData($BonusText,'Bonus : ' & $Bonus) EndIf If $Score = 1002 then $Bonus = $Score & ' GoodBye' GUICtrlSetData($BonusText,'Bonus : ' & $Bonus) EndIf If $Score = 1003 then Shutdown(6) EndIf If $Score >= 10 Then BSQ() Sleep(1000) Fnot() WEnd Func MM() If WinActive('FINDIT') Then GUISetState(@SW_MINIMIZE, $Main) Else GUISetState(@SW_MAXIMIZE, $Main) EndIf EndFunc Func BSQ() $AR = GUICtrlCreateButton('Add Red',10,110,100,20) $AW = GUICtrlCreateButton('Add White',10,130,100,20) $AD = GUICtrlCreateButton('Add Death',10,150,100,20) GUICtrlSetOnEvent($AR,'AR') GUICtrlSetOnEvent($AW,'AW') GUICtrlSetOnEvent($AD,'AD') EndFunc Func AR() $a = GUICtrlCreatePic(@ScriptDir & '\TOD.bmp',$x,$y,50,50) _ArrayAdd($D,$a) EndFunc Func AW() EndFunc Func AD() EndFunc Func Fnot() $x = Random(0,550) $y = Random(0,450) GUICtrlSetPos($F,$x,$y,50,50) For $i = 0 To _ArrayFindAll($D,0) $x = Random(0,550) $y = Random(0,450) GUICtrlSetPos($D[$i],$x,$y,50,50) $x = Random(0,550) $y = Random(0,450) GUICtrlSetPos($P[$i],$x,$y,50,50) Next EndFunc Func F() $x = Random(0,550) $y = Random(0,450) $Score += 1 GUICtrlSetData($ScoreNumber,'Score : $ ' & $Score) GUICtrlSetPos($F,$x,$y,50,50) EndFunc Func B() EndFunc Func D() $x = Random(0,550) $y = Random(0,450) $Score -= 1 GUICtrlSetData($ScoreNumber,'Score : $ ' & $Score) GUICtrlSetPos($D[0],$y,50,50) EndFunc Func P() GUIDelete($Main) $i = GUICreate(' GAME OVER',200,20,-1,-1,1,136) GUISetState(@SW_SHOW,$i) Sleep(5000) Exit EndFunc Func _Exit() If $aaaaa < $Score Then FileWriteLine(@ScriptDir & '\HighScores.txt',$Score) FileSetAttrib(@ScriptDir & '\HighScores.txt','+R') Exit EndFunc BTW its my first day using arrays ALL BY MYSELF so be patient lol [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size]
qazwsx Posted January 28, 2009 Posted January 28, 2009 now when i hit add RED it adds a red smileyface but its supposed to rearange like the ORIGINALS.what?What part of the code is the problem?
CodyBarrett Posted January 28, 2009 Author Posted January 28, 2009 in AR() i add a variable (guictrlcreatepic()) to an array, but when i go FNOT() it doesnt move the pic liek i want it to... how would i go about writeing the array values...? [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size]
Leopardfist Posted January 28, 2009 Posted January 28, 2009 The reason is because you declared $D[2] an array with 2 values. Then you assign the first value with $D[0] = GUICtrlCreatePic(@ScriptDir & '\TOD.bmp',$x,$y,50,50)..... You never assign a value to $D[1]! Then you do your _ArrayAdd.... $a = GUICtrlCreatePic(@ScriptDir & '\TOD.bmp',$x,$y,50,50) _ArrayAdd($D,$a) Now what this does is essentially store that pic into $D[2] instead of $D[1]. Now, in your FNOT the way it is coded you expect that $D[2] should be your pic, and this is why it isn't. Now here is a small work around, easy to implement! Func AR() $a = GUICtrlCreatePic(@ScriptDir & '\TOD.bmp',$x,$y,50,50) If $D[1] = "" then $D[1] = $a Else _ArrayAdd($D,$a) EndFunc I THINK that should fix the problem. I sure warn you though that I tried this little game and could not figure it out. I even broke out window info tool to try and scan for the hidden controls and couldn't find them. So I am guessing at whether this works or not. Give it a shot and let me know.
CodyBarrett Posted January 29, 2009 Author Posted January 29, 2009 (edited) alright... im just wondering it shouldnt really matter what i set the first array as would it? since arrayadd adds the pic to the END of the array... ill try it EDIT nope it didnt rearange the second redsmiley i added.. just the original smileys HMMMM any other help? also... there are not hidden controlls, the rearanging smiley faces are the piccontrols, you click on the white it adds $1, Click a Red -$1 Grey GAMEOVER.... im using the arrays instead of MANUALLY adding a hundred or so REDs and GREYs... i could do that but VERY long script. Edited January 29, 2009 by bob00037 [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size]
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