So I've started to use MF2 instead of the old The Games Factory.
I'm trying to make a managment game where you buy/build buildings and businesses. My city has five areas, each represented by a frame/level.
I want the player to be able to move around he city by switching frames, and I want the progress in each frame to be kept.
Is it true that the only way for a frame to be changed to where it was before is through global values? Becuase the only way I've found to do it is to have a global value for, say, if a house has been built or not, and then compare it at the start of the level. This seems really cumbersome and I would run out of global values very fast if I need a separate one for every factor that can be changed in a level.
Is there an easier way to do this, I wish there was a way to save the state of a frame and reload it the nex time to frame is displayed.
If some of your objects are present in many frames, you can make their alterable values global by checking "Global object" under the object's runtime options.
I'd definitely go with Don's suggestion - an array should be the perfect solution.
Each city block can be represented by one value in an array, so 0=empty, 1=house, 2=factory etc.
Use one array for each frame, and then save&load when switching.
Originally Posted by flexxx I've come this far in my test frame:
- Button [BUILD BUTTTON] clicked Build the house
:[ARRAY] Write value 5 to (1)
- ValueAtX ( "[ARRAY]", 1) = 5
:House built
But the second one doesn't trigger. What am I doing wrong?
Other one? you must set array x pos to 2 for other one... you cant always write to the same position.
:[ARRAY] Write value 5 to (1) should be :[ARRAY] Write value 5 to (increasing number of houses)
Or even better is to use x,y for position, and z for type of house built.
Arrays are much better than ini,s when it comes to large quantity of data. Inis are restricted in size i think.
And to me arrays are much easier to code with when u get the hang of it.
Originally Posted by Don Luciano
Or even better is to use x,y for position, and z for type of house built.
Actually, using a Z-value for type built is wasteful. Numeric values 0-inf is better than using Z if there is only one type of data to be held at any given X, Y.
When you create a building, you use the "write value to x,y" action.
Value is a number which acts as an id for a particular type of building (eg. house=1, factory=2).
X is the horizontal grid coordinate. It can be found by dividing the actual screen position by the width of a grid square.
Y is the vertical grid coordinate. It can be found by dividing the actual screen position by the height of a grid square.
For example:
The resulting array is hown on the right.
(each grid square is 16x16 pixels)
I suggest you look at the array examples, and read a few articles (including the one on Tile-based games, which has a few handy formulae)
Originally Posted by Don Luciano
Or even better is to use x,y for position, and z for type of house built.
Actually, using a Z-value for type built is wasteful. Numeric values 0-inf is better than using Z if there is only one type of data to be held at any given X, Y.
Well thats what i meant. I didnt meant to use more than one z for diferent houses. That would be wastefull. But defaultly it does use one z for any data at x,y.
could just use one frame and have each scene next to each other, have it when you 'switch' to another area it just moves the screen across.
say you have 5 areas as you said, and the window size is 500 by 500, you have a frame thats 2500x500.
scene 1 = set screen x scroll to 0
scene 2 = set screen x scroll to 500
scene 3 = set screen x scroll to 1000
scene 4 = set screen x scroll to 1500
scene 5 = set screen x scroll to 2000
that way you dont need to worry about bonus items, global objects, and you can have the other scenes easily advance in time when you dont have them in focus (Which i assume you would want, why would they not be evaluated if you aren't looking at them)