1
Help, Errors, FAQ / Re: Thoughts of a newcomer
« on: 2008-03-09, 11:04:24 PM »
I can't change that back there 
Here is updated code:

Here is updated code:
THANKYOU EVERYONE
Now just so everyone knows, these are the rules you need to make a left/right sprite that jumps, like Mario, etc.
Firstly you need two states, a left and a right state. If you rename Norm0 in the template you made to Right, then choose another state where it points left, rename that Left.
To make the sprite stick to the ground instead of being able to fly, add gravity. This is a rule named Gravity. Select "Do" and "AlterYVelocity" and add ".4" into the delta box. You'll also need three rules called "if moving left", "if moving right" and "if pressing up". I'll go through these one at a time, as they all have subrules which you'll need to add.
Make a rule called "if moving left" and select "if" and "IsInputPressed". Then from the Input box, select "SpriteBase.InputBits.Left" and set Initial Only to "false". If it was true, you would only be able to move one "step" at a time, setting it to false means if you hold down the key, the player will move along until you let go of the button.
This rule is a part of "if moving left" so make sure it is nested. Name this rule "and facing right" then select "and" and "IsInState". In First State, select "(int)Sprites.Player.State.Right" and the same for Last State.
This third rule is also part of "if moving left" and is the last one to be included there. Make a new rule called "then face left" select "do" and "SwitchToState". In the State box, select "(int)Sprites.Player.State.Left" and in Alignment select "RelativePosition.CenterMiddle" and tick the box "end if/while". What we've just done is told the player to move left when we press left. The second rule checks if it is facing right and the third turns the sprite to face left before walking.
In order to move right, we do the same things except replace Left and Right and vice verca in all the rules. Here is what to do anyway, incase you need it.
Make a new rule called "if moving right" and select "if" and "IsInputPressed". From Input select "SpriteBase.InputBits.Right" and InitialOnly is "false".
Create a new rule (a sub-rule of "if moving right") and name it "and facing left" then select "and" and "IsInState". From both FirstState and LastState, select "(int)Sprites.Player.State.Left".
Create a new rule (a sub-rule of "if moving right") and name it "then face right" and select "Do" and "SwitchToState". From State select "(int)Sprites.Player.State.Right" and from Alignment, "RelaticePosition.CenterMiddle". Tick the End If/While box.
Create a new rule called "if pressing up" you can also call this "jump" or something more descriptive. Select "if" and "IsInputPressed" then in Input select "SpriteBase.InputBits.Up" and in InitialOnly, select "true".
Add another rule (this is a subsection of the "pressing up" rule) call this "on ground" or something. select "And" and "Blocked". In the direction, select "SpriteBase.Direction.Down". This checks if you can't move down (because you're on the ground) and allows you to jump. If you're in the air, you can move down, and thus won't be allowed to jump.
Add another rule (this is also a subsection of the "pressing up" rule) call this "accellerate" or whatever you like. Select "Do" and "=" (that's the equal sign, just one, not two of them with no other text) and in Value, select "-10" (thats minus ten) and in Output To: select "dy" and tick the end if/while box
In your inertia rule you'll need "do" and "reactToInertia" selected. From RetainPercentVertical, type 100. From RetainPercentHorizontal, type 80.
There is another rule, it can be named "Walk" which has "do" and "AccellerateByInputs" selected. In Accelleration, have "10". Then in Max have "5" and in HorizontalOnly, select "true". This tells the sprite how fast to move when you press any of the buttons.
This should result in a left/right jumping sprite.
If it doesn't work, I have an extra rule which I'm not sure what it doed (can someone help?). One is called "Rule 1" and has "Do" and "AlterYVelocity" selected. In delta, it has "0.1"
This should definately result in having a left-right jumping sprite.
If anyone out there wants to follow the first tutorial, then inserting these rules, please do so we can clean up the explanations and sticky this somewhere. I'm certain other people will want to know.
Cheers.
[edit]There is an error in there somewhere which allows you to jump infinitely high if you press up over and over again in quick succession. After figuring all that out, I'm a little fatigued so I'm taking a break. If anyone else can spot the error (or can think of a quick solution) please go ahead and do so.
[edit] In the first run, I forgot to add the jump information here. Thanks to Jam0864 for suggesting a fix anyway and allowing progess to be made. You can now jump only when on the ground.
Note: In the second rule of "if pressing up", if you select select "And" and "TouchTiles". Then in the category, select "TileCategoryName.Solid", you should be able to climb walls by walking up to them and pressing up, repeatedly.