•°•°• Lets share useful maths equations •°•°•

StormyStudioStormyStudio United KingdomMember Posts: 3,989
edited October 2012 in Working with GS (Mac)
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...

Comments

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    edited October 2012
    @stormystudio -- This kind of stuff is great!

    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.
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    @RThurman... thanks...I've updated the second constrain equation (parenthesis left over from the equation I've got running with a few extra bits, so I can vary the diametre)

    ...

    @stoney I'm glad you like the thread.
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    HOW TO HAVE A LINE CONNECT TWO MOVING ACTORS:

    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
  • MeaningfulGamesMeaningfulGames Member, PRO Posts: 171
    This is an awesome idea. T-up :)
  • POMPOM Member Posts: 2,599
    edited November 2012
    Hey ,
    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.
  • LumpAppsLumpApps Member Posts: 2,881
    Here is my old project for making all sorts of shapes: http://db.tt/u9LjZYB4
    Not a equation in itself but since it uses/generates them I thought its legit to post it here.
  • LeonardDeveloperLeonardDeveloper Member Posts: 4,630
    As far as relations can get you could try thatdevelopermarket's slider puzzle :)

    http://thatdevelopermarket.com/?product=slider-puzzle-game
Sign In or Register to comment.