News:

Function Finder  Find all the functions within source code files

Main Menu

Getarray/setarray; pointers on typed arrays?

Started by Draco9898, June 18, 2007, 12:36:48 AM

Previous topic - Next topic

Draco9898

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)
DualCore Intel Core 2 processor @ 2.3 ghz, Geforce 8600 GT (latest forceware drivers), 2 gigs of ram, WIN XP home edition sp2, FireFox 2.

"You'll no doubt be horrified to discover that PlayBasic is a Programming Language." -Kevin

kevin

#1
arraypointer() is an integer array

thisthing().tthisthing is a type a array


PlayBASIC Code: [Select]
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



Draco9898

I know, I was wondering how to make an pointer to point at typed arrays, thanks
DualCore Intel Core 2 processor @ 2.3 ghz, Geforce 8600 GT (latest forceware drivers), 2 gigs of ram, WIN XP home edition sp2, FireFox 2.

"You'll no doubt be horrified to discover that PlayBasic is a Programming Language." -Kevin

kevin


Draco9898

#4
Why not? Pointers can make everything nice and generalized
DualCore Intel Core 2 processor @ 2.3 ghz, Geforce 8600 GT (latest forceware drivers), 2 gigs of ram, WIN XP home edition sp2, FireFox 2.

"You'll no doubt be horrified to discover that PlayBasic is a Programming Language." -Kevin

kevin


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


Draco9898

What was stopping me was pointing to a typed array, just it seems you helped me with that?
DualCore Intel Core 2 processor @ 2.3 ghz, Geforce 8600 GT (latest forceware drivers), 2 gigs of ram, WIN XP home edition sp2, FireFox 2.

"You'll no doubt be horrified to discover that PlayBasic is a Programming Language." -Kevin

kevin

  Dim MyPointer as MyType pointer

  See   Help ->About -> Types 

  Also,

  See Projects->tutorials->types

Draco9898

Yes, I got it the gist of it in the second post, thank you very much Kevin.
DualCore Intel Core 2 processor @ 2.3 ghz, Geforce 8600 GT (latest forceware drivers), 2 gigs of ram, WIN XP home edition sp2, FireFox 2.

"You'll no doubt be horrified to discover that PlayBasic is a Programming Language." -Kevin

Draco9898

#9
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?
DualCore Intel Core 2 processor @ 2.3 ghz, Geforce 8600 GT (latest forceware drivers), 2 gigs of ram, WIN XP home edition sp2, FireFox 2.

"You'll no doubt be horrified to discover that PlayBasic is a Programming Language." -Kevin

kevin


Draco9898

#11
thank you very much, kevin
That's pretty cool, will that work with version 1.47 and IDE 1.1.5F?
DualCore Intel Core 2 processor @ 2.3 ghz, Geforce 8600 GT (latest forceware drivers), 2 gigs of ram, WIN XP home edition sp2, FireFox 2.

"You'll no doubt be horrified to discover that PlayBasic is a Programming Language." -Kevin

kevin


Draco9898

Which version do you recommend? I need working mapping/world "rays". Sorry to bother you so much :)
DualCore Intel Core 2 processor @ 2.3 ghz, Geforce 8600 GT (latest forceware drivers), 2 gigs of ram, WIN XP home edition sp2, FireFox 2.

"You'll no doubt be horrified to discover that PlayBasic is a Programming Language." -Kevin

kevin