Forum Replies Created
-
AuthorPosts
-
This was easy enough in Original Monkey, and I would imagine that a variation could be used in Monkey 2. The trick was that if you already made a templated 1D array copy, you can then use it in your 2D one, and so on. OFC you still need to make separate ones for as many dimensions as you think you’ll need, but not much coding is involved. Here is the Monkey X version:
Class for generic functions
Monkey123456789101112131415161718192021222324252627282930313233343536' Class for generic functionsClass Generic< T >' Return a copy of the passed 1D array (will not 'deep copy' objects, just copies references)Function CopyArray:T[]( orig:T[] )Local len:Int = orig.Length()Local arr:T[] = New T[ len ]For Local i:Int = 0 Until lenarr[ i ] = orig[ i ]NextReturn arrEnd' Return a copy of the passed 2D array (will not 'deep copy' objects, just copies references)Function CopyArray:T[][]( orig:T[][] )Local len:Int = orig.Length()Local arr:T[][] = New T[ len ][]For Local i:Int = 0 Until lenarr[ i ] = CopyArray( orig[ i ] )NextReturn arrEnd' Return a copy of the passed 3D array (will not 'deep copy' objects, just copies references)Function CopyArray:T[][][]( orig:T[][][] )Local len:Int = orig.Length()Local arr:T[][][] = New T[ len ][][]For Local i:Int = 0 Until lenarr[ i ] = CopyArray( orig[ i ] )NextReturn arrEndEndActivity on the original Monkey forum seems to be dropping fast. I assume part of it is that active posters are coming here instead.
I don’t like fragmentation
Activity – even if it’s not relevant to a user’s particular issue – helps keep up motivation and confidence.
I’ve done something like this in the past with spritesheet images – but I just used a point to define the sprite, knowing what the basic size of the image and its sprites is.
I think a sprite atlas as such should probably be a real atlas, with arbitrary packed images.
This design might suit some users, especially for a tile-based game – but it is a very specific approach, and might be best done ad hoc for such a game.
This isn’t Monkey 2 specific, but like Mark and jondecker, I would just try to develop my game in an OO fashion, then when it’s done, refactor out the particular system into a module for my next game.
As several people have noticed, there’s no difference in C++ apart from the default access specifier, and apparently a template thing I didn’t know about. When I coded in C++ I never used the struct keyword at all, on the basis that it was redundant – a hangover in the interests of C compatibility. (This was long before C# made structs fashionable, in an attempt to pull back from the restrictions of Java.)
However, I think that in the interests of nice target code, they should probably use whichever was originally set. And if one is to be used always, I think it should be class, even if that means a bunch of redundant ‘public’ keywords too.
-
AuthorPosts