|
« Reply #2 on: October 20, 2009, 10:07:51 pm »
|
|
(I'm learning GML as I go lol) Now then: This is Goodnight's pushing code which is found in his objLink: // Wall-pushing detection code. // Just to clarify, Link's pushcount activates his pushing animation, // while the block's pushcount activates its movement.
// If you weren't moving diagonally, and weren't able to move, check for a solid for Link to push. var pushblock; pushblock=0 // Determine the id of the solid block in front of Link (if there is one). if !(holdd || holdu || fholdd || fholdu || place_free(x+xstep,y)) { pushblock=collision_point(x+xstep*8+(xstep>0)*16,y+8,parSolid,0,0) } else if !(holdl || holdr || fholdl || fholdr || place_free(x,y+ystep)) { pushblock=collision_point(x+8,y+ystep*8+(ystep>0)*16,parSolid,0,0) } // If there is a solid, increase Link's pushcount (to a maximum of 16). if pushblock>0 { pushcount=min(pushcount+1,16) // Set the alarm to reset the pushcount to 0 when Link stops moving. alarm[7]=2 // If the solid is pushable, and Link is fairly in-line with it, if object_get_parent(pushblock.object_index)=parPushable && ((ystep=0 && abs(pushblock.y-y)<=4) || (xstep=0 && abs(pushblock.x-x)<=4)) { with pushblock { // and it's not already moving, if !moving { // and it can be pushed in the direction Link is facing, movedir=global.facing if movesa>0 || (movedir="D" && movesd>0) || (movedir="U" && movesu>0) || (movedir="L" && movesl>0) || (movedir="R" && movesr>0) { // then increase its pushcount. pushcount=min(pushcount+1,16) alarm[7]=2 } } } } }
// Set the right sprite when you are moving. // If Link has been pushing for at least 15 steps, use the pushing animation. if pushcount>=15 { switch global.facing { case "D": sprite_index=sprLinkPushD; break; case "U": sprite_index=sprLinkPushU; break; case "L": sprite_index=sprLinkPushL; break; case "R": sprite_index=sprLinkPushR; break; } // (Which is slightly slower than the running animation.) image_speed=animspeed*0.7 // Otherwise, use the running animation. } else { switch global.facing { case "D": sprite_index=sprLinkRunD; break; case "U": sprite_index=sprLinkRunU; break; case "L": sprite_index=sprLinkRunL; break; case "R": sprite_index=sprLinkRunR; break; } image_speed=animspeed } // If Link is not moving this step, } else { // Set the right standing sprite. switch global.facing { case "D": sprite_index=sprLinkStandD; break; case "U": sprite_index=sprLinkStandU; break; case "L": sprite_index=sprLinkStandL; break; case "R": sprite_index=sprLinkStandR; break; } movestep=0 }
// Almighty depth leverage technique depth=-y
This code was placed last on my objLink so it wouldn't get expected and or unexpected errors(which I fixed) . fhold could be found in my step event which is for movement like this(mainly for Corner-cutting loop if Link is being blocked by solids also the movement keys of Deku and human Link): // Start doing the movement. while (movestep>=1) { movestep-=1 fholdd=0; fholdu=0; fholdl=0; fholdr=0; Yet this code comes before Goodnight's code and the fhold are already called, if not the objDekuLink wont be working. WE all know the cut conner code and I'm guessing that this is whats causing the error. I had this called 4 times: 2 in scr and 2 in both objDekuLink and objLink: var cc; for (cc=6; cc>0; cc-=1) { if holdu { if !place_free(x,y-1) { if place_free(x-cc,y-1) && !(holdr || fholdr) { fholdl=1 } else if place_free(x+cc,y-1) && !(holdl || fholdl) { fholdr=1 } } } else if holdd { if !place_free(x,y+1) { if place_free(x-cc,y+1) && !(holdr || fholdr) { fholdl=1 } else if place_free(x+cc,y+1) && !(holdl || fholdl) { fholdr=1 } } } if holdl { if !place_free(x-1,y) { if place_free(x-1,y-cc) && !(holdd || fholdd) { fholdu=1 } else if place_free(x-1,y+cc) && !(holdu || fholdu) { fholdd=1 } } } else if holdr { if !place_free(x+1,y) { if place_free(x+1,y-cc) && !(holdd || fholdd) { fholdu=1 } else if place_free(x+1,y+cc) && !(holdu || fholdu) { fholdd=1 } } } } What I'm doing to do now: I'm going to change the setups of how the fhold functions are into more movement; the after effect was that Link cannot push anything that is parsolid and or grabs or pushables.A question: How is the error coming up if the fholds are being called BEFORE the code is taken into action? PS: I added extra conner cutting into scr, making the game place more smooth, fholds can be found there as well but the action is preventing the play due to objLink's fatal error. You'd be able to not run into these errors if you made the attempt to understand what was going on; rather than simply merging engines all wishy-washy. The error you are getting likely refers to the values of fhold not getting initialized to anything before the error message/location you get. You cannot determine whether or not fhold values are true or false since they are not set to anything. there not set as true or false values in this situation, aslo I did try some other methods to make the pushing actucally work.
« Last Edit: October 20, 2009, 10:19:03 pm by Linkwolf48 »
Logged
|
|