Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: Help:GM6.1, goodnight's movement, question:"How do you pull Link toward a hole?"  (Read 3436 times)

0 Members and 1 Guest are viewing this topic.

Koh

Help:GM6.1, goodnight's movement, question:"How ...
« on: December 04, 2006, 09:13:17 pm »
  • Tamer Koh
  • *
  • Reputation: +6/-0
  • Offline Offline
  • Gender: Male
  • Posts: 980
I really want to know this so I can fix up the hole-falling in TLoZ:GBMQ.  PPLLEEAASSEE HHEELLPP MMEE.
« Last Edit: March 01, 2007, 01:21:48 am by 4Sword »
Logged
  • Megaclipse Games

gm112

Re: Help:GM6.1, goodnight's movement, question:"...
« Reply #1 on: December 04, 2006, 10:28:26 pm »
Nice post. Perhaps you can post some code to show us what you're doing?
Logged

Jed

Re: Help:GM6.1, goodnight's movement, question:"...
« Reply #2 on: December 04, 2006, 10:57:30 pm »
move_to_object(obj_hole,global.linkspeed);
Logged

Goodnight

Once and future Captain
Re: Help:GM6.1, goodnight's movement, question:"...
« Reply #3 on: December 05, 2006, 01:00:36 am »
  • With a Capital G
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 706
move_to_object(obj_hole,global.linkspeed);
In a perfect world. What event? Which obj_hole? Where's the code to stop that movement?

My movement engine wasn't designed for gravity, and it would have to be redesigned from scratch for that. First I'd have to make independent movement loops for both horizontal and vertical movement (right now there's just one for both), so that Link can move in 360 degrees and not just 8 directions. Then I'd have to study LTTP and figure out the best sizes and placements for the gravity blocks, how much effect they have, etc.

For now, the best I can suggest is to have an object for each gravity direction, with a mask for each that is just a square (only a few pixels large) in the centre of the 16x16 block, and a parent object for all of them. Give the 8 gravity directions a Collision with objLink event, and set Link's hspeed and/or vspeed to 1 and/or -1. That's a decent enough gravity speed, and should keep Link's position to rounded numbers.

So for example, the Up-right gravity object's Collision with objLink event would have:
Code: [Select]
objLink.hspeed=1;
objLink.vspeed=-1;

[edit]
Just had a thought: for the non-diagonal gravity blocks, it would be a good idea to set the variable that's not used in that direction, to 0. Because if an up-right-gravity block pushed you into an up-gravity block, you wouldn't want to keep moving right.
[/edit]

Then in Link's Step event, add a piece that sets his speed to 0 if he's not touching any of them.
Code: [Select]
if !place_meeting(x,y,objGravityParent) { speed=0; }
« Last Edit: December 05, 2006, 01:06:20 am by Goodnight »
Logged

Jed

Re: Help:GM6.1, goodnight's movement, question:"...
« Reply #4 on: December 05, 2006, 06:40:41 am »
move_to_object() will move it towards the hole object, which is what he asked for. I assume he has the know-how to add it to the player object or use with (obj_player), and a collision event wiht some code for the hole should work as a cancel in my mind.
Logged

Koh

Re: Help:GM6.1, goodnight's movement, question:"...
« Reply #5 on: December 05, 2006, 11:52:09 am »
  • Tamer Koh
  • *
  • Reputation: +6/-0
  • Offline Offline
  • Gender: Male
  • Posts: 980
can someone put it in an engine for me?  I tried doing it like this:

Code: [Select]
if(!falling && !jumping ){
if((x<other.x && x>other.x+8) or (y>other.y && y<other.y+8)){
move_towards_point(other.x,other.y,3)
}
else if((x<=other.x && x>other.x+8) && (y>=other.y && y<other.y+8)){
falling=1
move_towards_point(x,y,0)
moveable=0
sound_play(Fall)
sprite_index=sprLinkFallDownHole
scr_heart_add_fast(-0.25);
image_speed=0.25
image_index=0
}
}
But Link kept on going past the hole and wouldn't fall at all XD.  BTW I'm using GB style so that means the radius would be within 16.
Logged
  • Megaclipse Games
Re: Help:GM6.1, goodnight's movement, question:"...
« Reply #6 on: December 05, 2006, 10:11:03 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1635
You don't have to check for x and y positions. It's silly. You can just check if you are colliding with it, or if you are a certain distance away from the center of the hole. If you are close enough to the hole's center (distance_to_object) or you collide with the hole (place_meeting), then you change link into a falling object.
Logged

Koh

Re: Help:GM6.1, goodnight's movement, question:"...
« Reply #7 on: December 09, 2006, 03:55:38 pm »
  • Tamer Koh
  • *
  • Reputation: +6/-0
  • Offline Offline
  • Gender: Male
  • Posts: 980
OMG so close.  The only directions that aren't working properly are D and R.  Don't mess with U and L code cause they work perfectly.  Please help D work.

Code: [Select]
if(!falling && !jumping) {
    switch(global.facing) {
        case "L":
            if(distance_to_point(other.x+4,other.y-4) > 5){
                move_towards_point(other.x+4,other.y-4,1)
                moveable=0
            }
            break;
        case "R":
            if(distance_to_point(other.x+4,other.y-4) > 5){
                move_towards_point(other.x+4,other.y-4,1)
                moveable=0
            }
            break;
        case "U":
            if(distance_to_point(other.x,other.y-4) > 5){
                move_towards_point(other.x,other.y-4,1)
                moveable=0
            }
            break;
        case "D":
            if(distance_to_point(other.x,other.y-1) > 3){
                move_towards_point(other.x,other.y-1,1)
                moveable=0
            }
            break;
    }
    if(distance_to_point(other.x,other.y+4) < 5 && global.facing="U"){
        x=other.x
        y=other.y
        falling=1
        moveable=0
        move_towards_point(x,y,0)
        sound_play(Fall)
        sprite_index=sprLinkFallDownHole
        scr_heart_add_fast(-0.25);
        image_speed=0.25
        mage_index=0
    }
    if(distance_to_point(other.x,other.y) < 3 && global.facing="D"){
        x=other.x
        y=other.y
        falling=1
        moveable=0
        move_towards_point(x,y,0)
        sound_play(Fall)
        sprite_index=sprLinkFallDownHole
        scr_heart_add_fast(-0.25);
        image_speed=0.25
        image_index=0
    }
    if(distance_to_point(other.x+4,other.y+4) < 5 && global.facing="L"){
        x=other.x
        y=other.y
        falling=1
        moveable=0
        move_towards_point(x,y,0)
        sound_play(Fall)
        sprite_index=sprLinkFallDownHole
        scr_heart_add_fast(-0.25);
        image_speed=0.25
        image_index=0
    }
    if(distance_to_point(other.x+4,other.y+4) < 5 && global.facing="R"){
        x=other.x
        y=other.y
        falling=1
        moveable=0
        move_towards_point(x,y,0)
        sound_play(Fall)
        sprite_index=sprLinkFallDownHole
        scr_heart_add_fast(-0.25);
        image_speed=0.25
        image_index=0
    }
}
« Last Edit: December 10, 2006, 02:30:40 pm by dlbrooks33 »
Logged
  • Megaclipse Games
Re: Help:GM6.1, goodnight's movement, question:"...
« Reply #8 on: December 09, 2006, 05:57:29 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1635
I'll tell you that I'm not going to read that unless you indent it and organize it.
Logged

Koh

Re: Help:GM6.1, goodnight's movement, question:"...
« Reply #9 on: December 09, 2006, 06:12:20 pm »
  • Tamer Koh
  • *
  • Reputation: +6/-0
  • Offline Offline
  • Gender: Male
  • Posts: 980
done, and its actually down and right thats not working.  Up and Left work perfectly.
Logged
  • Megaclipse Games
Re: Help:GM6.1, goodnight's movement, question:"...
« Reply #10 on: December 10, 2006, 12:55:55 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 1635
*ugh* No, you didn't clean it up. I'll do it for you.

Code: [Select]
if(!falling && !jumping) {
    switch(global.facing) {
        case "L":
            if(distance_to_point(other.x+4,other.y-4) > 5){
                move_towards_point(other.x+4,other.y-4,1)
                moveable=0
            }
            break;
        case "R":
            if(distance_to_point(other.x+4,other.y-4) > 5){
                move_towards_point(other.x+4,other.y-4,1)
                moveable=0
            }
            break;
        case "U":
            if(distance_to_point(other.x,other.y-4) > 5){
                move_towards_point(other.x,other.y-4,1)
                moveable=0
            }
            break;
        case "D":
            if(distance_to_point(other.x,other.y-1) > 3){
                move_towards_point(other.x,other.y-1,1)
                moveable=0
            }
            break;
    }
    if(distance_to_point(other.x,other.y+4) < 5 && global.facing="U"){
        x=other.x
        y=other.y
        falling=1
        moveable=0
        move_towards_point(x,y,0)
        sound_play(Fall)
        sprite_index=sprLinkFallDownHole
        scr_heart_add_fast(-0.25);
        image_speed=0.25
        mage_index=0
    }
    if(distance_to_point(other.x,other.y) < 3 && global.facing="D"){
        x=other.x
        y=other.y
        falling=1
        moveable=0
        move_towards_point(x,y,0)
        sound_play(Fall)
        sprite_index=sprLinkFallDownHole
        scr_heart_add_fast(-0.25);
        image_speed=0.25
        image_index=0
    }
    if(distance_to_point(other.x+4,other.y+4) < 5 && global.facing="L"){
        x=other.x
        y=other.y
        falling=1
        moveable=0
        move_towards_point(x,y,0)
        sound_play(Fall)
        sprite_index=sprLinkFallDownHole
        scr_heart_add_fast(-0.25);
        image_speed=0.25
        image_index=0
    }
    if(distance_to_point(other.x+4,other.y+4) < 5 && global.facing="R"){
        x=other.x
        y=other.y
        falling=1
        moveable=0
        move_towards_point(x,y,0)
        sound_play(Fall)
        sprite_index=sprLinkFallDownHole
        scr_heart_add_fast(-0.25);
        image_speed=0.25
        image_index=0
    }
}
Logged

Goodnight

Once and future Captain
Re: Help:GM6.1, goodnight's movement, question:"...
« Reply #11 on: December 10, 2006, 01:21:23 am »
  • With a Capital G
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Gender: Male
  • Posts: 706
Arright...

0) The reason I didn't suggest move_towards_point() is because it moves the object to positions that aren't whole numbers, which the point of my engine was to avoid, but whatever, use this if it works for you.

1) We can't tell why it isn't working by just your code. It seems you're using +4's and >5's and such to account for the mask sizes. Since I don't see that info anywhere, we'd need to debug the game in action to tell what "doesn't work" and why.
Logged

Koh

Re: Help:GM6.1, goodnight's movement, question:"...
« Reply #12 on: December 10, 2006, 02:28:03 pm »
  • Tamer Koh
  • *
  • Reputation: +6/-0
  • Offline Offline
  • Gender: Male
  • Posts: 980
well I am using GB style, which means the sizes are 16x16.  x+4 and y+4 would be the center of the hole (x+8 and y+8 was too far). the >5 was to show if he is one pixel to far, so pull him toward the hole.  the <5 was to see if he was within the 4c4 position.  and the last part was to put him equal to the holes x and y and make him fall.  But D and R won't cooperate with it :(.
Logged
  • Megaclipse Games
Re: Help:GM6.1, goodnight's movement, question:"...
« Reply #13 on: December 10, 2006, 07:09:13 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 2890
Goodnight's engine is NOT meant to simulate GB style - it's strictly LTTP. Just consider that.
Logged

Koh

Re: Help:GM6.1, goodnight's movement, question:"...
« Reply #14 on: December 10, 2006, 10:10:41 pm »
  • Tamer Koh
  • *
  • Reputation: +6/-0
  • Offline Offline
  • Gender: Male
  • Posts: 980
you can easily use his engine for GB.  just change the distance to a little lower than what it alreayd is and make sure teh collision points are 16x16 ;).
Logged
  • Megaclipse Games
Re: Help:GM6.1, goodnight's movement, question:"...
« Reply #15 on: December 10, 2006, 10:14:52 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6206
If you would just have made your own movement engine you wouldn't have so much problems...
Logged
Re: Help:GM6.1, goodnight's movement, question:"...
« Reply #16 on: December 10, 2006, 10:21:59 pm »
  • علي
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 205
If you would just have made your own movement engine you wouldn't have so much problems...
I don't think everybody knows GML so they just use the interface to make there games
so a little help probably would be apreciated cause that post was helpfull in no way and you
shouldn't post anything if you won't post something helpful

dlbrooks33: since the sprites are smaller in your gameboy version if all you did was replace the original MC ones with your GB ones
you are bound to have problems with collison so try learning the code or at least fix the size so that you won't have problems in the future
Logged
علي
  • alirazaq.com

Koh

Re: Help:GM6.1, goodnight's movement, question:"...
« Reply #17 on: December 12, 2006, 09:53:20 pm »
  • Tamer Koh
  • *
  • Reputation: +6/-0
  • Offline Offline
  • Gender: Male
  • Posts: 980
oh trust me I didn't change from MC to GB.  I actuallly changed the interface from being like +4 to +2 since MC is close to being 2x larger than the  GB Link.
Logged
  • Megaclipse Games
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.319 seconds with 74 queries.

anything