I need a little help with importing a list if lists from a csv file.
Using some other similar threads and tutorials I have managed to import a simple csv table using the 'file' component and 'import from csv table components'. I now need help with importing a a slightly more complex table. For example, I want to make a list of 10 soccer teams where each team is a list of 11 players, and each player is a list of a number of traits like name, age, height, weight etc. I know how to make a list of lists in app inventor but am confused about how to make this list in csv format and import it to app inventor. I want to make this in csv format so I can easily edit the data in excel and overwrite csv file whenever needed after the app has been packaged.
Also an off topic question but would appreciate if someone can help. In my game app I have a sprite which I want to move from point A to B. Currently I place the sprite at point A, set its heading to point B and then enable it so it moves in a straight line from A to B. What I want to do now is to make it take a curved path from A to B instead of moving in a straight line. It is more of a maths problem than an app inventor problem but would appreciate any help.
for more complex structures I recommend you to use JSON format
after importing the file in JSON format just use the JSONTextDecode block from the web component to convert it into a complex list of lists
probably someone else can give you a tip for the second question...
Curves. A programmed curve path plotted on an AI2 Canvas. Not easy with a Canvas. Here is a link to using the Canvas in a Windows Delphi Object Pascal project http://www.efg2.com/Lab/ Library/Delphi/Graphics/Math. htm
Why am I directing you here? Delphi's canvas works almost exactly like the canvas in AI2. Some of the plotting algorithms posted on this page would be almost identical in structure to code you would need in AI2 blocks... yes, the coding is in Pascal; you need to 'translate' to blocks.
Try some things by starting a new Project; put a canvas on the Designer and see what you can do. Show us what you come up with.
Thanks for the replies. I will try the json format.
Hi azar-
Unfortunately I am not from a programming/computers background so the Pascal bits are a little to difficult for me. But with some trial and error I have been able to make the sprite move in a curve. What I have done is to add a timer that changes the heading of the sprite continuously. It moves in a sort of curved path but doesn't really end up at the exact point I want it to. With some more time I might be able to figure this out though.
"Also an off topic question but would appreciate if someone can help. In my game app I have a sprite which I want to move from point A to B. Currently I place the sprite at point A, set its heading to point B and then enable it so it moves in a straight line from A to B. What I want to do now is to make it take a curved path from A to B instead of moving in a straight line."
You must provide the following:
Point A (Ax, Ay)
Point B (Bx, By)
Center of a circle which has points A and B as endpoints of a chord passing through the circumference of the circle (Cx, Xy)
We can calculate the Radius of the circle:
Radius = sqrt((Ax - Cx)^2 + (Ay - Cy)^2)
Now we need to get the angles of points A and B on the circle relative to the center of the circle:
AngleA = atan2(Ay - Cy, Ax - Cx)
AngleB = atan2(By - Cy, Bx - Cx)
Now we can create a loop to plot the points along the arc from A to B:
for Angle from AngleA to AngleB by 1 (it is assumed that AngleA < AngleB, otherwise make the 'by' value -1)
DrawPoint(Cx + Radius x cos(Angle), Cy - Radius x sin(Angle))
Thanks Scott, I will give this a go. My trigonometry is a bit rusty to so it will take me some time to figure out your solution but this is pretty much exactly what I was looking for.
댓글 없음:
댓글 쓰기