How to improve this in Bmax.
BlitzMax Forums/BlitzMax Beginners Area/How to improve this in Bmax.
| ||
In blitz3D I would often code like this Type Animation Field FRAME%[64] Field FrameX%[64] Field FrameY%[64] Field FrameXSIZE%[64] Field FrameYSIZE%[64] Field MaxFrames% Field FrameSpeed# Field Image Field AmimationName$ Field AnimationID% endtype So in this I would have a max frames per animation of 64 In BlitzMax is there a way to use OOP stuff to make this more dynamic ? |
| ||
Sure - arrays can be whatever size you like. Unlike in B3D, a Max array is a fully-fledged value that can be returned, resized, assigned to variables or fields, etc. Create an array with `New Foo[Size]` and assign it to the field. So e.g.: Type Animation Field FRAME%[] Field FrameX%[] Field FrameY%[] Field FrameXSIZE%[] Field FrameYSIZE%[] Field MaxFrames% Field FrameSpeed# Field Image Field AmimationName$ Field AnimationID% Function Make:Animation(frames:Int) local a:Animation = New Self a.MaxFrames = frames a.FRAME = New Int[frames] a.FrameX = New Int[frames] 'etc return a End Function endtype |
| ||
Thanks Yasha |