Jump to content


Photo

Making an apple fall properly


  • Please log in to reply
9 replies to this topic

#1 zakaos

zakaos

    GMC Member

  • GMC Member
  • 33 posts

Posted 16 June 2011 - 06:42 PM

For my first project I decided I would use the first tutorial files to make a game, where fruit falls from the sky at random positions and the player runs back n forth to catch them but I'd like to start with the falling apple. I want it to fall from the sky at 1 second intervals falling to the ground maybe with a little bounce then stop. As u can see in it's current state it's more like newtons nightmare: http://www.filedropper.com/applecrazy
  • 0

#2 ParodyKnaveBob

ParodyKnaveBob

    theUndiscovered

  • GMC Member
  • 992 posts
  • Version:GM:Studio

Posted 16 June 2011 - 07:02 PM

LOL!

Howdy, zakaos, and welcome to the GMC. Your file is hilarious! I have an idea that maybe an apple is dropping each game step instead of each second, but it's hard to tell exactly what's going on because you uploaded the .exe instead of the .gm81 source. Try again, and let's see what happens. $:^ ]

Regards,
  • 0

#3 zakaos

zakaos

    GMC Member

  • GMC Member
  • 33 posts

Posted 16 June 2011 - 08:30 PM

Yea I did make it every step, how do I change it to every second?
  • 0

#4 ParodyKnaveBob

ParodyKnaveBob

    theUndiscovered

  • GMC Member
  • 992 posts
  • Version:GM:Studio

Posted 16 June 2011 - 09:12 PM

Did you actually take the tutorials? It should lead you through pretty well through alarms and how to use them. But that's the short answer: alarms. (And a slightly longer answer: set an alarm to room_speed*(number of seconds) and have the alarm then set itself every time it executes; room_speed is the number of steps taken per second, which is why room_speed*(number of seconds) will result in that-many-seconds.) But if you haven't already, please check out the official tutorials! They're very helpful!

Regards again,
  • 1

#5 zakaos

zakaos

    GMC Member

  • GMC Member
  • 33 posts

Posted 17 June 2011 - 06:21 AM

Did you actually take the tutorials? It should lead you through pretty well through alarms and how to use them. But that's the short answer: alarms. (And a slightly longer answer: set an alarm to room_speed*(number of seconds) and have the alarm then set itself every time it executes; room_speed is the number of steps taken per second, which is why room_speed*(number of seconds) will result in that-many-seconds.) But if you haven't already, please check out the official tutorials! They're very helpful!

Regards again,


Wow thanks so much for your help!
what you suggested did exactly what i needed.
my proof of concept is really coming together,
next i need to do something about the way they land,
seen here:
http://www.filedropper.com/applecrazy02

you can see my gm file here:
http://www.filedropper.com/applecrazy_1
  • 0

#6 Diventurer

Diventurer

    GMC Member

  • New Member
  • 732 posts
  • Version:GM8

Posted 17 June 2011 - 08:15 AM

Okay, I have a kind of working way for the apples, but it sucks really bad...
Lol... I am not good with physics :/

Apple:
Create event:
TimesOnGround = 0;
VSPEED = 0;
gravity_direction = 270;

Step:
if (place_free(x, y + 1))
{
    gravity = 0.5;
}
else
{
    gravity = 0;
    hspeed = 0;
}

Collision with object 'Solid'
move_contact_solid(direction, 12);

if (TimesOnGround < 8)
{
    switch (TimesOnGround)
    {
        case (0):
        {
            vspeed = -choose(3, 4, 5);
            VSPEED = vspeed;
            x -= choose(-1, 1, -1, 2);
            image_angle = random(20);
            break;
        }
        
        case (1):
        {
            vspeed = VSPEED + choose(0.5, 1, 1.5, 2);
            hspeed = choose(1, -1, 1, -2);
            image_angle = random(20);
            break;
        }
        
        case (2):
        {
            vspeed = VSPEED + choose(0.5, 1, 1.5, 2);
            hspeed = choose(1, -1, -1, 2);
            image_angle = random(20);
            break;
        }
        
        case (3):
        {
            vspeed = VSPEED + choose(0.5, 1, 1.5, 2);
            hspeed = choose(-1, -1, 1, 2);
            image_angle = random(20);
            break;
        }
        
        case (4):
        {
            vspeed = VSPEED + choose(0.5, 1, 1.5, 2);
            hspeed = choose(0, -1, -1, 1, 2);
            image_angle = random(20);
            break;
        }
        
        case (5):
        {
            vspeed = VSPEED + choose(0.5, 1, 1.5, 2);
            hspeed = choose(0, 1, -1, -1, 2);
            image_angle = random(20);
            break;
        }
        
        case (6):
        {
            hspeed = choose(0, 1, -1, 1, -2);
            image_angle = random(20);
            break;
        }
        
        case (7):
        {
            vspeed = 0;
            hspeed = 0;
            break;
        }
    }
    
    TimesOnGround += 1;
}
else
{
    vspeed = 0;
    hspeed = 0;
}

Be sure to make Solid to solid. Lol.

Edited by Diventurer, 17 June 2011 - 09:17 AM.

  • 0

#7 KaptainKool96

KaptainKool96

    GMC Member

  • New Member
  • 20 posts

Posted 17 June 2011 - 04:15 PM

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ummm... that looks great gut i would just put this is a collision event with the floor:
move_contact_solid(direction,12)
vspeed=0
you do need the floor object and the whatever is falling to be solid. however, this does not have a bouncing effect. i just think a shorter code would be best for first time users.

Edited by KaptainKool96, 17 June 2011 - 04:17 PM.

  • 0

#8 zakaos

zakaos

    GMC Member

  • GMC Member
  • 33 posts

Posted 19 June 2011 - 12:02 AM

So, its comin along thanks to your guys's help.
i started working on making the apples age and decay,

I zipped the executable with the source file,

feel free to check it out if you want.

http://filepak.com/u..._applecrazy.zip

Edited by zakaos, 19 June 2011 - 10:20 PM.

  • 0

#9 zakaos

zakaos

    GMC Member

  • GMC Member
  • 33 posts

Posted 16 July 2011 - 06:25 AM

updated if anyone wants to check it out, coming along nicely,
Play Newton's Nightmare.
  • 0

#10 ParodyKnaveBob

ParodyKnaveBob

    theUndiscovered

  • GMC Member
  • 992 posts
  • Version:GM:Studio

Posted 22 July 2011 - 10:31 PM

Fun. Not sure why random zombies are coming out of the apples... heheh...

I see you're still having trouble with the bouncing...

But the hit detection feels pretty natural at least. ~nodnod~

Okay, bouncing. I just looked at your old v4's bouncing setup, saw what I figured was the problem, and then tried a solution which worked. Is your new v5 using the same (faulty) landing/bouncing setup, or have you tried to change it?

Regards,
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users