UnderwareDESIGN

PlayBASIC => Beginners => Topic started by: Draco9898 on June 18, 2007, 12:36:48 AM

Title: Getarray/setarray; pointers on typed arrays?
Post by: Draco9898 on June 18, 2007, 12:36:48 AM
Hi, I'm trying to figure out how I got my pointers to point to typed arrays in the past, and it even let me use a regular typed variable (SETARRAY PortrtImgs(),Char(X).PortrtPointer) to store the location and I had a another array that set to this, but I can't get it to work from scratch, so I tried this instead: , anyhelp?

Gosh, I'm really rusty, so it's super embarrassing :P

It gives me "Array handle is invalid" or something along those lines, and yes I looked at help w/ F1.

type Tthisthing
Gabah
endtype
dim thisthing(20) AS Tthisthing
thisthing(0).gabah=2355

Makearray arraypointer()
setarray arraypointer(),getarray(thisthing().tthisthing)
Title: Re: Getarray/setarray; pointers on typed arrays?
Post by: kevin on June 18, 2007, 08:33:56 AM
arraypointer() is an integer array

thisthing().tthisthing is a type a array


[pbcode]
type Tthisthing
   Gabah
endtype
dim thisthing(20) AS Tthisthing
thisthing(0).gabah=2355



Makearray arraypointer().tThisThing
setarray arraypointer(),getarray(thisthing().tthisthing)

print ArrayPointer(0).gabah

sync
waitkey

[/pbcode]
Title: Re: Getarray/setarray; pointers on typed arrays?
Post by: Draco9898 on June 19, 2007, 04:01:35 PM
I know, I was wondering how to make an pointer to point at typed arrays, thanks
Title: Re: Getarray/setarray; pointers on typed arrays?
Post by: kevin on June 19, 2007, 04:11:13 PM
   Why would you want to ?

Title: Re: Getarray/setarray; pointers on typed arrays?
Post by: Draco9898 on June 19, 2007, 04:27:43 PM
Why not? Pointers can make everything nice and generalized
Title: Re: Getarray/setarray; pointers on typed arrays?
Post by: kevin on June 19, 2007, 04:33:37 PM

   Well, what's stopping you ?    Declare a pointer and assign it.

Title: Re: Getarray/setarray; pointers on typed arrays?
Post by: Draco9898 on June 19, 2007, 05:09:37 PM
What was stopping me was pointing to a typed array, just it seems you helped me with that?
Title: Re: Getarray/setarray; pointers on typed arrays?
Post by: kevin on June 19, 2007, 05:59:10 PM
  Dim MyPointer as MyType pointer

  See   Help ->About -> Types 

  Also,

  See Projects->tutorials->types
Title: Re: Getarray/setarray; pointers on typed arrays?
Post by: Draco9898 on June 19, 2007, 10:30:32 PM
Yes, I got it the gist of it in the second post, thank you very much Kevin.
Title: Re: Getarray/setarray; pointers on typed arrays?
Post by: Draco9898 on June 20, 2007, 09:25:11 PM
This is what I originally wanted to do, and it works fine, except when it gets to changing enemy position X, Y, it says Apointer() pointer is not a defined typed array?:

PSUB Create_Enemy(CreateNumb,PosX,PosY)
`Save a multitude of redundant code lines by pointing to typed arrays, stream-lined.
        SELECT CreateNumb
CASE 0
  SETARRAY APointer().tPOINTToType,ECell(0).pointr
CASE 1
                SETARRAY APointer().tPOINTToType,NEWENEMY(0).pointr
ENDSELECT
ThisNum=GETARRAYELEMENTS(APointer().tPOINTToType,1)+1
REDIM APointer(ThisNum) AS tPOINTToType

        `HAVING TROUBLE HERE \/
`APointer(ThisNum).X#=PosX
`APointer(ThisNum).X#=PosY
ENDPSUB


otherwise I'd just do this if thats not possible, but makes it so I have to just add redundant code:

        SELECT CreateNumb
CASE 0
                ThisNum=GETARRAYELEMENTS(ECell().Enemystruct,1)+1
                REDIM ECell(thisnum) AS Enemystruct
ECell(thisnum).X# = blah blah
CASE 1
ThisNum=GETARRAYELEMENTS(THISNewMonster().Enemystruct,1)+1
                REDIM THISNewMonster(thisnum) AS Enemystruct
THISNewMonster(thisnum).X# = blah blah
CASE 2
ThisNum=GETARRAYELEMENTS(THISNewMonster2().Enemystruct,1)+1
                REDIM THISNewMonster2(thisnum) AS Enemystruct
THISNewMonster2(thisnum).X# = blah blah
ENDSELECT



Sorry, but I'm really rusty :P

Or would it be EVEN better still if I just made all the enemies inside one array instead of creating lots of different arrays for each enemy type? I.e:

Type Tenemy
   EnemyNum
   thisX#,ThisY#, blahblah#
endtype
dim Enemy(A large number).Tenemy

then pick through their behaviors/animations/etc depending on their Enemy(X).EnemyNum?
Title: Re: Getarray/setarray; pointers on typed arrays?
Post by: kevin on June 21, 2007, 12:35:14 AM

See  Type Collections  (http://www.underwaredesign.com/forums/index.php?topic=1640.0)



Title: Re: Getarray/setarray; pointers on typed arrays?
Post by: Draco9898 on June 21, 2007, 02:01:48 AM
thank you very much, kevin
That's pretty cool, will that work with version 1.47 and IDE 1.1.5F?
Title: Re: Getarray/setarray; pointers on typed arrays?
Post by: kevin on June 21, 2007, 03:00:27 AM

get up to date  (http://www.underwaredesign.com/forums/index.php?topic=1182.msg13730#msg13730)
Title: Re: Getarray/setarray; pointers on typed arrays?
Post by: Draco9898 on June 21, 2007, 03:13:32 AM
Which version do you recommend? I need working mapping/world "rays". Sorry to bother you so much :)
Title: Re: Getarray/setarray; pointers on typed arrays?
Post by: kevin on June 21, 2007, 06:54:35 AM
 1.63g
Title: Re: Getarray/setarray; pointers on typed arrays?
Post by: Draco9898 on June 21, 2007, 03:43:31 PM
Cool, so all the mapping/world stuffs was hooked back up again, eh?
Title: Re: Getarray/setarray; pointers on typed arrays?
Post by: kevin on June 21, 2007, 03:44:37 PM
they we're never removed.


ahh..  I get it now, you think 1.63 is the Dx7 update, it's just the old stock version.  1.69 is the current BETA of the rebuilt versions. They don't have maps etc
Title: Re: Getarray/setarray; pointers on typed arrays?
Post by: Draco9898 on June 21, 2007, 04:06:02 PM
Ah, I see, I was thinking all the 1.6Xx versions had the stuff cut so they could be rebuilt. I see now.