![]() |
![]() |
![]() |
#1 |
Registered User
Join Date: Apr 2018
Location: Germany
Posts: 103
|
How to create a 'Array of structs' in AMOS?
I'm currently playing around with AMOS.
What I not made out yet is how to manage complex types. E.g. a list of Points. Each point has an X and Y value and maybe some other properties, too. How can an Array of points be created with AMOS? |
![]() |
![]() |
#2 |
Total Chaos forever!
![]() |
You have to do direct manipulation of an Amos bank with Peek, Poke, Deek, Doke, Leek and Loke.
|
![]() |
![]() |
#3 |
Registered User
Join Date: Apr 2018
Location: Germany
Posts: 103
|
Oh I think I aim for something else. Only data - no gfx at this moment.
I try to achieve something that in C would be done like this: Code:
struct MyPoint { ULONG X; ULONG Y; }; MyPoint listOfPoints[10]; |
![]() |
![]() |
#4 |
Registered User
![]() Join Date: Jul 2015
Location: The Netherlands
Posts: 2,651
|
I don't think you can make something like structs in AMOS. I used to "emulate" arrays of structs by having a number of separate arrays containing the individual entries of the struct I wanted and using their name to group them.
So your example would become something like Code:
DIM POINT_X(10),POINT_Y(10) |
![]() |
![]() |
#5 |
Registered User
Join Date: Apr 2018
Location: Germany
Posts: 103
|
This will do it, at least for objects with not too many properties:-) Tank you.
|
![]() |
![]() |
#6 | |
Registered User
Join Date: Nov 2004
Location: Germany
Posts: 542
|
How about multi dimensional arrays ?
I'm emulating types with them like: dim Point(10,2) 10 would be the number of points. (reference number) I have to define where to save the coordinates. e.g. 0=x , 1=y So to access the 5th point x and y coordinate, i'm using : PosX=Point(5,0) PosY=Point(5,1) To make it readable i have used extra variables (which may not change in the code) like: T_X=0 T_Y=1 So the above code would be (a bit more readable too, well in case of debugging!): PosX=Point(5,T_X) PosY=Point(5,T_Y) btw. Quote:
With Amos Data bank you can allocate a desired amount of memory, in which you can (L)(D)Poke the desired values. |
|
![]() |
![]() |
#7 |
Registered User
![]() Join Date: Jul 2015
Location: The Netherlands
Posts: 2,651
|
Yeah, multidimensional arrays also work just fine
![]() The reason I personally tended to do the many 1D arrays way myself was simply one of clarity and allowing multiple types to be mixed. You can instantly see what POINT_X and POINT_Y are referring to, in a multidimensional array you'd have to remember. Now obviously for something as simple as coordinates this is quite doable, but as structures become more complicated it's easier to start making errors when using multidimensional arrays. But use whatever works for you ![]() |
![]() |
![]() |
#8 |
Wipe-Out Enthusiast
![]() Join Date: Nov 2005
Location: .
Age: 40
Posts: 2,521
|
depends on the use though - multi-dimensional arrays are quite a big performance hit in AMOS if accessed inside your game loop. I prefer the PEEK/POKE method personally
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
68040 const array init | phx | Coders. Asm / Hardware | 6 | 14 February 2020 10:27 |
Creating an array gives me a Guru | Shatterhand | Coders. Blitz Basic | 14 | 13 August 2019 21:54 |
Array putting garbage in register | Locash | Coders. Asm / Hardware | 8 | 04 March 2018 14:03 |
Limited Array Of CDTV Games | fondpondforever | Retrogaming General Discussion | 9 | 23 July 2015 15:20 |
Blitz2: Pointer to array | idrougge | Coders. Blitz Basic | 3 | 26 March 2015 22:44 |
|
|