Jump to content

Eigensheep

Active Members
  • Posts

    62
  • Joined

  • Last visited

Everything posted by Eigensheep

  1. Thanks for the feedback UEZ! I'll take a look at using Beep() to generate some sounds for it... Glad you enjoyed playing wakillon
  2. Hello everyone, Just a little recreation of the Space Invaders game. I'm sure it's been done before (?) but it's good practice to do it myself! There's no sound because I wanted to try to keep it to a single .au3 file and I'm pretty sure you can't generate your own sounds. The controls are: ENTER - play game LEFT/RIGHT - move left or right SPACEBAR - fire Any ideas on how to optimise it would be great, I wanted to add the barriers that you usually get to hide behind but it was becoming too slow. And of course, if I've got any rules wrong then feel free to correct it... space invaders v2.au3
  3. Ok, so I realise AutoIt is a bad choice for gaming. But I've been working on this for a while now, and feel that the project is near completion so I thought a couple of you guys might have fun testing it. It's basically a mario-like game that I've based heavily on a version I played online a while back. I'd been messing around with GDIPlus and game creation in AutoIt for a bit over the Summer and made simple things like space invaders, etc. so I thought I'd take this on as a challlenge. Well, here's the result. The controls and objectives are all explained in the game so I'll not waste time and post them here. I'd appreciate any comments, suggestions, bugs and ideas for improvement. I'll apologise for the fairly messy code now. I'm also not sure of the name, I've called it "Balls In Space" but this is in fact the name of the game I based it on and I'd like something more appropriate and original so if any creative people have an idea, I'm open to suggestions. One more thing - it should be obvious, but to run the game, it's MainGUI.au3. It has only one level at the moment, but there's a text file in the levels folder that describes how to add more. You can do this to your heart's content. And you can change the game in any way you like, but please do mention my work if you show it to anyone Oh, and for competitive people, with practice I can get a score of 1000. 920 is also pretty good. Balls In Space.zip
  4. I think I've found a solution. First I shortened some of my longer variables (this is surprising news!) and that made a small difference, BUT then I realised that because I was taking some variables from an external file, they were all being read as string type, so in expressions such as "If $var Then" later on, even if $var was "False" then the code was executed. This made a huge difference - it cut down the average time for one of my functions from 250ms to 79ms (according to timerdiff)... Now I know to make sure my variables are of the right type in future. Thanks for the tips though, I'll bear all of it in mind for future scripts.
  5. That doesn't seem to have made a difference. The variable $split[1] comes from a FileReadLine() and the file is closed after the Switch loop, would this make a difference? And Info, I'll bear that in mind - how long is long? Thanks for the help guys.
  6. Ok, I am genuinely confused by this. I'm using GDI Plus to draw images to the screen and then "moving" the images by redrawing them in GDI+. But the problem is that the script slows depending on how I define my initial variables and I don't see why - Like this, it's a useable script, reasonably fast and responsive ("local" here is the global scope, so I don't think memory is the problem) Local Const $Width = 700 Local Const $Height = 650 Local Const $fog = 8 Local Const $n_blocks = 30 Local Const $tilt = $Pi/5 Local Const $bgcolor = "F0506070" Local $dot_distance = 50 But like this and the whole script becomes around 3 seconds slower for every action Switch $split[1] Case "fog" Global Const $fog = 8 Case "n_blocks" Global Const $n_blocks = 30 Case "bgcolor" Global Const $bgcolor = "F0506070" Case "sphere_image" Global $sphere_image = @ScriptDir & "\images\sphere.gif" Case "sphereR0" Global $sphereR0 = 255 Case "sphereG0" Global $sphereG0 = 255 Case "sphereB0" Global $sphereB0 = 90 EndSwitch And, of course, I wanted to use the latter. Any ideas what I can do?
  7. Thanks guys, some interesting thoughts. I think practically M23's solution works best, but in my file the executable code is so short I might be better off to just separate the cases and repeat it. But perhaps for longer sections of code...? Thanks again!
  8. Hi all, Just a quick question; is there a way of having a conditional ContinueCase statement? What I mean is that if I have "Case 1,2,6...." and then "Case 2,3,4" and "Case 1,5" later on in a switch, is there a way I can get autoIt to execute both applicable statements if the value is 1 or 2 (in this example)?? That seems poorly phrased even though I'm english, I hope you can understand my question! Thanks in advance.
  9. Umm, this is awkward. I removed the " & " in each string and now it works. Sorry to have wasted your time, I hope this can help someone else in the future!
  10. Hi guys, firstly sorry for creating another thread. But I can't solve my problem using solutions posted in the forums. So I have this script: $file = @ScriptDir & "\files\tst.au3" $directory = _GetDirPath($file) FileInstall("C:\Users\Jordan\Documents\Autoit Files\Encryption" & "\Aut2exe.exe", $directory) FileInstall("C:\Users\Jordan\Documents\Autoit Files\Encryption" & "\Aut2exe_x64.exe", $directory) FileInstall("C:\Users\Jordan\Documents\Autoit Files\Encryption" & "\AutoItSC.bin", $directory) FileInstall("C:\Users\Jordan\Documents\Autoit Files\Encryption" & "\AutoItSC_x64.bin", $directory) FileInstall("C:\Users\Jordan\Documents\Autoit Files\Encryption" & "\Notes.ico", $directory) FileInstall("C:\Users\Jordan\Documents\Autoit Files\Encryption" & "\upx.exe", $directory) ShellExecuteWait(@ScriptDir & "\files\Aut2exe.exe", '/in "' & $file & '" /icon "' & $directory & 'Notes.ico"') FileDelete($directory & "Aut2exe.exe") FileDelete($directory & "Aut2exe_x64.exe") FileDelete($directory & "AutoItSC.bin") FileDelete($directory & "AutoItSC_x64.bin") FileDelete($directory & "Notes.ico") FileDelete($directory & "upx.exe") Func _GetDirPath($filepath) $i = StringInStr($filepath, "\", 0, -1) Return StringMid($filepath, 1, $i) EndFunc And when I compile I get the notorious error; "Invalid FileInstall() function:" The files exist, are in the location specified, and I HAVE used a literal string as the first parameter of each call to the function. I also replaced all / with \ as suggested, but this hasn't solved it either. I get no such problem running the script normally. Can someone please explain what's going on? Many thanks.
  11. Hi, just a quick question.... What's the equivalent way in autoit of "For Each cell In Application.Selection" in a macro? And if possible, is there a way of restricting this to just one column of the selection, because I need to be able to do both. Thanks in advance
  12. Hi, is there any way to find the first letter not between two <>? So if I had the string <ab>/<cd>efg can I easily get the 'e' without checking every result from StringRegExp? The example seems easy, but my problem is that there could be other things in between the > and the letter, like numbers or / or ^, etc... so it really is just the first letter. Thanks!
  13. 29 Downloads, 109 views and only 1 comment?
  14. Thanks! Glad you liked it.
  15. Another editor, and nothing special. I just thought it finally warranted posting. I still use SciTE by preference. But on computers where AU3 is not installed (eg. at school) I have a copy of the autoit directory and this on my USB stick. The screenshot below should show what it looks like. Features: Text editor New,Open,Save Compile Run Error check Beta/Production Switch "No save" option - the file is not saved before running/ compiling/ error checking Version checker (top right) with website link Multiple "Tabs" New, Next, Previous, Close, Save Some problems I am aware of are: Empty files reading "0" on tab-change and unknown errors on opening some files. You also need SciLexer.dll to run it (not posted, but readily available.) I would be really grateful for any comments/ problems/ ideas/ improvements. Oh and btw, the files "highlighter.au3.txt", "Scintilla.h.au3" and "SciteInclude.au3" should go in the same directory as the main file. I didn't write all of it, just some, but I forget where I found the code - so if it was you then thank you! Let me know and I can put your name in somewhere. Also, the "windows" in the filename doesn't refer to the OS. It's my way of differentiating versions. The source is long which is why I haven't posted it. (But it is included in the zip) Editor.zip
  16. I'm almost certain there's an obvious answer, but can someone tell me why in the following script I am not getting anything written to the output window in SciTE and I get a blank MsgBox, but a valid return value? Thanks! #include <Constants.au3> ;... $file_loc = @ScriptDir & "\test.au3" $file_au3 = $file_loc $foo = RunWait('"' & @ScriptDir & '\Autoit3\au3check.exe" "' & $file_au3 & '"',"", @SW_HIDE, $STDERR_CHILD+$STDOUT_CHILD) ConsoleWrite('"' & @ScriptDir & '\Autoit3\au3check.exe" "' & $file_au3 & '"') MsgBox(64,"Return value is",$foo) $errch = "" While 1 $line = StdoutRead($foo) If @error Then ExitLoop $errch = $errch & $line ConsoleWrite("I can't even see this line...") WEnd MsgBox(64,"",$errch) ;...
  17. I see... Thank you!!! It helps a lot!
  18. Hi, I've tried most things but I can't seem to get the concept to work. I've basically got a GUI with a button and an input and when you hit the button, I would like the script path to run. I tried: $fn = @ComSpec & ' /c "' & @ScriptDir & '\autoit3.exe" /ErrorStdOut "' & $_FILENAME & '"' RunWait($fn) (The $_FILENAME is a valid script path, and autoit3.exe is in the script directory...) But the cmd gives an error. What am I doing wrong? Thanks!
  19. OK, so I got really bored over the past week and I was a bit fed up with only being able to solve linear simultaneous equations, so I came up with this. At the moment its still not quite finished, but the basic workings are all there. To use it, replace $equation1, $equation2 and $variable at the top of the script with the ones you need, following the example. The script uses sylvester's dialytic method to eliminate the given variable, so could be easily extended to 3 or more equations. Hope you guys like it... Final.au3
  20. Sory for the late reply, thanks to both for the help, but I think i'll stick with just the multiline.
  21. Hi, There is probably a really obvious answer, but I can't find it Basically, using GUICtrlCreateButton($apps[$x],50+$lft*100,50+$top*50,90,40,$BS_MULTILINE) will work and display the text on two lines ($lft and $top are defined). But when I use GUICtrlSetBkColor(-1,0x808080) this effect stops. What am I doing wrong?
  22. It reallly only works for linear equations though. You start by entering how many variables you have and then enter the equations into the boxes. When you click solve it gives the answers to all the unknowns to a maximum of 3dp [you could change this - I used round($ans,3)] It's most useful if you have more than 2 variables. #include <GUIConstantsEx.au3> Global $num_unknowns = Number(InputBox("Enter number of unknowns","How many unknowns are there? [NB. You need as many equations as there are unknowns]",3)) Dim $coeff[$num_unknowns+1][$num_unknowns+2] Dim $values[$num_unknowns+1][$num_unknowns+2] GUICreate("Enter Equations:",(48*$num_unknowns) + 121,(26*$num_unknowns) + 77) For $n = 1 To $num_unknowns For $r = 1 To $num_unknowns $values[$n][$r] = GUICtrlCreateInput("",48 * $r, 26 * $n, 25, 21) GUICtrlCreateLabel(StringMid("abcdefghijklmnopqrstuvwxyz",$r,1), (48 * $r)+26, (26 * $n)+5, 10, 17) If $r < $num_unknowns Then GUICtrlCreateLabel("+", (48 * $r)+37, (26 * $n)+5, 10, 17) Else GUICtrlCreateLabel("=", (48 * $r)+37, (26 * $n)+5, 10, 17) EndIf Next $values[$n][$r] = GUICtrlCreateInput("",48 * $r, 26 * $n, 25, 21) Next $solve_button = GUICtrlCreateButton("Solve",(48*$num_unknowns) + 38,(26*$num_unknowns) + 36, 50, 25) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $solve_button For $n = 1 To $num_unknowns For $r = 1 To $num_unknowns+1 $coeff[$n][$r] = Number(GUICtrlRead($values[$n][$r])) Next Next GUISetState(@SW_HIDE) $sols = _Solve($num_unknowns,$coeff) $solutWin = GUICreate("Solutions:", 220, (21 * $sols[0])+ 42) For $n = 1 To $sols[0] ;You can change the round() in the next line: GUICtrlCreateLabel(StringMid("abcdefghijklmnopqrstuvwxyz",$n,1) & " = " & Round($sols[$n],3) & " (Max. 3dp)", 50, 21 * $n, 200, 20) Next GUISetState(@SW_SHOW,$solutWin) EndSwitch Sleep(100) WEnd ; ====================================================================== ; Name...........: _Solve ; Description ...: Finds all unknowns in linear simultaneous equations ; Syntax.........: _Solve($num_unknowns, ByRef $coeff) ; Parameters ....: $num_unknowns - Number of unknown variables (i.e. X,Y,Z is 3) ; $coeff - 2d array containing equations as coefficients: $coeff[1-based $equation][1-based coefficients] ; Return values .: Success - Array: 1st element is number of unknowns, elements 1 to $i are their values, in order ; Author ........: Jordan ; Remarks .......: Will only solve for linear equations. All variables on left of = sign and constant (include as last element in array) on the right. ;======================================================================= Func _Solve($num_unknowns, ByRef $coeff) Dim $solutions[$num_unknowns+1] = [$num_unknowns] $backupArray = $coeff $numberOfUns = $num_unknowns For $r = 1 To $numberOfUns For $eliminatingValue = 1 To $num_unknowns-1 Dim $new_eqs[$num_unknowns+1-$eliminatingValue][$num_unknowns+2] For $current_eq = 1 To UBound($coeff,1)-2 Dim $bypassStep[2][$num_unknowns+2] $value = $coeff[$current_eq+1][$eliminatingValue] For $index = 1 To UBound($coeff,2)-1 $bypassStep[0][$index] = $coeff[$current_eq][$index] * $value Next $value = $coeff[$current_eq][$eliminatingValue] For $index = 1 To UBound($coeff,2)-1 $bypassStep[1][$index] = $coeff[$current_eq+1][$index] * $value Next For $index = 1 To UBound($coeff,2)-1 $new_eqs[$current_eq][$index] = $bypassStep[0][$index] - $bypassStep[1][$index] Next Next $coeff = $new_eqs Next $ans = $coeff[1][UBound($coeff,2)-1] / $coeff[1][UBound($coeff,2)-2] $solutions[$num_unknowns] = $ans For $eqn = 1 To UBound($backupArray,1)-1 $backupArray[$eqn][UBound($backupArray,2)-2] = $backupArray[$eqn][UBound($backupArray,2)-1] - ($backupArray[$eqn][UBound($backupArray,2)-2] * $ans) Next ReDim $backupArray[UBound($backupArray,1)-1][UBound($backupArray,2)-1] $num_unknowns = $num_unknowns - 1 $coeff = 1 $coeff = $backupArray Next Return $solutions EndFunc; ==>_Solve()
  23. Hi, this may seem really silly, but I can't seem to find how to do it. I have an array (see below) and it has 2 dimensions as shown (example). What I would really like to do is remove the middle (i.e. index 1) element from each row and add its value onto the last (i.e. index 2). How would I go about doing this? Dim $array[4][3] = [[1,2,3],[3,4,5],[5,6,7],[7,8,9]] ;Would like to remove the middle values to get following array: Dim $array[4][2] = [[1,5],[3,9],[5,13],[7,17]] Thanks.
  24. Hi, I mainly wrote this because my parents and I are always short for ideas when playing games that require you to act out an item, but i suppose the script could be applied to any purpose as it uses external files. Basically, you can supply the list of items (along with other details) and then select the categories/themes to pick from. The result is a set of cards set out in a web page which is saved to a chosen directory. For testers, I have included some items in a list, although not very good as only the "People" category has colours, and not all items have themes, but you should get the idea. The script may also need tweaking for the latest version (sorry! ) as I haven't tried it with that yet. All the files you need are in the zip. The code has 261 lines so I won't print it here, but it is included. I also apologise that it may not be the best format - its just how my brain works! Thankyou! CharadesCards.zip
  25. Thanks, i'll give that (the function) a try. What I havedone is to bring up a GUI with several checkboxes (values stored in themes.txt - simply a list) and then to read the value of those that are unchecked to an array. I then have another separate txt file (called items.txt) in the same directory that I would like to pick out a specified number of lines from that don't have those values, but not just the first 10, say. Here is (the important part of) my code so far: CODE GUICtrlSetData($title,"Step 2 of 3") GUICtrlSetData($instructions," Now select the themes you want to use. As before, select all, one or a combination of several. When finished, click next again.") GUICtrlSetOnEvent($next,"_step3") $file = FileOpen(@ScriptDir & "/themes.txt",0) $x = 215 $y = 100 $xmax = 595 $ymax = 400 $xdist = 130 $ydist = 30 Global $themes[1][2] = [["CtrlId","Name"]] While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop $ctrl = GUICtrlCreateCheckBox($line,$x,$y,$xdist,$ydist) GUICtrlSetState(-1,$GUI_CHECKED) $x = $x + $xdist + 5 If $x > $xmax Then $x = 215 $y = $y + $ydist + 5 EndIf ReDim $themes[uBound($themes)+1][2] $themes[uBound($themes)-1][0] = $ctrl $themes[uBound($themes)-1][1] = $line WEnd FileClose($file) Func _step3() Global $exclude[1] = ["Text"] For $x = $themes[1][0] To $catgs[uBound($themes)-1][0] If GUICtrlRead ( $x ) = $GUI_UNCHECKED Then ReDim $exclude[uBound($exclude)+1] $exclude[uBound($exclude)-1] = $themes[$x-$themes[1][0]+1][1] EndIf Next EndFunc
×
×
  • Create New...