Sign in to follow this  
Followers 0
fielmann

How to store coordinates?

4 posts in this topic

I'd like to store/save the postion for 20 objects

DIM $Planetpos[21]
for $i=1  to 20
    $X = Random ( 1,20,1)
    $y = Random ( 1,20,1)
    $pos[$i] = $X,$Y  ; <- LINE DO NOT WORK!!!!
next

It should looks like:

pos[1] = 10 , 10

pos[2] = 15 , 11

pos[1] = 11 , 19

$pos[$i] = $X,$Y ; <- LINE DO NOT WORK!!!! :)

Can anbody help me ?

Share this post


Link to post
Share on other sites



#include <Array.au3>
Dim $Planetpos[20][2]
For $i = 0 To 19
    $Planetpos[$i][0] = Random(1, 20, 1)
    $Planetpos[$i][1] = Random(1, 20, 1)
Next
_ArrayDisplay($Planetpos, 'Positions')


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Use a bidimensional array or a separator, for example "|".

DIM $Planetpos[21]
for $i=1  to 20
    $X = Random ( 1,20,1)
    $y = Random ( 1,20,1)
    $pos[$i] = $X & "|" & $Y ; <- LINE DO NOT WORK!!!!
next

And when you want to read the coordinates you can use StringSplit().


When the words fail... music speaks

Share this post


Link to post
Share on other sites

#include <Array.au3>
Dim $Planetpos[20][2]
For $i = 0 To 19
    $Planetpos[$i][0] = Random(1, 20, 1)
    $Planetpos[$i][1] = Random(1, 20, 1)
Next
_ArrayDisplay($Planetpos, 'Positions')
WOW

thx 4 your fast and perfect answer ! :)

your are really: :)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0