The Daily Click ::. Forums ::. Klik Coding Help ::. Newbie frame help - MF2
 

Post Reply  Post Oekaki 
 

Posted By Message

Rydenio



Registered
  19/04/2006
Points
  42
7th September, 2009 at 14:59:40 -

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.

I want to to be kapt as simple as possible.

Thanks for any help!

 
n/a

Don Luciano

Heavy combat pancake

Registered
  25/10/2006
Points
  380

VIP Member
7th September, 2009 at 15:30:44 -

You can use array...

 
Code me a sausage!

Spitznagl

Cabinetmaker

Registered
  06/12/2008
Points
  4260

The SpinsterVIP MemberHas Donated, Thank You!Picture Me This Round 29 Winner!Picture Me This Round 31 Winner!Picture Me This Round 36 Winner!
7th September, 2009 at 16:21:48 -

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.

Alternately, you could use the "1000 global values" object
http://www.clickteam.info/extensions/extview.php?id=169

 
...

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
7th September, 2009 at 17:28:44 -

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.

 
n/a

Watermelon876



Registered
  16/04/2009
Points
  27

I am an April FoolVIP Member
7th September, 2009 at 18:04:45 -

Save Frame Position? Slightly noobish, but it works!

 
Awesomeness is Watermelon.
*/l、
゙(゚、 。 7
l、゙ ~ヽ
じしf_, )ノ
This is Koji. Copy and paste Koji to your sig so he can acheive world domination.

Rydenio



Registered
  19/04/2006
Points
  42
8th September, 2009 at 09:06:04 -

So I've been looking at arrays, but the concept is hard to grasp.

Especially that there are only three conditions for it puzzles me. How do I check if a certain value has been written?

Could someone describe this to be bearing in mind that I don't seem to understand even the basics of how an array object operates?

 
n/a

alastair john jack

BANNED

Registered
  01/10/2004
Points
  294

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!VIP MemberMushroomI am an April Fool
8th September, 2009 at 09:09:49 -

use the system object's "compare" condition, that way you can do anything you want.

 
lol

Rydenio



Registered
  19/04/2006
Points
  42
8th September, 2009 at 09:21:47 -

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?

 
n/a

alastair john jack

BANNED

Registered
  01/10/2004
Points
  294

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!VIP MemberMushroomI am an April Fool
8th September, 2009 at 09:31:56 -

I don't know dear, maybe you should be using X,Y instead? not just X

 
lol

Rydenio



Registered
  19/04/2006
Points
  42
8th September, 2009 at 09:52:47 -

I dont know, I tried it the same way but wit 1,1 instead of just 1.

Right now I'm leaning towards using the ini object instead becuase it's showing me more love that the array.

 
n/a

]Alpha[



Registered
  19/09/2003
Points
  245
8th September, 2009 at 10:48:25 -

INIs are another good solution to your problem.
It's very easy to learn to use INI and there are lot of articles about that here on Daily Click.

 
All that I see is the years...

Don Luciano

Heavy combat pancake

Registered
  25/10/2006
Points
  380

VIP Member
8th September, 2009 at 11:42:20 -


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.

 
Code me a sausage!

aphant



Registered
  18/05/2008
Points
  1242
8th September, 2009 at 14:47:41 -


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.

 

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
8th September, 2009 at 15:25:43 -

You should use an array.

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.
Image
(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)


Edited by Sketchy

 
n/a

alastair john jack

BANNED

Registered
  01/10/2004
Points
  294

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!VIP MemberMushroomI am an April Fool
9th September, 2009 at 03:01:30 -


Originally Posted by flexxx
I dont know, I tried it the same way but wit 1,1 instead of just 1.

Right now I'm leaning towards using the ini object instead becuase it's showing me more love that the array.



don't go to inis, use AssArray instead -- more protection and easier to use.

 
lol
   

Post Reply



 



Advertisement

Worth A Click