The Daily Click ::. Forums ::. Klik Coding Help ::. Beginner Question
 

Post Reply  Post Oekaki 
 

Posted By Message

WallMeat



Registered
  01/11/2009
Points
  5
1st November, 2009 at 01:52:03 -

Hello, everyone!

I'm not a seasoned programmer, but I've gotten into working with MMF recently. I'm eager to get a platformer up and running, but there are a few things slowing my progress that I'd like to know more about. I'll stick with just this one for now, since an answer may actually solve most of my other problems. It's probably basic stuff to a veteran programmer, but bear with me!

I'd like to know, what are Alterable Values? In particular, I'm trying to build movement and physics for a platformer, but I don't fully understand what the numbers and calculations represent. When I follow tutorials, no explanation is really given about them, so as a result, even if I can build something functional by following a tutorial's instruction, I don't really understand how or why or what makes it function. I'd prefer to be able to freely manipulate objects and such with deliberate calculations instead of shooting in the dark. Any help with this would be greatly appreciated! (Also, if there are effective methods of detailed object and behavior customization other than Alterable Values available, elaboration on those would be appreciated as well.)

 
n/a

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49667

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
1st November, 2009 at 02:03:23 -

A variable is a kinda of a storage for numbers to be manipulated, or stored for later.

Alterable Variables are simply variables attached to any object. These variables can differ from instance to instance even if it's the same object!

This is good for storing lives of enemies, AI states, or whatever else you can think of!

I find when you just simply follow the tutorial and then play around with everything afterwards you start to figure out how everything works! That's how it was for me even though I felt like I was shooting in the dark for a while.

 
n/a

[DELETED]

Likes to put dots on paper

Registered
  08/12/2008
Points
  118

MushroomVIP MemberARGH Sign
1st November, 2009 at 06:03:18 -

Alterable Values are your soon-to-be best friend in MMF.

 
n/a

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
1st November, 2009 at 08:08:50 -

Another way of looking at it:

Alterable values are identical to counters.

The only difference is that they are internal to each active object. That is to say, each active object has its own internal counters called "Alterable Values".

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

WallMeat



Registered
  01/11/2009
Points
  5
2nd November, 2009 at 23:42:03 -

Thanks for your help everyone!
Describing them as a kind of storage for numbers clears things up a little bit, but I'm still foggy on the subject. I don't know what the numbers I'm storing actually represent-are they X/Y coordinates? Hit points? Units of time? And how do I know what number to put into the field? In other words, I still don't know what the numbers correspond to, and what effect putting in a certain number will have. I'm looking to be able to translate ideas into actions using Alterable Values as easily as creating simple Conditions, but I'm essentially clueless as to what or how or which number or equation will give me the results I'm looking for, and which ideas I'll need Alterable Values to accomplish. The solution to most of the "limits" I'm feeling are probably right under my nose, but inability to understand-and subsequently manipulate-Alterable Values still holds me back.
At the moment, I can't compare them to counters since I haven't gotten around to counters just yet...(I'm just trying to go beyond the simplest parts of MMF)but I will keep it in mind. If anything, that will give me a head start in learning counters when I come to it!
If you could, please explain to me in novice terms what the numbers represent, and how exactly to manipulate them? Please be as thorough as possible; the more information, the better!
Thanks for your patience!

 
n/a

UrbanMonk

BRING BACK MITCH

Registered
  07/07/2008
Points
  49667

Has Donated, Thank You!Little Pirate!ARGH SignKliktober Special Award TagPicture Me This Round 33 Winner!The Outlaw!VIP MemberHasslevania 2!I am an April FoolKitty
Picture Me This Round 32 Winner!Picture Me This Round 42 Winner!Picture Me This Round 44 Winner!Picture Me This Round 53 Winner!
2nd November, 2009 at 23:53:35 -

Well normally the numbers stored in Alterable Variables have no meaning, BUT when you combine Alterable Variables with the code that manipulates/accesses them then that's when they have meaning. Got it? Good.

You can manipulate Alterable Variables in two ways:

Firstly inside the frame editor. Highlight an object and check it's properties, somewhere on one of the tabs is a Alterable Variable section. You can add new Alterable Variables, name them, and even set their value!

Secondly you can change and access Alterable Variables in your code, from the event editor! To access and compare an Alterable Variable to something else (Either a fixed number, or another number retrieved from other objects) simply add a new condition, select the object you want to check the Alterable Variable of and select:

-Alterable Variables
-Compare to one of the Alterable Variables

At that point a diologe will come up that allows you to select which Alterable Variable you want to check and what you want to compare it to. Also HOW to compare it. eg. Greater Than, Equal to, ect.

To change an Alterable Variable from within the event editor simply create a condition under which you want the change to occur. (ex: When bullet hits player) Then add a new action under the object of which you want to change it's alterable Variable (Select one of the little boxes on the grid, under the object you want)

Hope you can understand this!
Good Luck!


 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
3rd November, 2009 at 13:01:58 -


Originally Posted by WallMeat
I don't know what the numbers I'm storing actually represent-are they X/Y coordinates? Hit points? Units of time? And how do I know what number to put into the field? In other words, I still don't know what the numbers correspond to, and what effect putting in a certain number will have.



The numbers can represent anything you like - that's the whole point of alterable values.
MMF's designers gave objects a lot of pre-defined "variables" - X_position, speed, size, direction, etc - but they couldn't possibly have thought of everything. Any time you need to use a variable that isn't built-in to MMF, you use an alterable value.

Let's consider a simple "Breakout" clone.
You have lots of "brick" objects, each of which is represented by an "active object".
Now suppose you want to make it so that a brick must be hit 3 times before it is destroyed.
You need a way to remember how many times each individual brick has been hit.
If you have 20 bricks, that's 20 different values you need to store.
If you were to use "counter" objects, you would need one counter for each brick, which would be very wasteful and confusing.

The solution is to use one of the Brick object's alterable values.
Your code might look something like this:

1.) If Ball collides with Brick
-> Add 1 to Alterable Value A of Brick

2.) If Alterable Value A of Brick = 3
-> Destroy Brick

The important thing is that each Brick object stores it's own alterable value A. One Brick can have an alterable value A of "1" (if it's been hit once), and another may have an alterable value A of "2" (if it's been hit twice).

In the platformer you are making, you would use alterable values for vertical-velocity, horizontal-velocity, gravity, jump-strength, etc.

The other point I want to make is that you should get in the habit of renaming alterable values - it will make your code much easier to understand. In the breakout example, you might rename "Alterable Value A" to "HitCount" or something like that.

Edited by Sketchy

 
n/a

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
3rd November, 2009 at 13:40:40 -

Sketchy - That is the best explanation of Alterable Values I have ever heard. I'm sure that will help a lot of people

Edited by an Administrator

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

bigredron



Registered
  07/04/2007
Points
  299
4th November, 2009 at 00:24:15 -

Sketchy always has great examples

 
n/a

WallMeat



Registered
  01/11/2009
Points
  5
5th November, 2009 at 14:58:45 -

Thanks much for the explanations, especially for going into all the detail! You guys have cleared up a lot of the confusion--I've gone back several times to look over the events in the tutorial I've been following, and things are starting to make much more sense. I believe I may be close to a breakthrough, but there's something that still remains a mystery to me:

How do you direct what attribute an Alterable Value will control?

For instance, if I wanted to make Alterable Value 1 control player speed, but have Alterable Value 2 control something entirely different like gravity, and have Alterable Value 3 contol something different from that, and so on.

In the tutorial I've been working with, Alterable Value 1 appears to correspond to the player's gravity, but I can't tell how the person running the tutorial linked the attribute of gravity to Alterable Value 1...it seemed to be linked to gravity right off the bat, but that doesn't seem right. I'm wondering if I missed something somewhere, but I can't find anything, despite looking over the Events several times over.
I understand I'll be able to rename the Alterable Values later for convenience, but as of now I'm having trouble figuring out how to tell each Alterable Value what it should be in control of.

In other words, how do I tell an Alterable Value what attribute it will have control over?

Also, is there a difference between creating attributes that seem to keep count of a number like Hit Points, and creating an attribute like Gravity or Attack Strength? Is it possible to use Alterable Values to do something like change player movement from Running/Jumping to Swimming when they touch what I want to act as water?

From there, I'm hoping I'll be able to create attributes for my objects such as the Jump Strength and Velocity suggested before, and to be able to manipulate those attributes by comparing Alterable Values and such, also suggested. If there are any other parts of the program involved in doing this properly/efficiently (I wondered if Fast Loops might be involved, but I'm unsure of this), please go into detail!

You guys have been an amazing help with this, and I've gotten a lot further thanks to you! Your assistance is definitely appreciated!

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
5th November, 2009 at 16:19:09 -

Alterable Values on their own, don't do anything. It's only when you combine them with other variables and actions that they become useful.

Let's consider a custom platform movement.
We need two alterable values - we'll rename them "Gravity" and "Y_Velocity" just to make things easy.
To begin with, we don't want the player to be moving at all, so we'll leave the initial value of "Y_Velocity" as "0".

We do however, want the player to be affected by gravity, so we set the "Gravity" alterable value to some number - let's just say "2" for now. To find the right value usually takes a bit of trial and error.

Now, like I said before, simply setting alterable values isn't going to do anything on it's own.
First, you need to think about the relationship between "Y_Velocity" and "Gravity".
Hopefully you can see that gravity is a force which acts to increase the rate at which the player is falling (his Y_Velocity).

So, you would make an event like this:

1.) Always
-> Add Gravity("Player") to Y_Velocity("Player")

Still, this isn't enough to have any visible effect yet. We need to actually move the player sprite on screen.
So...

2.) Always
-> Set Y position of Player to: Y position of Player + Y_Velocity("Player")

Now you will actually be able to see something happen - the player will fall at an ever-increasing rate.
It might seem backwards that you add the "Y_Velocity", but you need to remember that the Y-axis counts down from the top of the screen (it's the opposite of a normal graph).

Now suppose you want the player to stop falling when they land on a platform.
You need to set their rate of fall to "0":

3.) Player collides with backdrop
-> Set Y_Velocity("Player") to 0

And what if you want the player to be able to jump?
A positive value of "Y_Velocity" makes the player fall, so to make the player jump, you need to make it a negative value (take another look at line 2 if you can't see why).

4.) Player overlaps backdrop <- you can jump in mid-air, can you?
+ Player presses "shift" key
-> Set_Velocity("Player") to -10

What if you want to add a powerup that makes the player fall more slowly, like he's on the moon?

5.) Player collides with Powerup_1
-> Set Gravity("Player") to 1 <- remember - normal gravity was "2"

What if you want to add a powerup that let's the player jump really high?
Well for that, you'd need to rewrite line 4 using another alterable value:

4.) Player overlaps backdrop
+ Player presses "shift" key
-> Set_Velocity("Player") to Jump_Strength <- remember to set the initial value of jump_strength to -10

...

6.) Player collides with Powerup_2
-> Set Jump_Strength("Player") to -20


If you followed all this exactly, you'd end up with a pretty buggy game, so it's really just to try and help you understand.

I think you'd actually be better off the using the built-in platform movement to begin with, just until you are more comfortable using MMF.


 
n/a

Codemonkey

Always Serious

Registered
  06/11/2007
Points
  164

Code MonkeyKlikCast StarVIP MemberAttention GetterWii Owner360 OwnerThe Cake is a LieCardboard BoxHero of TimeI'm a Storm Trooper
I'm on a BoatIt's-a me, Mario!PS3 OwnerSonic SpeedGOTM - SEPTEMBER 2009 - WINNER!Evil klikerPokemon Ball!I am an April Fool
5th November, 2009 at 19:03:45 -

Show off.

 
You can log off any time you like, but you can't ever leave.

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
5th November, 2009 at 20:05:35 -

Nah. I've just got way too much time on my hands...

 
n/a
   

Post Reply



 



Advertisement

Worth A Click