Ejemplo n.º 1
0
/*
 * void encrypt_string( STRING *sstr, STRING *estr, int shift )
 *
 * Performs encrypting on a single string. Both the source string
 * (sstr) and the container (estr) must be valid.
 * Additionally a custom shift value can be passed.
 *
 * Another variant using the default shift macro (__SHIFT) can be found below.
 */
void encrypt_string( STRING *sstr, STRING *estr, int shift )
{
	if( !sstr || !estr )
		return;

	sstr = str_create(sstr);
	estr = str_create("");

	STRING *buffer = "";
	int counter = 0;
	int temp_val = 0;
	int length = str_len(sstr);

	while( counter < length )
	{
		str_cpy(buffer, sstr);
		str_clip(buffer, counter);
		str_trunc(buffer, length - counter - 1);
		temp_val = str_to_asc(buffer) + shift;
		str_for_asc(buffer, temp_val);
		str_cat(estr, buffer);

		counter++;
	}
}
Ejemplo n.º 2
0
void createLetters()
{	
	var letterAscii ; // For storing ASCII value of each letter
	var letterY ; // For repositioning letters onscreen
	var letterZ ; 
	var entHandle = 0 ; // For keeping track of who's first in line
	var stringCount = 0 ; // For keeping track of how many letters to eliminate

	
	str_cpy( sourceString,"dillinger" ) ; // Load sequence of letters into sourceString

	stringCount = str_len( sourceString ) ; // Store the length of the String in stringCount
	
	letterAscii = str_to_asc(sourceString); 
	
	str_cpy( myFontString,sourceString ) ; 
	str_trunc(myFontString, (str_len(myFontString) - 1)) ;  // now myFontString == 1st Letter
	
	str_clip(sourceString,1);
	
	while ( stringCount != 0 ) // Continue until the string is empty
	{
// Assign screen position of letters so they appear in same pattern as keyboard layout QWERTY...
		switch (letterAscii)
		{
			case 97: // a
				letterY = 270 ; 
				letterZ = 230 ; 
				break ; 

			case 98: // b
				letterY = 0;
				letterZ = 160;
				break;

			case 99: // c
				letterY = 120;
				letterZ = 160;
				break;

			case 100: // d
				letterY = 150;
				letterZ = 230;
				break;
	
			case 101: // e
				letterY = 146;
				letterZ = 298;
				break;

			case 102: // f
				letterY = 92;
				letterZ = 230;
				break;
	
			case 103: // g
				letterY = -30;
				letterZ = 230;
				break;
	
			case 104: // h
				letterY = 30;
				letterZ = 230;
				break;
	
			case 105: // i
				letterY = -156;
				letterZ = 298;
				break;

			case 106: // j
				letterY = -90;
				letterZ = 230;
				break;

			case 107: // k
				letterY = -150;
				letterZ = 230;
				break;

			case 108: // l
				letterY = -210;
				letterZ = 230;
				break;

			case 109: // m
				letterY = -124;
				letterZ = 159;
				break;

			case 110: // n
				letterY = -56;
				letterZ = 160;
				break;

			case 111: // o
				letterY = -210;
				letterZ = 300;
				break;

			case 112: // p
				letterY = -266;
				letterZ = 300;
				break;

			case 113: // q
				letterY = 270;
				letterZ = 300;
				break;

			case 114: // r
				letterY = 84;
				letterZ = 300;
				break;

			case 115: // s
				letterY = 212;
				letterZ = 230;
				break;

			case 116: // t
				letterY = 28;
				letterZ = 298;
				break;

			case 117: // u
				letterY = -100;
				letterZ = 300;
				break;

			case 118: // v
				letterY = 60;
				letterZ = 160;
				break;

			case 119: // w
				letterY = 206;
				letterZ = 300;
				break;

			case 120: // x
				letterY = 180;
				letterZ = 160;
				break;

			case 121: // y
				letterY = -40;
				letterZ = 300;
				break;

			case 122: // z
				letterY = 242;
				letterZ = 160;
				break;

			}


		wait( 400 ) ; 
		me = ent_create("../Letters+26.tga", vector(0,letterY,letterZ), letter) ; // create a new letter entity and start its function
		my.ascii = letterAscii;		// stores the letter's ascii value
		my.previous = entHandle;		// inherits the previous letter's handle
		my.eliminated = 0;
		my.ambient = 100 ; 
		reset(my,INVISIBLE);
		entHandle = handle(me) ; // save the current letter's handle so it can be assigned to the next letter

		letterAscii = str_to_asc(sourceString); 
		
		str_cpy( myFontString,sourceString ) ;
		str_trunc(myFontString, (str_len(myFontString) - 1)) ;  // now myFontString == 1st Letter 

		str_clip(sourceString,1);
		}

	}
Ejemplo n.º 3
0
void createLetters()
{	
	var letterAscii;
	var letterY;
	var letterZ;
	var entHandle = 0;

	//str_cpy(sourceString,"qwertyuiopasdfghjklzxcvbnm^");
	
		str_cpy(sourceString,"dillinger^");
				letterAscii = str_to_asc(sourceString); 
				str_clip(sourceString,1);
		
		while (letterAscii != 94)
		{


			switch (letterAscii)	//temp code to be replaced with something elegant later
			{
				case asc_a:
					letterY = 270;
					letterZ = 230;
					break;
				
				case asc_b:
					letterY = 0;
					letterZ = 160;
					break;
					
				case asc_c:
					letterY = 120;
					letterZ = 160;
					break;
					
				case asc_d:
					letterY = 150;
					letterZ = 230;
					break;
					
				case asc_e:
					letterY = 146;
					letterZ = 298;
					break;
					
				case asc_f:
					letterY = 92;
					letterZ = 230;
					break;
					
				case asc_g:
					letterY = -30;
					letterZ = 230;
					break;
					
				case asc_h:
					letterY = 30;
					letterZ = 230;
					break;
					
				case asc_i:
					letterY = -156;
					letterZ = 298;
					break;
		
				case asc_j:
					letterY = -90;
					letterZ = 230;
					break;
					
				case asc_k:
					letterY = -150;
					letterZ = 230;
					break;

				case asc_l:
					letterY = -210;
					letterZ = 230;
					break;

				case asc_m:
					letterY = -124;
					letterZ = 159;
					break;

				case asc_n:
					letterY = -56;
					letterZ = 160;
					break;

				case asc_o:
					letterY = -210;
					letterZ = 300;
					break;

				case asc_p:
					letterY = -266;
					letterZ = 300;
					break;

				case asc_q:
					letterY = 270;
					letterZ = 300;
					break;

				case asc_r:
					letterY = 84;
					letterZ = 300;
					break;

				case asc_s:
					letterY = 212;
					letterZ = 230;
					break;

				case asc_t:
					letterY = 28;
					letterZ = 298;
					break;

				case asc_u:
					letterY = -100;
					letterZ = 300;
					break;

				case asc_v:
					letterY = 60;
					letterZ = 160;
					break;

				case asc_w:
					letterY = 206;
					letterZ = 300;
					break;

				case asc_x:
					letterY = 180;
					letterZ = 160;
					break;

				case asc_y:
					letterY = -40;
					letterZ = 300;
					break;

				case asc_z:
					letterY = 242;
					letterZ = 160;
					break;

			}
			

		me = ent_create("Letters+26.tga", vector(0,letterY,letterZ), letter);	// create a new letter entity and start its function
		my.ascii = letterAscii;		// stores the letter's ascii value
		my.previous = entHandle;		// stores the previous letter's handle
		my.eliminated = 0;
		reset(my,INVISIBLE);
		entHandle = handle(me);		// save the current letter's handle so it can be assigned to the next letter
		
		
			letterAscii = str_to_asc(sourceString); 
			str_clip(sourceString,1);
	
			wait(800);
		}
		

	}