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: Link Platforms & Bouncing  (Read 5242 times)

0 Members and 1 Guest are viewing this topic.
Link Platforms & Bouncing
« on: January 05, 2010, 01:35:17 pm »
  • *
  • Reputation: +8/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6604
First things first, I removed the rolling and Niek's bow and arrow for the time being because him and I are working out a possible change to how movement works and how those things would be considered. Otherwise though, after that downer, there are some updates to this project.

The ledge jumping has been improved so that Link's jumping is more of a parabola instead of sloped triangles. Additionally with that ledge jumping, the next free space is calculated before the jump so that it doesn't have to be checked each step as Link moves along his set path. This is to prevent wasteful place checking over longer distances. I also fixed up an error in the diagonal movement set the step_x and step_y equal to each other if Link was just moving that way; it should strictly be if both speeds are at their maximums.

I did add some new stuff though! I have it so that when Link falls into a pit, the view will go back onto him just how it happens in the actual game. I also added horizontal and vertical platforms, an object you can bouncing against, etc. It might not seem like a lot, but I checked it and the system I came up with allows you to jump off of ledges onto moving platforms, standing on platforms which run into things that can push you off, and a lot of other combinations like that. Not only that, but I went into the code and FULLY COMMENTED it with descriptions which should say what's going on as the code is processed.

Anyway, images:

from left to right, improved ledge-jumping, platform riding, bouncing

A download of the engine is available on its project page (the format for the time being is GM7, the engine is compatible with GM8 though more than likely):
http://www.zfgc.com/index.php#?action=games&sa=view&id=128
Logged
Re: Link Platforms & Bouncing
« Reply #1 on: January 05, 2010, 02:14:35 pm »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3374
Firstly, this is really quite awesome. The ledge jumping has improved heaps, the parabolic motion looks so much better than the previous triangular.
The platform riding works rarther nicely. With the bouncing, does it work with round edged blobs as well? If I remember in the FS from LTTP/FS game there were bouncing jellies like that which had slightly rounded corners. You had to charge through them with pegasus boots.
Logged
Quote from: Jason
Your community is a bunch of stuck up turds.

pxl_moon (dotyue)

Team Dekunutz
Re: Link Platforms & Bouncing
« Reply #2 on: January 05, 2010, 06:20:04 pm »
  • .越//
  • *
  • Reputation: +5/-1
  • Offline Offline
  • Gender: Male
  • Posts: 2280
I don't know about you guys but i thought that the wall-placefiller were a little to dark and to near to the color of the hole-placefillers i just recolored it i think its better viewable so



for the platforms:
should it be that one is nearly under an bouncing object and the other complete under a wall?
Logged

~~Resources~~
~Minish Cap Style~

Minish Cap Beta:Firerod Icon, Majoras Mask:ChuChu, Ocarina of Time:Gossip Stone, Oracle Series:Link plays the "Herpes of Ages", Impa, Wand Maker: HUD
~GB-Zelda Style~
Ocarina of Time: Deku Caca
~Other~
Paper Mario Style Zelda&Link, Tetra Trackers HUD-Cleanups

Re: Link Platforms & Bouncing
« Reply #3 on: January 05, 2010, 07:44:51 pm »
  • *
  • Reputation: +8/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6604
Darklight:

The bouncing would probably work alright with a round bounce object, although I am not fully certain as for this engine I ended up changing Link's collision mask to be rectangular instead of precise collision checking with the mskShadow. This was done because when there is a ledge right next to a wall, if you are corner-cutting off of the wall and your ledge jump is activated, it'll mess up your descent. I had that mostly figured out, but it also involved calculating the abs(x - xprevious) and abs(y - yprevious) for how much you move in the direction of motion increasing your dist_a, and how much you move perpendicular altering the animation rate. A key problem that didn't go away was that if you were moving diagonally at the corner of a wall and it triggered the ledge jump, you'd be able to jump in place or appear stuck. Basically what I ended up going with was a lot simpler and more efficient.

However, even with Link having a rectangular mask, if the bounce object has a circular one, it would not be that difficult to run into it when you're moving diagonally - it should trigger the bounce_check_x and bounce_check_y which will move Link diagonally. Originally I was using one of RyuKage2007's MC Sea Urchins for my bounce object which would also decrement a hearts system I had going, lol. Also though, yeah, besides diagonal bouncing, I am pretty sure that using some sort of direction based sine or cosine measurement that the diagonal bounce can be made to appear more radial. Seems kind of easy actually.

dotyue:

Ha, originally I had the walls the same color as Link's shadow, so I darkened the walls to just be another shade of gray. Red looks better though I have to admit. But yeah, about the platforms, the one that moves vertically is meant to go under the solid object. The horizontal platform only went half the distance under the bounce object, well I don't really know exactly why I did it like that. I was probably using the hole on the bottom near it as a way to adjust the falling animation so that it's origin was set correctly. More over I guess I just wanted to have one that cleared Link off completely and one which only knocked him off if he stood in a certain position on the platform.
Logged
Re: Link Platforms & Bouncing
« Reply #4 on: January 07, 2010, 05:48:27 am »
  • *
  • Reputation: +8/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6604
I found an oversight in the way my code works. For example, if you have a down ledge that has it so you can land on a horizontal platform - if you are moving up while the platform is moving, Link will try to corner-cut around the wall objects which surround the ledge. This causes a problem in that the corner-cutting is either moving Link sometimes faster towards the direction of motion or faster away from it; when it's away it cancels out the motion so he'll just be running in place.

There is actually an easy way to fix this. It would involve splitting up the wall objects into those "with corners" and those "without corners". A lot of walls won't have the corners which under the current solid_check functions in the engine, the way the code is written it will first check to see if the object is met, then see if it can corner-cut around it, and then see if it is still meeting the original object (for it the corner-cutting doesn't work, if it does Link is no longer colliding with the wall). For objects that don't have to be corner-cut around, all the code you really need is to determine that you're hitting the object then back up.

Also, I was messing around with the view code and some of the move code. With the view code I basically figured out that I could make it so instead of the outsides of the room being what limits the view, I could make it so it could be any value. This would be for things like the fairy fountains in Minish Cap which alter the view as you get closer to them or for moving between rooms in a dungeon.
Logged

Mamoruanime

@Mamoruanime
Re: Link Platforms & Bouncing
« Reply #5 on: January 07, 2010, 07:02:20 am »
  • ^Not actually me.
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 9786
Another issue (although you may have been implying this as well) is that when you have 2 moving platforms near each other, moving at varied speeds (in messing around with the source, I modified the platforms to accept the move_s as a per-instance variable, instead of a static instance var), link will clip both of them, and follow the platform with the highest ID. It basically makes it really easy to walk across a row of moving platforms by simply standing on the edge of the first so the next carries you.

Either way, it's pretty fun to make a row of vertical platforms with varied speeds, because it's actually pretty challenging to walk across them without falling into a hole :P

On a side note, woooooh random input from Mammy XD
Logged
Re: Link Platforms & Bouncing
« Reply #6 on: January 07, 2010, 07:16:47 am »
  • *
  • Reputation: +8/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6604
I was thinking about using the Room Creating event as a means to create platforms with differing characteristics while having the variables in their creation events be the defaults. Although, the variables in the creation events can also be assigned values through use of a random function.

I knew about that a bit because of the way the detection of the platform works; using place_meeting rather than some wacky use of the platform object seeing if Link is position_meeting with the platform. It also seems though that I forgot to adjust the mask of the platform object so that the issue is avoided less (it creates "gaps" between platforms that Link can still cross between); when I was coding it in GM8 there were different sprite collision settings, and when I went back to GM7 I forgot to do the adjustment.

Additionally though, when the platform's move speed is set to something that isn't a factor of 16, the platform will still go back and forth, but it will overshoot the stopping distance by just a bit. For example, if the move speed is 3, since the platform is moving in increments of 3 it will go from 15 to 18 where 18 is 2 away from where it should have stopped. Correction code for this would not be that difficult to implement, but I was just being lazy; platforms moving at a speed of 3 are pretty quick though for them to be used in-game.
« Last Edit: January 07, 2010, 07:18:36 am by 4Sword »
Logged
Re: Link Platforms & Bouncing
« Reply #7 on: January 07, 2010, 02:20:51 pm »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3725
Damn, that looks really good. I did find one additional error. When you come from a ledge jump and you land on ice Link will immediately stand still instead of sliding a bit. That is because of this bit of code in the draw event:

Code: [Select]
if (dist_c){
        //stop and show "land" sprite
        dist_c = 0; move_x = 0; move_y = 0;
        image_speed = 0; image_index = image_number - 1;
}

You can fix this by changing it to:

Code: [Select]
if (dist_c){
        //stop and show "land" sprite
        dist_c = 0;
        move_x = (direction == 0) - (direction == 180)
        move_y = (direction == 270) - (direction == 90)
        image_speed = 0; image_index = image_number - 1;
}

EDIT:
About the platforms. I would have made 1 completely generic platform. Because in the game hardly any platform is the same, thus you either make a few hundred different platform objects or you give additional specs to the platform in the room creation code.

I prefer the latter option. I would make the platform in a manner that it has a list of points/directions to follow. Each time he has reached a point or followed a direction for a certain amount of time, he would go to the next on in the list. End when it reaches the last in the list it would start over. This way it is possible to make with 1 platform object a platform with a simple horizontal or vertical path or a platform with a complex path.

Or something like it. I saw that GM8 has Lists data structures, but I don't know about GM7. GM7 is a acting difficult with me at the moment.

EDIT2:
I guess I know now what Mammy means, because the attached image looks weird.
« Last Edit: January 07, 2010, 03:56:37 pm by Niek »
Logged
Re: Link Platforms & Bouncing
« Reply #8 on: January 07, 2010, 04:02:39 pm »
  • *
  • Reputation: +8/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6604
I was kind of peeved with GM8 because when I imported a version of the engine I was working on from GM7, the constants I had in GM7 were still there, I just couldn't access them because GM8 has constants as a registered feature.

About the ledge-jumping onto ice, it'd be helpful to know if there is a place in the game where sliding after jumping onto ice can be observed. I did some quick testing just now with the actual game to where I used a jump anywhere cheat code to jump off a ledge onto ice and when that is done Link doesn't move when landing. I don't know if that is just due to the code, but the point being that if it's not in the Minish Cap game or the situation never appears in the game we don't have to code it.

The platforms were just put in to show that the concept was plausible. At one point I had a platform which moved and cycled through 90 degree turns, and was working on one that would move randomly in a set space. The code gets a little more complicated when you have a platform that moves in x and y directions because the trick I used with the directional incrementation doesn't work too well with that and you have to check more variables or whatnot. I've though about adding a platform that just moves without stopping around solid objects that it borders though and will try adding that in. Either that or platforms that move a certain distance and then turn (independent of the starting position). Most platforms that I remember from Minish Cap though were vertical or horizontal.

Oh, and I used this in a Room Creation code:
Code: [Select]
var plat_o;
plat_o = instance_create(96,144,objPlatH);
with (plat_o){
  direction = 0;
  move_s = 1;
  dist_x = 2;
}
plat_o = instance_create(96,176,objPlatH);
with (plat_o){
  direction = 180;
  move_s = 1;
  dist_x = 2;
}
There would easily be a way to read information from a file so that multiple platforms could be created and their values set from read-in information.

Oh, and like I said about the platforms, the solution is just altering bounding box of the platform mask. I forgot to do it in the GM7 file. All you have to do is set the bounding box properties to manual and then set it up like Left: 3, Top: 3, Right: 28, Left: 28. Something like that'll get the job done. There is still some pushing the ledge can do to Link if he's on "dry land" but that can be remedied by just further tweaking of the bounding box until it is alright.
Logged
Re: Link Platforms & Bouncing
« Reply #9 on: January 08, 2010, 08:25:43 am »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3725
I was kind of peeved with GM8 because when I imported a version of the engine I was working on from GM7, the constants I had in GM7 were still there, I just couldn't access them because GM8 has constants as a registered feature.
Hmm, I don't have a problem with 8. I can still work with constants like in GM7. They just aren't found under Global Game settings anymore. Instead you have to look under Resources. Took me hours to figure that out  :( In "What is new" it was mentioned that the constants had there own form. It would have been nice if they mentioned where you could find it (Shift-Ctrl-N).

About the ledge-jumping onto ice, it'd be helpful to know if there is a place in the game where sliding after jumping onto ice can be observed. I did some quick testing just now with the actual game to where I used a jump anywhere cheat code to jump off a ledge onto ice and when that is done Link doesn't move when landing. I don't know if that is just due to the code, but the point being that if it's not in the Minish Cap game or the situation never appears in the game we don't have to code it.
I can't find such a place anymore. I thought I found one the last time, but it also could be that I was mistaken with something else. A well, it doesn't really matter. If anyone wants to add it, it is just changing 2 lines of code.
Logged

Mamoruanime

@Mamoruanime
Re: Link Platforms & Bouncing
« Reply #10 on: January 08, 2010, 08:30:53 am »
  • ^Not actually me.
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 9786
Just grabbing a small snippet to reply to-

Most platforms that I remember from Minish Cap though were vertical or horizontal.

I'm pretty sure he means just having a generic platform, and leaving the actual path a per-instance variable. So for example, you can have Platform A that goes from 0,0 to 0,128, and then Platform B that goes from 16,0 to 256,0 without having 2 separate objects. I don't imagine there's really any need to have them go at an angle or anything along those lines, but while MC doesn't do that, it doesn't hurt to inadvertently code in the support for that sort of functionality.

EDIT: Uploaded a small edit of the engine to show what I mean with the platforms collision being a bit strange.
« Last Edit: January 08, 2010, 08:48:40 am by Mamoruanime »
Logged
Re: Link Platforms & Bouncing
« Reply #11 on: January 08, 2010, 08:42:18 am »
  • *
  • Reputation: +8/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6604
There was also an additional bug that could be triggered although it's harder to do. If you hit a bounce object into a pit a certain way, your death animation will be moving as if Link bounced to his death. The way to fix this is to simply have the hole_check set the slip_x and slip_y to false (or 0, they're pretty much the same).

Oh, and if that is what you guys were talking about with having the platforms like that, with the distances set like that, it'd probably make a little more sense to do that. Under the current model, there is an absolute value calculation done and the platform always starts out in the center of its path. If done the other way, all that'd be checked would be the x or the y and the platforms would start out near where you're able to get onto them. But about adding it extended functionality going above and beyond sometimes takes away from working on other parts.

Oh and unrelated, but I finally discovered the use of the script_execute function. I have all the states larger than 0 represented by scripts which do the drawing. In the Draw Event for the Link object, the code then looks like this:
Code: [Select]
if (state) script_execute(state);
else{
  ...
}

in the Creation Event I can just do something like state = LinkNorm, which LinkNorm is the script for the draw event of Link's normal actions of walking and standin. The script name without the parenthesis after the name represents the script id which for most things will be positive integer numbers. Doing the code like this allows primary Link actions to be added in more easily, makes it so if you have a lot of actions you won't have to go through cases in a switch statement to figure out which one to go with, and it gives the state values meaningful names.
Logged

Mamoruanime

@Mamoruanime
Re: Link Platforms & Bouncing
« Reply #12 on: January 08, 2010, 08:52:00 am »
  • ^Not actually me.
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 9786
:P You should check out my pureLA source... It makes a ton of use from that function XD It works nice :P

Actually; I'll upload it here simply because it has an example of minimal objects for multiple uses that might come in handy-
Logged
Re: Link Platforms & Bouncing
« Reply #13 on: January 08, 2010, 08:52:25 pm »
  • *
  • Reputation: +9/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3725
Oh, and if that is what you guys were talking about with having the platforms like that, with the distances set like that, it'd probably make a little more sense to do that. Under the current model, there is an absolute value calculation done and the platform always starts out in the center of its path. If done the other way, all that'd be checked would be the x or the y and the platforms would start out near where you're able to get onto them. But about adding it extended functionality going above and beyond sometimes takes away from working on other parts.
What Mammy said is what I meant, yeah but also with 4, 5, 6 or even more points it goes to. It is done in the Minish Cap. The Palace of Winds on 3F you have such a platform that has a more complex path.

Oh and unrelated, but I finally discovered the use of the script_execute function. I have all the states larger than 0 represented by scripts which do the drawing.

A nice idea, that I just implemented with the Bow & Arrow code. See PM for it. Next to the draw event I also made it for the key events.

I just need to port it all to GM7 again, but I'm still fighting with it. And GM7 is winning :'(
Logged
Re: Link Platforms & Bouncing
« Reply #14 on: January 08, 2010, 09:47:30 pm »
  • *
  • Reputation: +8/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6604
Yeah, I read over your PM, the move_halt idea seems like it has promise and the revision to the while loop stuff I had for moving Link to a grid space was a lot more efficient. I think that it showed up in an earlier code example you had, I just didn't understand it or forgot about it when I was working on an impromptu code session.

Anyway, about the GM7/GM8 stuff, yeah if you want to have it all in GM8 that'd be fine (not sure about what your last sentence meant); I can't access the constants menu though because it is now a registered feature, although technically speaking if you were to add constants I would still be able to use them, just not edit them.

Edit: Oh, and view code, it can be moved to its own little code block outside of the code block that contains the movement code. You just have to be sure to remember to move the local view_w/view_h to the other block; the view code in itself doesn't use anything involving the move_x/move_y so it should be alright.
« Last Edit: January 08, 2010, 10:27:28 pm by 4Sword »
Logged
Re: Link Platforms & Bouncing
« Reply #15 on: September 14, 2011, 07:00:44 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 5
Hi!
I took a look at your code! Cool work!
I have a question:
The moving platforms use the following step event code: (i removed the comments for shortening)
Code: [Select]
var dire_x;
if (abs(x - xstart) >= dist_x * 16) direction += 180 / turn_c;
dire_x = ((!direction) - (direction == 180)) * move_s;
x += dire_x;
if (place_meeting(x,y,objLink)){
  with (objLink){
    if (state){
      x += dire_x;                                                                           <<<<<<<<<<<<<THIS LINE
      solid_check_x(dire_x,0,height_f,parSolid);
      bounce_check_x(dire_x,maxi_x * 2,objBounce);
    }
  }
}

The place i marked your using the variable dire_x. Your in an With (objLink) do so your using variables from the objLink object. but this variable gehts NEVER anywhere set for objLink, it does not even show up in debug window -> local variables -> objLink.
It makes me cracy. How does this work?

mfg
Logged
Re: Link Platforms & Bouncing
« Reply #16 on: September 15, 2011, 12:41:43 am »
  • *
  • Reputation: +8/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6604
Ha, I haven't actually looked at this code in a very long time. The dire_x variable won't show up in the debug window because it is a local variable to the piece of code it is called from (it isn't defined for objLink overall). The value of dire_x is either a -1 or a 1 (!direction - direction == 180 means that since direction == 0 will only cause !direction to be true). I may have improved the code overall though, my old computer's video card stopped working so I lost access to a good portion of the upgrades I had made to it (I think I figured out a way to avoid the place_meeting).
Logged
Re: Link Platforms & Bouncing
« Reply #17 on: September 17, 2011, 11:52:59 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 5
Im still confused about how this works.
I tried this:
Code: [Select]
if place_meeting(x+4*dir,y,obj_mp_return) {dir = dir * -1;} else {x += 4*dir;}
with (obj_Link) do {x += 4* dir;}

And it seems not to work (unknown variable: dir)
The error is the one i would also suspect to get from your code.
But i'm not able to find out why your programm is fine with your code^^

Please correct if i understood something false:
1) Variables (if not global) are stored for every instance of an object.
2) if i do the following, it should not work:
Code: [Select]
//i am obj1
thisvar = 123;
with (obj2) do {x += thisvar;}
because im in the with-do i could only use variables known by the instance of obj2. because thisvar is only known by obj1.

From my View it looks like your code does something like 2)'s example. I searched the whole code of your project.
dire_x gets no where defined for objLink. If my 1) would be correct, you should not be able to use dire_x in with (objLink) do {}

Sorry if im stupid but my brain does not understand this^^
Logged
Pages: [1]   Go Up

 


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



Page created in 0.029 seconds with 73 queries.