I reworked the collision function so that it's not direction-stressed, and now I'm working on the collision parameters themselves. I think I'm on to something...


Nah, it doesn't work. I thought maybe if I made it check every four pixels it would stop him, but he just keeps on running.


I'll try again, but I wish I could just have him stop whenever he hits an unwalkable combo.

Code:
import "std.zh"

// ==========================================
// Dash - This script handles the dash boots.
// ==========================================

ffc script Dash{

	int dashforce_maximum;		// The maximum force of the player's Dash.
	int dashforce_current = 0;	// The current force
	int i = 0;				// This counter slows the rate at which
						// dashforce decays, to smooth the dash.

	int dash_pause = 0;		// This counter prevents the player from
						// holding down R for continuous dashing.

	void run(){

                int savedLinkX;
		int savedLinkY;

		while(true){

			

			if(Link->Dir==DIR_RIGHT || Link->Dir==DIR_LEFT || Link->Dir==DIR_UP || Link->Dir==DIR_DOWN){

                                dashforce_maximum = 7;

						}

			else{

				dashforce_maximum = 0;

						}



							
				if( (Link->InputR) && (dash_pause == 0) &&
				


					(!canMove(Link->Y+17, Link->X+16)) ||
					(!canMove(Link->Y+17, Link->X)) ||
					(!canMove(Link->Y+17, Link->X+8)));

			
					{

						dashforce_current = dashforce_maximum;
						dash_pause = 20;

					}

				if(Link->Dir==DIR_LEFT){
					if(dashforce_current > 0){


						if( (!canMove(Link->X, Link->Y+7)) ||
						(!canMove(Link->X+8, Link->Y+16)) ||
						(!canMove(Link->X-8, Link->Y+16))) {
							dashforce_current = 0;
						}
						else {
							Link->X = Link->X - dashforce_current;
							savedLinkX = Link->X;	
							if(i == 2){ 
								i = 0;
							}
							else{
								dashforce_current--;
								i++;
							}
						}
					}
				}
				if(Link->Dir==DIR_UP){
					if(dashforce_current > 0){


						if( (!canMove(Link->X, Link->Y+7)) ||
						(!canMove(Link->X+8, Link->Y+16)) ||
						(!canMove(Link->X-8, Link->Y+16))) {
							dashforce_current = 0;
						}
						else {
							Link->Y = Link->Y - dashforce_current;
							savedLinkY = Link->Y;	
							if(i == 2){ 
								i = 0;
							}
							else{
								dashforce_current--;
								i++;
							}
						}
					}
				}
				if(Link->Dir==DIR_RIGHT){
					if(dashforce_current > 0){
						if( (!canMove(Link->X, Link->Y+7)) ||
						(!canMove(Link->X+8, Link->Y+16)) ||
						(!canMove(Link->X-8, Link->Y+16))) {
							dashforce_current = 0;
						}
						else {
							Link->X = Link->X + dashforce_current;
							savedLinkX = Link->X;	
							if(i == 2){ 
								i = 0;
							}
							else{
								dashforce_current--;
								i++;
							}
						}
					}
				}
				if(Link->Dir==DIR_DOWN){
					if(dashforce_current > 0){
						if( (!canMove(Link->X, Link->Y+7)) ||
						(!canMove(Link->X+8, Link->Y+16)) ||
						(!canMove(Link->X-8, Link->Y+16))){
							dashforce_current = 0;
						}
						else {
							Link->Y = Link->Y + dashforce_current;
							savedLinkY = Link->Y;	
							if(i == 2){ 
								i = 0;
							}
							else{
								dashforce_current--;
								i++;
							}
						}
					}
				}
			
			Link->InputR = false; 	// This is necessary to stop R from 
							// flipping your selected item.


			// Decrement dash_pause as long as you're on the ground.


				dash_pause--;
				if (dash_pause < 1) { dash_pause = 0; }

			
			
			Waitframe();
		} // end of while loop
	} // end of void run


    	// ===================================
	// Collision detection function
	// ===================================
	bool canMove(int x, int y){

		if(Link->InputR){		


				// x=23, y=130
				// Obviously in range...
				if(x<0 || x>255 || y<0 || y>175)
					return false;
				int mask=1111b;
		
				// x % 16 = 7, so
				// mask = 1111 & 0011 = 0011
				if(x%16<8)
					mask&=0011b;
				else
					mask&=1100b;
		
				// y % 16 = 2, so
				// mask = 0011 & 0101 = 0001
				if(y%16<8)
					mask&=0101b;
				else
					mask&=1010b;
	
				// All but the top-right quarter of the combo is solid, so ComboS = 1011
				// mask & ComboS = 0001 & 1011 = 0001
				// The result wasn't 0, so return false
				return ((Screen->ComboS[ComboAt(x, y)]&mask)==0);	
		}
	 }// end of canMove
}// end of ffc script
if(Link->Dir==DIR_UP){
if(dashforce_current > 0){


if( (!canMove(Link->X, Link->Y+7)) ||
(!canMove(Link->X+8, Link->Y+16)) ||
(!canMove(Link->X-8, Link->Y+16))) {
dashforce_current = 0;
}

else {
Link->Y = Link->Y - dashforce_current;
savedLinkY = Link->Y;
if(i == 2){
i = 0;
}
else{
dashforce_current--;
i++;
}
}
and

}
if(Link->Dir==DIR_RIGHT){
if(dashforce_current > 0){
if( (!canMove(Link->X, Link->Y+7)) ||
(!canMove(Link->X+8, Link->Y+16)) ||
(!canMove(Link->X-8, Link->Y+16))) {
dashforce_current = 0;
}

else {
Link->X = Link->X + dashforce_current;
savedLinkX = Link->X;
if(i == 2){
i = 0;
}
else{
dashforce_current--;
i++;
}
}
}
}
are giving me problems. When he dashes right or up, Link goes inside the unwalkable combo before stopping. Any suggestions? I know I need to change the !canMove conditions, but I don't know what I should change them to.
Currently, all four directions are using the same !canMove conditions.

Left and Down seem to be working fine, even on offcenter positions.



EDIT: Funny thing, if you use this code on a side-scroller you can dash in midair. And if you dash up, it's a double-jump! Dashing down doesn't do much, though.