Theron
November 8, 2008, 10:28am
1
Usually in C was used the matrix for this stuff.
So how am I doing in python a character holder called by two variables.
ex. m(1,2)=c; m(5,3)=t etc.
I want to know how to give him values one by one (for each variable 1 and 2). A read for every two variables and an exact read like something=m(3,2) for example.
Please help!
if you want to store 2D coordinates you can use the vec2d or point2d classes
https://www.panda3d.org/apiref.php?page=Point2D
thought the content of those have to be numerical datatypes.
for a more general approach you can use tuples or lists
for tuples just do:
m = ( 1.432 , 6.341 )
for a list it’s
m = [ 4321.53124 , 4.143 ]
and you can access the single components by doing m[0] or m[1]
rdb
November 8, 2008, 10:48am
3
I think he rather means something like 2D-lists:
m = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
print m[0][2]
m[1][0] = 8
five = m[1][1]
Theron
November 8, 2008, 10:50am
4
Yes I thought of 2D list but my python manual does not wrote how to make exact calls!
Tnx for the answers and sorry for the disturbance!