Пример #1
0
/**********************************************************************
 * mark_outline
 *
 * Make a mark on the edges window at a particular location.
 **********************************************************************/
void mark_outline(EDGEPT *edgept) {  /* Start of point list */
  void *window = edge_window;
  float x = edgept->pos.x;
  float y = edgept->pos.y;

  c_line_color_index(window, Red);
  c_move(window, x, y);

  x -= 4;
  y -= 12;
  c_draw(window, x, y);

  x -= 2;
  y += 4;
  c_draw(window, x, y);

  x -= 4;
  y += 2;
  c_draw(window, x, y);

  x += 10;
  y += 6;
  c_draw(window, x, y);

  c_make_current(window);
}
/*----------------------------------------------------------------------------
						Public Code
-----------------------------------------------------------------------------*/
void DisplayProtoList(const char* ch, LIST protolist) {
  void* window = c_create_window("Char samples", 50, 200,
                                 520, 520, -130.0, 130.0, -130.0, 130.0);
  LIST proto = protolist;
  iterate(proto) {
    PROTOTYPE* prototype = reinterpret_cast<PROTOTYPE *>(first_node(proto));
    if (prototype->Significant)
      c_line_color_index(window, Green);
    else if (prototype->NumSamples == 0)
      c_line_color_index(window, Blue);
    else if (prototype->Merged)
      c_line_color_index(window, Magenta);
    else
      c_line_color_index(window, Red);
    float x = CenterX(prototype->Mean);
    float y = CenterY(prototype->Mean);
    double angle = OrientationOf(prototype->Mean) * 2 * M_PI;
    float dx = static_cast<float>(LengthOf(prototype->Mean) * cos(angle) / 2);
    float dy = static_cast<float>(LengthOf(prototype->Mean) * sin(angle) / 2);
    c_move(window, (x - dx) * 256, (y - dy) * 256);
    c_draw(window, (x + dx) * 256, (y + dy) * 256);
    if (prototype->Significant)
      tprintf("Green proto at (%g,%g)+(%g,%g) %d samples\n",
              x, y, dx, dy, prototype->NumSamples);
    else if (prototype->NumSamples > 0 && !prototype->Merged)
      tprintf("Red proto at (%g,%g)+(%g,%g) %d samples\n",
              x, y, dx, dy, prototype->NumSamples);
  }
  c_make_current(window);
}
Пример #3
0
/**********************************************************************
 * mark_split
 *
 * Set up the marks list to be displayed in subsequent updates and draw
 * the marks in the current window.  The marks are stored in the second
 * sublist. The first sublist is left unmodified.
 **********************************************************************/
void mark_split(SPLIT *split) {
  void *window = edge_window;

  c_line_color_index(window, Green);
  c_move (window, (float) split->point1->pos.x, (float) split->point1->pos.y);
  c_draw (window, (float) split->point2->pos.x, (float) split->point2->pos.y);
  c_make_current(window);
}
Пример #4
0
	action update_Earth() // Actions for earth.mdl
{
	wait(1) ; 
	c_setminmax( me ) ; // Wrap Collision Zone to Model's size

	my.emask |= ( ENABLE_ENTITY ) ; // make entity sensitive for block and entity collision
  	my.event = collide_event ; // Define which event will be triggered
 
	while (1) // While game is running, continue to do this:
	{
		// If Up Arrow Key is pressed, subtract 2 from the Z Position, and check for collision
		if ( key_cuu ) c_move(me, NULL,vector(0,0,2 * time_step), NULL ) ; 
		// If Down Arrow Key is pressed, add 2 to the Z Position, and check for collision
      if ( key_cud ) c_move(me, NULL,vector(0,0,-2 * time_step), NULL ) ; 
      // If Left Arrow Key is pressed, subtract 2 from the Y Position, and check for collision
      if ( key_cul ) c_move(me, NULL,vector(0,2 * time_step,0), NULL ) ; 
      // If Right Arrow Key is pressed, add 2 to the Y Position, and check for collision
      if ( key_cur ) c_move(me, NULL,vector(0,-2 * time_step,0), NULL ) ; 
      
	wait (1) ; 
	}
}
Пример #5
0
// call this function from a level to enable the free camera movement
void def_move()
{
	VECTOR force,speed,dist;
	ANGLE aforce,aspeed; 

	// initialize speed and distance
	vec_zero(speed);
	vec_zero(aspeed);
	vec_zero(dist);

	if (1 > def_camera)
	def_camera = 1;
	if (1 < run_mode && run_mode < 5) 
	def_camera = 2;	// prevent player movement in entity viewer mode

	while (def_camera) 
	{
		aforce.tilt = 5*(key_pgup - key_pgdn + mouse_right*mouse_force.y);
		if (key_alt==0) {
			aforce.pan = -5*(key_force.x + mouse_right*mouse_force.x + joy_force.x);
			aforce.roll = 0;
			} else {
			aforce.pan = 0;
			aforce.roll = 5*(key_force.x + mouse_right*mouse_force.x + joy_force.x);
		}
		vec_add(&camera->pan,vec_accelerate(&dist,&aspeed,&aforce,0.8));

		force.x = 7*(key_force.y + key_w - key_s + joy_force.y);
		force.y = 3*(key_comma - key_period + key_a - key_d);
		force.z = 3*(key_home - key_end);
		vec_accelerate(&dist,&speed,&force,0.5);
		
		if (NULL != player && 1 == def_camera) {
			c_move(player,&dist,nullvector,IGNORE_PASSABLE|IGNORE_PASSENTS|GLIDE);
			camera->genius = player;
			vec_set(&player->pan,&camera->pan);
			vec_set(&camera->x,nullvector);
			vec_rotate(&camera->x,&camera->pan);
			vec_add(&camera->x,&player->x);
			} else {
			camera->genius = NULL;
			vec_add(&camera->x,vec_rotate(&dist,&camera->pan));
		}
		wait(1);
	}
}
Пример #6
0
/**********************************************************************
 * render_edgepts
 *
 * Create a list of line segments that represent the expanded outline
 * that was supplied as input.
 **********************************************************************/
void render_edgepts(void *window, EDGEPT *edgept, C_COL color) {
  float x = edgept->pos.x;
  float y = edgept->pos.y;
  EDGEPT *this_edge = edgept;

  if (!edgept)
    return;

  c_line_color_index(window, color);
  c_move(window, x, y);
  do {
    this_edge = this_edge->next;
    x = this_edge->pos.x;
    y = this_edge->pos.y;
    c_draw(window, x, y);
  }
  while (edgept != this_edge);
}
Пример #7
0
// uses: durability, speed
action breaking_platform()
{
	ENTITY* ent = ent_create("platform_crumble.wmb", &my->x, NULL); //f**k it
	ent_preload(ent); //f**k it
	set(ent, INVISIBLE | PASSABLE); //f**k it
	
	set(my, is_platform);
	my->event = breaking_platform_evt;
	my->emask |= (ENABLE_IMPACT); 
	if (my->durability <= 0) my->durability = 0.5;
	if (my->speed <= 0)      my->speed = 2;
	
	while(!is(my, is_touched))
	{
		wait (1);
	}

	ent_playsound(me, sndPlatformCrumble, 1000);
	set(me, INVISIBLE | PASSABLE); //f**k it
	reset(ent, INVISIBLE | PASSABLE); //f**k it
	//ent_morph(me, "platform_crumble.wmb");
	wait (-(my->durability));

	ent->speed = my->speed; //f**k it
	ptr_remove(me); //f**k it
	me = ent; //f**k it
	//move downwards
	VECTOR vecSpeed;
	my->alpha = 100;
	set(my, TRANSLUCENT | PASSABLE);
	while(my->alpha != 0)
	{
		vec_set(&vecSpeed, vector(0,0, -(my->speed) * time_step));
		c_move(me, nullvector, &vecSpeed, IGNORE_MODELS | IGNORE_SPRITES | IGNORE_WORLD | IGNORE_PASSABLE | IGNORE_PASSENTS | IGNORE_MAPS);
		my->alpha = maxv(my->alpha - (my->speed * time_step * 0.5), 0);
		wait (1);
	}

	ptr_remove(me);
}
Пример #8
0
void
docmd(void)
{
	int c;
	struct ww *w;
	char out = 0;

	while (!out && !quit) {
		if ((c = wwgetc()) < 0) {
			if (terse)
				wwsetcursor(0, 0);
			else {
				wwputs("Command: ", cmdwin);
				wwcurtowin(cmdwin);
			}
			do
				wwiomux();
			while ((c = wwgetc()) < 0);
		}
		if (!terse)
			wwputc('\n', cmdwin);
		switch (c) {
		default:
			if (c != escapec)
				break;
		case 'h': case 'j': case 'k': case 'l':
		case 'y': case 'p':
		case ctrl('y'):
		case ctrl('e'):
		case ctrl('u'):
		case ctrl('d'):
		case ctrl('b'):
		case ctrl('f'):
		case ctrl('s'):
		case ctrl('q'):
		case ctrl('['):
			if (selwin == 0) {
				error("No window.");
				continue;
			}
		}
		switch (c) {
		case '1': case '2': case '3': case '4': case '5':
		case '6': case '7': case '8': case '9':
			if ((w = window[c - '1']) == 0) {
				error("%c: No such window.", c);
				break;
			}
			setselwin(w);
			if (checkproc(selwin) >= 0)
				 out = 1;
			break;
		case '%':
			if ((w = getwin()) != 0)
				setselwin(w);
			break;
		case ctrl('^'):
			if (lastselwin != 0) {
				setselwin(lastselwin);
				if (checkproc(selwin) >= 0)
					out = 1;
			} else
				error("No previous window.");
			break;
		case 'c':
			if ((w = getwin()) != 0)
				closewin(w);
			break;
		case 'w':
			c_window();
			break;
		case 'm':
			if ((w = getwin()) != 0)
				c_move(w);
			break;
		case 'M':
			if ((w = getwin()) != 0)
				movewin(w, w->ww_alt.t, w->ww_alt.l);
			break;
		case 's':
			if ((w = getwin()) != 0)
				c_size(w);
			break;
		case 'S':
			if ((w = getwin()) != 0)
				sizewin(w, w->ww_alt.nr, w->ww_alt.nc);
			break;
		case 'y':
			c_yank();
			break;
		case 'p':
			c_put();
			break;
		case ':':
			c_colon();
			break;
		case 'h':
			(void) wwwrite(selwin, "\b", 1);
			break;
		case 'j':
			(void) wwwrite(selwin, "\n", 1);
			break;
		case 'k':
			(void) wwwrite(selwin, "\033A", 2);
			break;
		case 'l':
			(void) wwwrite(selwin, "\033C", 2);
			break;
		case ctrl('e'):
			wwscroll(selwin, 1);
			break;
		case ctrl('y'):
			wwscroll(selwin, -1);
			break;
		case ctrl('d'):
			wwscroll(selwin, selwin->ww_w.nr / 2);
			break;
		case ctrl('u'):
			wwscroll(selwin, - selwin->ww_w.nr / 2);
			break;
		case ctrl('f'):
			wwscroll(selwin, selwin->ww_w.nr);
			break;
		case ctrl('b'):
			wwscroll(selwin, - selwin->ww_w.nr);
			break;
		case ctrl('s'):
			stopwin(selwin);
			break;
		case ctrl('q'):
			startwin(selwin);
			break;
		case ctrl('l'):
			wwredraw();
			break;
		case '?':
			c_help();
			break;
		case ctrl('['):
			if (checkproc(selwin) >= 0)
				out = 1;
			break;
		case ctrl('z'):
			wwsuspend();
			break;
		case 'q':
			c_quit();
			break;
		/* debugging stuff */
		case '&':
			if (debug) {
				c_debug();
				break;
			}
		default:
			if (c == escapec) {
				if (checkproc(selwin) >= 0) {
					(void) write(selwin->ww_pty,
						&escapec, 1);
					out = 1;
				}
			} else {
				if (!terse)
					wwbell();
				error("Type ? for help.");
			}
		}
	}
	if (!quit)
		setcmd(0);
}
Пример #9
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);
	}
}
Пример #10
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);
	}
}
Пример #11
0
void ebHandJoint ()
{
	set(my, INVISIBLE);
	
	vec_scale(my->scale_x, 2);
	c_updatehull(my, 0);
	
	VECTOR v0, v1, v, diff;
	
	BOOL isChopped = false;
	
	while (1)
	{
		updateHandChopped(g_ebHand);
		
		int myid = (int)my->skill1;
		
		if (myid % 2 == 0)
			set(my, FLAG2);
		
		if (g_ebHand != NULL)
		{
			if (g_ebHand->skill1 != 1)
				break;
				
			BOOL bLeftHand = (g_ebHand->skill20 != 0);
			int fingerId = myid;
			VECTOR vecFingerPos, vecFingerDir;
			
			handFingerPos(g_ebHand, bLeftHand, fingerId, &vecFingerPos, &vecFingerDir);
			
			vecFingerPos.y = player->y;
			vecFingerPos.z -= 32;
			
			vec_diff(&diff, &vecFingerPos, my->x);
			
			var distplayer = absv(my->x - player->x);
			
			if (g_handDropping && vec_length(&diff) > 2)
			{
				var distmove = c_move(my, NULL, &diff, IGNORE_PASSABLE | IGNORE_SPRITES | IGNORE_FLAG2);
				
				if (g_ebHand->skill2 != 0 && distmove <= 0 && (distplayer < my->max_x * 1.25))
					player->PL_HEALTH = 0;
			}
			else
			{
				if (!g_handDropping && !g_fingerChopped)
				{
					if (distplayer < my->max_x * 2)
					{
						if (g_playerIsAttacking)
						{
							set(my, PASSABLE);
						
							if (bLeftHand) // left
								g_handChopL[my->skill1] = true;
							else // right
								g_handChopR[my->skill1] = true;
								
							isChopped = true;
							g_fingerChopped = true;
							
							doChopped(g_ebHand, g_ebHand->skill20, my->skill1);							
							updateHandChopped(g_ebHand);
							
							ebDoCrazyness();
							ebDoHit();
								
							break;
						}
					}
				}
			}
		}
		
		wait(1);
	}
	
	ptr_remove(my);
}