Zetar's Forum Posts

  • I played around with my original capx and came up with a few adjustments. It will now spawn 3 spherical solar systems at random locations in the window with a y rotational axis, and different rotational speeds. Looks neat...

    app.box.com/s/1wg9v4gwqel5ligldu0d

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • R0J0hound, you are a great tribute to all those who frequent this site. Thank you for taking the time to solve this. That extra 48.8 is the key. Thanks for figuring that out! I have created a simple capx with comments to help anyone else in the future who may try to do this.

    Again, this is not the same as orbiting a sprite using Keslers orbit (see circle plot formula at: scirra.com/forum/make-the-player-orbit-around-a-center-point_topic61405.html. This formula will make a perfect circle around the object, which will not deviate.

    This IS using the physics engine to orbit a moon/satellite around a central object with mass. The formula uses the internal Physics.mass of the objects, which is calculated by collision box size*Density variable in the physics properties. So the bigger the item, the more mass it has, multiplied by as many times you want by changing the Density property of sprite.physics.density. These objects can be made to interact with other physics objects creating somewhat realistic planetary models.

    Not only the formula for gravity, but specifically the important impulse push to get the object into orbit.

    app.box.com/s/a93qqsubba14i0nuelwm

  • Making something orbit an object using physics is not hard. I have used and found many ways to do it. So Why is calculating the necessary orbit speed at a specific distance hard?

    I want to create and obj1 sprite, apply physics and center it on screen. Then create an obj2 (with physics) at a random distance from obj1 and send it into orbit at a precise speed to keep it in a circular orbit.

    There has to be a way to do this� I have a capx using the gravity plug-in to use as an example, but you may want to do it a different way. (like using xvector variables and mass, ect�)

    I know the math behind this, but it just does not seem to work. Anyone want to take a crack at it with me?

    https://app.box.com/s/a88x1g5z0k9qk99srvcx

  • I found the plugin Magicam which works perfect, and it was just updated too!

  • Hello friends,

    I can make the screen scroll to a location in the center of two objects, however I need to have the layer zoom out as they move further apart.

    To scroll to center:

    Scroll to position ->

    Obj1.x+(obj2.x-obj1.x)*0.05

    Obj1.y+(obj2.y-obj1.y)*0.05

    Do I need to set an initial variable with the number Distance(obj1,x,obj1.y,obj2.x,obj2.y, then compare that with the current distance clamped so it does not get to small? I think I have the principle, but I am not sure how to do it right...

    Thanks!

  • I think I will re-ask this question because it was confusing...

    I would like to calculate the velocity it takes a moon to orbit a planet at the start of layout using the following:

    Mass of the objects: I have redone the orbit events to use the moon.physics.mass and planet.physics.mass. FYI-This internal value is calculated using the area of the collision mask (set to circle) * Density (internal physics variable) which can be changed to make an object heavier.

    Distance between the objects: Using Construct 2�s Distance formula. Distance(moon.x,moon.y,Planet.x,planet.y)

    Gravity: This is an unknown to me, and part of my problem.

    According to physics laws, to calculate the velocity of an orbiting satellite, you must use this formula: Velocity= Square root of ((Gravity * Mass of Planet) / Distance between center of planet and Satellite center). I need to know what I use for Gravity�

    Currently I have an initial impulse hard set as a onetime event that sends the satellite moon into orbit, but it took many tries to figure out an optimal number.

    Here is the Link to my Example:

    https://app.box.com/s/llz72y0cvlf1rvudv5uh

  • I have got the physics part down to make a satellite use physics to orbit around a planet. I used a formula given by leparlon:

    -Set the world gravity to 0

    -Physics behaviour in all the objects in with the gravity force will act (in this case, the crates).

    -Events:

         Each 0.5 seconds (for better performance)

         Apply Force On CRATE Toward position MOON.X, MOON.Y->GLOBAL_VARIABLE * (CRATE.mass + MOON.mass) / ((CRATE.X - MOON.X)*(CRATE.X - MOON.X) + (CRATE.Y - MOON.Y)*(CRATE.Y - MOON.Y))

    My Question: Using a variable "mass" on the planet and object, and using the distance between the moon and object, how do I get Velocity?

    V=SQRT((G{Gravity}*M{Mass of Moon})/R{Distance of center of moon to object})

    Hint (WHAT IS Gravity in this case???????) You cant use 6.67*10^11...

    Ultimately I want to have the object start out at a perfect speed to create a perfect orbit at start of layout. Distance will vary, as will mass of each moon and object.

  • Thank you for the OR lesson! I missed that update...   (I was out of touch for about a year, so I missed a bunch of changes.)   That OR box will fix my problem.

  • I want a Condition to check if a variable = 1 OR 5 OR 8 OR 9. I will have about 16 of these conditions, each checking for 3-4 values that vary in each condition... Any Ideas how to do this without writing 4 separate conditions for that one question? (I was thinking there was something like this:

    If Var1=1,

    OR,

    If Var1=5,

    OR,

    If Var1=8,

    OR,

    If Var1=9 -> Do Expression

  • I have decided that a Hash table might do the trick a little better... I am going to try that rout.

  • Hello forum Buddies,

    I have populated an X,Y Array with (Random X coordinate), (Random Y coordinate), and other info about a sprite that will eventually be placed on the screen. So each Y axis line is a new object with x,y coordinates.

    I also created a Dropdown box that lists each object location as ?X,Y?. This box is populated in the for next loop creating the random coordinates.

    How would I do a search of the Array to find the Y line (I need CurY of Array) where X0 = tokenat(List.SelectedText,0,",") and X1 = tokenat(List.SelectedText,1,",")? It would start with-> List: on selection changed

    Example: ARRAY

          X0 , X1

    Y0    213 , 435

    Y1    123 , 654

    Example:Dropdown List

    213,435

    123,654

  • I hate it when I post then find the answer a couple minutes later...   Well, if anyone else need to know, here is a way to do it:

    canvas -> Fill canvas with color -> str("rgb("&INT(random(255))&","&INT(random(255))&","&INT(random(255)))

    str() will make everything in the () into a string. :) Yea, it is coming back to me now... (you can change INT(random(255) to a variable of any kind with an INT value between 0 and 255.)

  • I know this may be a re-cap for some, but I have searched the forums and tried everything... (Been away a while, so I am rusty...)

    How do you select a random color using canvase?

    It wants a string, but "rgba("&random(255)&","&random(255)&","&random(255)&",1)" does not work... (I think because it wants that whole string in quotes, and i dont know how to do that.)

    Thanks in advance!

  • Thanks Yann. I will use this to help me build an array version. If I do It I will post a link :)

  • Thanks Yann. I was hoping someone had a capx handy that I could tear apart. I created a few random maze generators, but not so that they use every cell in a "perfect maze". I would like to build the maze in an array using that sort of algorithm, then display it graphically.

    I know it is not a "simple" event list, but I was hoping someone could post something close that I could manipulate to what I need. Until then I will keep trying on my end.

    BTW, do you think building it graphically then writing to an array would be easier?