AlmarM Posted October 18, 2010 Share Posted October 18, 2010 (edited) Hey,I'm currently creating a little game with AutoIt, and it involves a 2D array.Whenever I use thisGlobal $iX = 25 Global $iY = 25 Global $aArray [$iX + 1][$iY + 1] For $tmpY = 0 To $iY For $tmpX = 0 To $iX $aArray[$tmpY][$tmpX] = "blah" Next NextThere is no problem, everything works.But as soon as I want to resize the array like thisGlobal $iX = 20 ; changed to 20 Global $iY = 25 Global $aArray [$iX + 1][$iY + 1] For $tmpY = 0 To $iY For $tmpX = 0 To $iX $aArray[$tmpY][$tmpX] = "blah" Next NextIt's gets an out or range error.Same as thisGlobal $iX = 25 Global $iY = 20 ; changed to 20 Global $aArray [$iX + 1][$iY + 1] For $tmpY = 0 To $iY For $tmpX = 0 To $iX $aArray[$tmpY][$tmpX] = "blah" Next NextHow do I fix this? The problem is that my For loops can only take 2 numbers wich are equal to each other.EDIT: Typo Edited October 18, 2010 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
whim Posted October 18, 2010 Share Posted October 18, 2010 Just a typo i think: you need to swap the X and Y dimensions one way ... Global $aArray [$iY + 1][$iX + 1] or another ... $aArray[$tmpX][$tmpY] = "blah" at least, that cured the error for me when $iX <> $iY ... whim Link to comment Share on other sites More sharing options...
AlmarM Posted October 18, 2010 Author Share Posted October 18, 2010 Hmm, yeah thanks for that . Brings new errors inside my game though. Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
MvGulik Posted October 18, 2010 Share Posted October 18, 2010 (edited) Nice one for Coding Mistakes dim $aArray[ $iX +1][ $iY +1]For $tmpY = 0 To $iYFor $tmpX = 0 To $iX$aArray[ $tmpY ][ $tmpX ] = ...NextNext Edited October 18, 2010 by MvGulik "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ... Link to comment Share on other sites More sharing options...
AlmarM Posted October 18, 2010 Author Share Posted October 18, 2010 Mayby my head wasn't really clear when writing this. Oh well. Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. 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