News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

My types not working?

Started by Draco9898, July 09, 2004, 02:35:47 AM

Previous topic - Next topic

Draco9898

PlayBASIC Code: [Select]
`Make Types For Coins>>>
`All coins in graphical representation
Type Coins
MyPlayer,Status,xpos,ypos,ElemType
EndType
Dim TCoins(0) As Coins

Function CreatePlayerCoins(Player)
Size=GetArrayElements(TCoins().Coins,1)
ReDim TCoins(Size+2) As Coins
While S<3
INC S
Coins(Size+X).MyPlayer=Player
`Coins(Size+X).Status=3
`Coins(Size+X).Statusxpos=30
`Coins(Size+X).Statusypos=200
`Coins(Size+X).ElemType=Rnd(4)
EndWhile
EndFunction





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
Well, it might help if the assignment actaully used the type array you've declared..  as you've dimmed "TCoins"   and are attempting to use an array called "Coins" .   Of course no array exists, since it was never dimmed..  

PlayBASIC Code: [Select]
`Make Types For Coins>>>
`All coins in graphical representation
Type Coins
MyPlayer,Status,xpos,ypos,ElemType
EndType
Dim TCoins(0) As Coins

Function CreatePlayerCoins(Player)
Size=GetArrayElements(TCoins().Coins,1)
ReDim TCoins(Size+2) As Coins
While S<3
INC S
tCoins(Size+X).MyPlayer=Player
tCoins(Size+X).Status=3
tCoins(Size+X).xpos=30
tCoins(Size+X).ypos=200
tCoins(Size+X).ElemType=Rnd(4)
EndWhile
EndFunction





Also the T prefix thing  should be used for the actual type declarations rather than the arrays..  

like this

PlayBASIC Code: [Select]
`Make Types For Coins>>>
`All coins in graphical representation

Type tCoins
MyPlayer,Status,xpos,ypos,ElemType
EndType

Dim Coins(0) As tCoins

Function CreatePlayerCoins(Player)
Size=GetArrayElements(Coins().tCoins,1)
ReDim Coins(Size+2) As tCoins
While S<3
INC S
Coins(Size+X).MyPlayer=Player
Coins(Size+X).Status=3
Coins(Size+X).xpos=30
Coins(Size+X).ypos=200
Coins(Size+X).ElemType=Rnd(4)
EndWhile
EndFunction




It's just handy notation idea the people commonly use...

Draco9898

Doh....Well that's what you get when you code when you're half alseep  :rolleyes:
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

:) no matter it happens to all of us.. most of the time.. well some of the time.. not that'd I'd admit making silly mistakes... never ... :rolleyes: