User Tag List

Results 1 to 3 of 3

Thread: Ledges!!!!

  1. #1
    Gibdo beefster09's Avatar
    Join Date
    Mar 2006
    Age
    31
    Posts
    699
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    2,710
    Level
    16
    vBActivity - Bars
    Lv. Percent
    97.33%

    Ledges!!!!

    It's a ledge script. Like y'know when you can hop off ledges in LttP and MC and others. Heck, you can even use it for an "automatic jump." I pretty much came up with this for the sake of the player's convenience in my quest-- so the player won't have to go all the way around again.
    Code:
    //Ledge
    //Link will jump off the ledge only when in the specified direction
    //D0: All acceptable directions in a masked format:
    //Up = 1;
    //Down = 2;
    //Left = 4;
    //Right = 8;
    //D1: Minimum direction hold time
    //D2: Sound to be played when hopping the ledge
    //All other properties are absorbed from the ffc, namely EffectHeight and EffectWidth
    const float GRAV=.16; //Insert your game's gravity constant here. (.16 by default)
    
    ffc script Ledge{
    
    	void run(int dir, int hold, int SFX) {
    
    		bool canJump;
    		int counter=0;
    
    		while(true) {
    
    			if((dir & 0001b) != 0) {
    				canJump = Link->InputUp && !Link->InputDown;
    				canJump &&= (Link->X >= this->X-4) && (Link->X <= this->X+this->EffectWidth-12);
    				canJump &&= (Link->Y <= this->Y+this->EffectHeight+8) && (Link->X >= this->X+this->EffectHeight+4);
    				while(canJump && counter<hold) {
    					counter++;
    					Waitframe();
    					canJump &&= Link->InputUp && !Link->InputDown;
    				}
    				counter = 0;
    				if(canJump) {
    					Link->Jump = ((this->EffectHeight+8)/2)*GRAV;
    					Game->PlaySound(SFX);
    					for(int i=0;i<this->EffectHeight+8;i++) {
    						Link->Y--;
    						Link->InputUp = false;
    						Link->InputDown = false;
    						Link->InputLeft = false;
    						Link->InputRight = false;
    						Link->InputA = false;
    						Link->InputB = false;
    						Link->InputR = false;
    						Link->InputL = false;
    						Waitframe();
    					}
    				}
    			} if((dir & 0010b) != 0) {
    				canJump = Link->InputDown && !Link->InputUp;
    				canJump &&= (Link->X >= this->X-4) && (Link->X <= this->X+this->EffectWidth-12);
    				canJump &&= (Link->Y >= this->Y-16) && (Link->Y <= this->Y-12);
    				while(canJump && counter<hold) {
    					counter++;
    					Waitframe();
    					canJump &&= Link->InputDown && !Link->InputUp;
    				}
    				counter = 0;
    				if(canJump) {
    					Link->Jump = ((this->EffectHeight+8)/2)*GRAV;
    					Game->PlaySound(SFX);
    					for(int i=0;i<this->EffectHeight+8;i++) {
    						Link->Y++;
    						Link->InputUp = false;
    						Link->InputDown = false;
    						Link->InputLeft = false;
    						Link->InputRight = false;
    						Link->InputA = false;
    						Link->InputB = false;
    						Link->InputR = false;
    						Link->InputL = false;
    						Waitframe();
    					}
    				}
    			} if((dir & 0100b) != 0) {
    				canJump = Link->InputLeft && !Link->InputRight;
    				canJump &&= (Link->Y >= this->Y-4) && (Link->Y <= this->Y+this->EffectHeight-12);
    				canJump &&= (Link->X <= this->X+this->EffectWidth+16) && (Link->X >= this->X+this->EffectWidth+12);
    				while(canJump && counter<hold) {
    					counter++;
    					Waitframe();
    					canJump &&= Link->InputLeft && !Link->InputRight;
    				}
    				counter = 0;
    				if(canJump) {
    					Link->Jump = ((this->EffectWidth+16)/2)*GRAV;
    					Game->PlaySound(SFX);
    					for(int i=0;i<this->EffectWidth+16;i++) {
    						Link->X--;
    						Link->InputUp = false;
    						Link->InputDown = false;
    						Link->InputLeft = false;
    						Link->InputRight = false;
    						Link->InputA = false;
    						Link->InputB = false;
    						Link->InputR = false;
    						Link->InputL = false;
    						Waitframe();
    					}
    				}
    			} if((dir & 1000b) != 0) {
    				canJump = Link->InputRight && !Link->InputLeft;
    				canJump &&= (Link->Y >= this->Y-4) && (Link->Y <= this->Y+this->EffectHeight-12);
    				canJump &&= (Link->X >= this->X-16) && (Link->X <= this->X-12);
    				while(canJump && counter<hold) {
    					counter++;
    					Waitframe();
    					canJump &&= Link->InputRight && !Link->InputLeft;
    				}
    				counter = 0;
    				if(canJump) {
    					Link->Jump = ((this->EffectWidth+16)/2)*GRAV;
    					Game->PlaySound(SFX);
    					for(int i=0;i<this->EffectWidth+16;i++) {
    						Link->X++;
    						Link->InputUp = false;
    						Link->InputDown = false;
    						Link->InputLeft = false;
    						Link->InputRight = false;
    						Link->InputA = false;
    						Link->InputB = false;
    						Link->InputR = false;
    						Link->InputL = false;
    						Waitframe();
    					}
    				}
    			}
    	
    			Waitframe();
    		}
    	}
    }
    This is a very straightforward script to set up.
    For D0, you add all the numbers together to get your mask.
    For D1, 10-20 are good values. it prevents players from "bumping" off the edge.
    For D2, you'll probably just want the default jumping sound, which is 45.
    Link now jumps over the whole tile and only the tile.
    All input is disabled while hopping off ledges.

    When setting up the ffc, you can extend the ledge by changing the width and height of the ffc. The script absorbs these values from the ffc itself.
    Avatar: Just who the SPAAAACE do you think I am?

  2. #2
    Gibdo Master Maniac's Avatar
    Join Date
    Aug 2007
    Location
    umm in a house
    Age
    32
    Posts
    646
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    2,533
    Level
    16
    vBActivity - Bars
    Lv. Percent
    47.05%

    Re: Ledges!!!!

    nice one beefster =)
    ... i just died a little inside...

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    "this time, of this sixteenth of a thousand lives will be my last, and this curse will be broken. though my fate is to burn in hell, it is worse to live among the thousand lifetimes that i have been sentenced to, than it would be to have satan tear the flesh from my body repeatedly for an eternity"

    --Andross Maximillion Remedy
    (otherwise known as Rem)

  3. #3
    Wizrobe
    Join Date
    Dec 2006
    Age
    29
    Posts
    3,693
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    8,935
    Level
    28
    vBActivity - Bars
    Lv. Percent
    42.94%

    Re: Ledges!!!!

    I've said it before and I'll say it again, this is amazing!
    Quote Originally Posted by rock_nog View Post
    Well of course eveything's closed for Easter - don't you know of the great Easter tradition of people barricading themselves up to protect themselves from the return of Zombie Christ?


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Armageddon Games is a game development group founded in 1997. We are extremely passionate about our work and our inspirations are mostly drawn from games of the 8-bit and 16-bit era.
Social