•°•°• Lets share useful maths equations •°•°•
StormyStudio
United KingdomMember Posts: 3,989
I just sat down with GameSalad with the luxurious position of a fresh project canvas.
I added some actors... circle, square and a triangle (basic textures)... an hour and a half later I have a basic but possibly addictive and original one button game mechanic with high score feature... I love GameSalad when its like this...
... anyway... its not quite related to my game at the moment but it did get me thinking about spirals... and code...and what useful things I know and would like to know... so I thought I'd post and share...
Anyone care to share some useful equations?
.................
USEFUL EQUATION NO.1:
ROTATE OBJECT AROUND EDGE OF A CIRCLE ACTOR
Code to get an actor to rotate around the outside of a circle as it rotates. Once its setup the possibilities are quite exciting...reverse it and have your actor go the opposite way to the rotating circle...control the speed...jump...expand and contract... spirals?...tunnels...etc etc...
Here's a bit of the code I made earlier after some tinkering... (without additional jumping controls and what not)
Create a rotating circle (actor with circle image on) and a rotation behavior with a speed of something like 90.
Make game attributes which hold the 'circle_width', 'circle_rotation' and 'circle_X' position.
Then (Inside the circle actor) add a 'change attribute' for width and position so the attributes are updated at the beginning (so we save the circles position and width as game attributes for easy access for other actors), but use Constrain for rotation so its constantly updated).
Then add another actor (a square) inside this actor add the following...
constrain:
'self position X' to game.circle_X -(game.circle_width/2)*sin( game.circle_rotation)
And see what happens....
then add
constrain:
'self position Y' to game.circle_Y -(game.circle width/2)*cos( game.circle rotation )
........
Then try changing the - to a +
enjoy.....
It's the basis for a lot of circular game ideas...
To get your actor to rotate as if on the edge of a planet or ball, add a constrain self rotation to your game.circle_rotation... possible add change it to (360-game.circle_rotation) depending which way your actor is going round the circle.
.......................
Anyway hope this is helpful, educational, something...
Night...
I added some actors... circle, square and a triangle (basic textures)... an hour and a half later I have a basic but possibly addictive and original one button game mechanic with high score feature... I love GameSalad when its like this...
... anyway... its not quite related to my game at the moment but it did get me thinking about spirals... and code...and what useful things I know and would like to know... so I thought I'd post and share...
Anyone care to share some useful equations?
.................
USEFUL EQUATION NO.1:
ROTATE OBJECT AROUND EDGE OF A CIRCLE ACTOR
Code to get an actor to rotate around the outside of a circle as it rotates. Once its setup the possibilities are quite exciting...reverse it and have your actor go the opposite way to the rotating circle...control the speed...jump...expand and contract... spirals?...tunnels...etc etc...
Here's a bit of the code I made earlier after some tinkering... (without additional jumping controls and what not)
Create a rotating circle (actor with circle image on) and a rotation behavior with a speed of something like 90.
Make game attributes which hold the 'circle_width', 'circle_rotation' and 'circle_X' position.
Then (Inside the circle actor) add a 'change attribute' for width and position so the attributes are updated at the beginning (so we save the circles position and width as game attributes for easy access for other actors), but use Constrain for rotation so its constantly updated).
Then add another actor (a square) inside this actor add the following...
constrain:
'self position X' to game.circle_X -(game.circle_width/2)*sin( game.circle_rotation)
And see what happens....
then add
constrain:
'self position Y' to game.circle_Y -(game.circle width/2)*cos( game.circle rotation )
........
Then try changing the - to a +
enjoy.....
It's the basis for a lot of circular game ideas...
To get your actor to rotate as if on the edge of a planet or ball, add a constrain self rotation to your game.circle_rotation... possible add change it to (360-game.circle_rotation) depending which way your actor is going round the circle.
.......................
Anyway hope this is helpful, educational, something...
Night...
Comments
To my way of thinking, this is what makes GameSalad so valuable. Since we are free of thinking in terms of computer languages and syntax, we can get creative and experiment with stuff.
Thanks for sharing this.
...
@stoney I'm glad you like the thread.
First you need to constantly update four game level attributes that represent the x,y positions of actor1 and actor2. Lets call them A1X,A1Y and A2X,A2Y (for actor 1 and actor 2, respectively).
You might want to change the line actor's height to one or two pixels.
Then you will need to constantly update four of the line actor's attributes:
Constrain Attribute: self.width To: magnitude(game.A1X-game.A2X,game.A1Y-game.A2Y)
Constrain Attribute: self.rotation To: vectorToAngle(game.A1X-game.A2X,game.A1Y-game.A2Y)
Constrain Attribute: self.Position.X To: game.A1X+(game.A2X-game.A1X)/2
Constrain Attribute: self.Position.Y To: game.A1Y+(game.A2Y-game.A1Y)/2
Its not a complicated equation , but its useful for many things ,
For example - when wanting to constrain an actor between two limits (like a slider)
use :
Constrain self.position.x TO max("Left limit value",(min("right limit value", game.Touches.Touch 1.X))
Roy.
Not a equation in itself but since it uses/generates them I thought its legit to post it here.
Lump Apps and My Assets
http://thatdevelopermarket.com/?product=slider-puzzle-game