Give Points to player, who moves
Hi,
I want that the player collect/get points for each (for example) 20 Pixels he moves high, he should get 10 points.
And if he goes down, then the highest number of points (for example at 80 Pixels height, he has 40 points) should be still displayed.
Did you have an idea?
I want that the player collect/get points for each (for example) 20 Pixels he moves high, he should get 10 points.
And if he goes down, then the highest number of points (for example at 80 Pixels height, he has 40 points) should be still displayed.
Did you have an idea?
Comments
Change attribute self.originalY (real) to self.position.Y <-- this goes at the top of the player actor's rules
Constrain attribute game.points to ceil((self.positionY-self.originalY)/2).
This will add a point each time the player moves up 2 pixels, so if you want the scoring to go 0...10...20 or 0...20...40, we can work on that next.
You may need to add some conditions (Rules) if you want to avoid negative scores. You could wrap the Constrain behavior in a When self.position.Y > self.originalY rule.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I create two attributes (real) "self.originalY" and "self.position.Y".
Also I set first the attribute self.originalY for example to "160".
I also have the "game.points" as integer.
Then I put at the top of the player actor the rule, as you write.
But with points, nothing happens. So for each 10 pixel I want the scoring go up for 10 points.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
< img src="http://www.URL.com">
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
As a side note, I'd recommend NOT using dashes in your attribute names. It will work fine, but it's confusing to see game.Current-PlayerY-self.position.Y because the dash looks like a minus (subtraction) symbol.
Also, how do you know it's not working? Have you created an actor with a DisplayText behavior to show game.Score while you're playing the game?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
So now it worked. I devided by 10. And when player starts at X160px, he just has 16 points, but he should have only 0.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS