Exemple #1
0
void letter()
{
	
	my.x = 2000;
	
	while(1)
	{
		my.frame = my.ascii - 96;
		my.scale_x = .5;
		my.scale_y = .5;

	
		if (my.eliminated == 0) 
		{
			my.x -= 100 * time_step;   // Move letter toward the camera in X   
	
		
			if (my.previous != 0)	// if not first letter in sequence
			{
				you = ptr_for_handle(my.previous);
			
				if ((LetterPressedAscii == my.ascii) && (your.eliminated == 1))
				{
					set(my, INVISIBLE);
					LetterPressedAscii = 0;

					my.eliminated = 1;
	
				}
			}
			
			else	if (LetterPressedAscii == my.ascii)	// if first letter in sequence
				{
					set(my, INVISIBLE);
					
					LetterPressedAscii = 0;	
					my.eliminated = 1;
				}
		}

testVar1 = LetterPressedAscii;
	
		wait(1);
	}
}
Exemple #2
0
void letter()
{
	my.x = 2000 ;
	
	while(1)
	{
		my.frame = my.ascii - 96;
		my.scale_x = .7;
		my.scale_y = .7;

	
		if (my.eliminated == 0) // If letter still exists...
		{
			my.x -= 100 * time_step;   // Move letter toward the camera in X   
	

			if ( my.previous != 0 )	// If not first letter in sequence
			{
				you = ptr_for_handle( my.previous ) ; // point to the letter before me
			// If the letter before me is gone, and my number matches the keyboard input...
				if ( (your.eliminated == 1) && (LetterPressedAscii == my.ascii) )
				{
					set(my, INVISIBLE) ; // "delete" me
					LetterPressedAscii = 0 ; // reset the keyboard input
					my.eliminated = 1 ; // Mark me down as toast
				}
			}
			
			else	if (LetterPressedAscii == my.ascii)	// If first letter in sequence
				{ // Don't bother checking if anybody's before me, but do the rest the same
					set(my, INVISIBLE);
					LetterPressedAscii = 0;	
					my.eliminated = 1;
				}
		}
	
	wait(1);
	}
}
Exemple #3
0
// uses: id, speed, idletime 
action moving_platform()
{
	set(my, is_platform);
	my->ptr_start = NULL;
	my->ptr_end   = NULL;
	if (my->idletime == 0) my->idletime = 0.001;
	
	wait (1);

	for(you = ent_next(NULL); (you != NULL) && (my->ptr_end == NULL); you = ent_next(you))
	{
		if ((your->id == my->id) && (my->id > 0) && is(you, is_marker))
		{
			if (my->ptr_start == NULL)
			{
				my->ptr_start = handle(you);
			}
			else if (my->ptr_end == NULL)
			{
				my->ptr_end = handle(you);
			}
			else
			{
				//do nothing
			}
		}
	}
	
	if ((my->ptr_end == NULL) || (my->id <= 0))
	{
		printf("incorrect platform marker for id %d", (int)my->id);
		return;
	}

	//platform start point
	VECTOR vecSpeed;
	VECTOR vecTemp;
	ENTITY *ent1, *ent2, *entTarget, *entCur, *entTemp;
	
	ent1 = ptr_for_handle(my->ptr_start);
	ent2 = ptr_for_handle(my->ptr_end);
	
	//directional speed
	vec_set(&vecSpeed, &ent2->x);
	vec_sub(&vecSpeed, &ent1->x);
	vec_normalize(&vecSpeed, my->speed);

	if (vec_dist(&ent1->x, &my->x) < vec_dist(&ent2->x, &my->x))
	{
		vec_set(&my->x, &ent1->x);
		entTarget = ent2;
		entCur    = ent1;
	}
	else
	{
		vec_set(&my->x, &ent2->x);			
		entTarget = ent1;
		entCur    = ent2;
		vec_scale(&vecSpeed, -1);
	}

	//entity loop
	while(1)
	{		
		vec_set(vecTemp, vecSpeed);
		vec_scale(vecTemp, time_step);
		vec_set(&my->absspeed_x, &vecTemp);
		
 		you = player;
		c_move(me, nullvector, &vecTemp, IGNORE_MODELS | IGNORE_SPRITES | IGNORE_YOU | IGNORE_PASSABLE | IGNORE_PASSENTS | IGNORE_MAPS);

		if(vec_dist(&entTarget->x, &my->x) < 20)
		{
			wait (1);
			vec_set(&my->absspeed_x, nullvector);
			wait(-(my->idletime));

			vec_scale(&vecSpeed, -1);
			entTemp   = entCur;
			entCur    = entTarget;
			entTarget = entTemp;			
		}
		
		wait (1);
	}
}
Exemple #4
0
// uses: id, speed 
action rotating_platform()
{
	set(my, is_platform);
	my->ptr_start = NULL;
	my->ptr_end   = NULL;
	
	wait (1);

	for(you = ent_next(NULL); (you != NULL) && (my->ptr_end == NULL); you = ent_next(you))
	{
		if ((your->id == my->id) && (my->id > 0) && is(you, is_marker))
		{
			if (my->ptr_start == NULL)
			{
				my->ptr_start = handle(you);
			}
			else if (my->ptr_end == NULL)
			{
				my->ptr_end = handle(you);
			}
			else
			{
				//do nothing
			}
		}
	}
	
	if ((my->ptr_end == NULL) || (my->id <= 0))
	{
		printf("incorrect platform marker for id %d", (int)my->id);
		return;
	}

	//platform start point
	VECTOR vecSpeed, vecTemp;
	ENTITY *ent1, *ent2, *entCenter;
	var vRadius;
	var vAngle;
	
	ent1 = ptr_for_handle(my->ptr_start);
	ent2 = ptr_for_handle(my->ptr_end);
	
	if (vec_dist(&ent1->x, &my->x) < vec_dist(&ent2->x, &my->x))
	{
		vec_set(&my->x, &ent1->x);
		entCenter = ent2;
		ent2->y = ent1->y;
	}
	else
	{
		vec_set(&my->x, &ent2->x);			
		entCenter = ent1;
		ent1->y = ent2->y;
	}

	//directional speed
	vec_set(&vecSpeed, nullvector);
	vRadius = vec_dist(&ent1->x, &ent2->x);

	//entity loop
	while(1)
	{		
		vAngle += time_step * my->speed;
		vAngle = ang(vAngle);
		vec_set(&vecSpeed, nullvector);
		vecSpeed.x = vRadius;
		vec_rotate(&vecSpeed, vector(0, vAngle, 0));
		vec_add(&vecSpeed, &entCenter->x);
		vec_sub(&vecSpeed, &my->x);
		vec_scale(&vecSpeed, time_step);
		vec_set(&my->absspeed_x, &vecSpeed);
		
 		you = player;
		c_move(me, nullvector, &vecSpeed, IGNORE_MODELS | IGNORE_SPRITES | IGNORE_YOU | IGNORE_PASSABLE | IGNORE_PASSENTS | IGNORE_MAPS);

		wait (1);
	}
}