Jump to content


goldage5

Member Since 25 Jan 2010
Offline Last Active Mar 26 2013 01:00 PM

Posts I've Made

In Topic: Free Music For Your Games

02 December 2012 - 08:53 PM

@goldage5 you haven't really given me much to work off, but here goes:


Thanks! That fits perfectly with my game.



In Topic: Free Music For Your Games

01 December 2012 - 10:55 PM

Mood: Dark, Suspenseful
Length: 3-4 minutes
Speed: Medium
Looped: Yes
Description of game style: The game is set in an alternate universe called The Dark Zone.
Preferred format: Can I have an OGG and an MP3 file for it please? Thanks.
Instruments: It would be really cool if you could put some human voices in there. I'll leave the rest up to you. Thanks.

Can you PM the link to me when you are done? Thanks.

In Topic: Tlighting[2.4] Gm: Studio

07 November 2012 - 08:17 PM

Is there a way to test the intensity of the light at a particular point?

In Topic: Gravity to Multiple Objects

04 October 2012 - 06:33 PM

Can anyone help me with a collision checking system for this?

Thanks.

In Topic: Gravity to Multiple Objects

24 September 2012 - 07:08 PM

Sure! Let's start with Newton's law:


Posted Image

As shown by this equation, the force which gravity has on an object is equal to
the constant of gravity, multiplied by the two masses multiplied by each other and
divided by their distance squared.

So, we already have the values we want to work with: you can easily assign "mass" variables
to your objects based on their apparent size, you can set a constant for gravity (DON'T use GM's -
set your own variable, this is just for the math), and you can know the distance squared by doing
power(point_distance(x1,y1,x2,y2),2).

Essentially, you need to set up a loop in which one object adds force to itself based on doing this
same equation with all of the other objects in the room. You can find all other gravity-inducing bodies
by doing something like this:

{

    grav = 0.25;


    var a, b, m1, m2, dist;
    for (a = 0; a < instance_number(obj_planet); a += 1)
    {
        b = instance_find(obj_planet,a);
        
        if !(b == id or b == noone)
        {
            m1 = mass;
            m2 = b.mass;
            dist = power(point_distance(x,y,b.x,b.y),2);
            motion_add(point_direction(x,y,b.x,b.y),grav*((m1*m2)/dist));
        }
    }
}

First, I set "grav" to 0.25, representing our constant for gravity (which, again, cannot
be the one set by Game Maker.) Then, I run through all of the instances of "obj_planet"
in the room - you would replace this with whatever you want to apply gravity to. If the instance
found is the instance doing the checking or "noone" (another GM constant), then the loop should
ignore it, as otherwise we will receive errors. Then, we get the mass of the first and second objects
(you should have set this already), and the distance squared. Finally, we run the formula. Please note
that this code assumes some kind of collision detection - if dist is 0, then you will get a division by 0.

This code also assumes that the object running it is an instance of obj_planet.
How does this work for you?


That works brilliant, thanks. However, how can I add a collision thing that works? I tried doing what I normally do, which is x=xprevious, and y=yprevious, but that just got them stuck on each other, with ones shooting out of the blob of asteroids occasionally.