Example #1
0
static char *
remote_event_locked(const char *command)
{
    if (strcmp(command, "burp") == 0) {
	burp();
    } else if (strcmp(command, "spit") == 0) {
	spit();
    } else {
	return strdup("Invalid command");
    }

    return strdup(SERVER_OK);
}
Example #2
0
static void
take_action()
{
    pthread_mutex_lock(&event_lock);

    if (randomly_with_prob(BURP_PROB)) {
	if (! n_consecutive_spits) {
	    printf("Too many burps, do a spit instead.\n");
	    spit();
	} else {
	    burp();
	}
    } else {
	if (n_consecutive_spits >= MAX_CONSECUTIVE_SPITS) {
	    printf("Too many spits, do a burp instead.\n");
	    burp();
	} else {
	    spit();
	}
    }

    pthread_mutex_unlock(&event_lock);
}
Example #3
0
void filedelete()
{
char delname[20];
int x;
delname[0] = 0;
makewindow( 10,9,55,14,"Delete File");
gotoxy(12,12);
cprintf("Filename : ");
retcursor();
x= inputstring(wherex(),12,delname);
if (x>0)
{
x = unlink(delname);
if (x == -1) burp();
}
hidecursor();
closewindow(10,9,55,14);
}
Example #4
0
void errormessage(char far *message)
{
char scbuffer[800];
struct text_info inforec;
int x1 = 10;
int x2 = 10;
int y1 = 20;
int y2 = 23;
if (strchr(message,13) != NULL)
x2 += 2*strlen(message)/3 + 4;
else
x2 += strlen(message)+4;
burp();
gettextinfo(&inforec);
if (x2-x1 < 17) x2 = x1 + 17;
gettext(1,y1,80,y2+1,scbuffer);
textbackground(LIGHTGRAY);
window(x1+1,y1+1,x2+1,y2+1);
clrscr();
textbackground(BLACK);
textcolor(LIGHTGRAY);
window(x1,y1,x2,y2);
clrscr();
window(x1,y1,x2+1,y2+1);
textlineh(1,1,x2-x1+1);
textlineh(y2-y1+1,1,x2-x1+1);
textlinev(1,1,y2-y1+1,218,192);
textlinev(x2-x1+1,1,y2-y1+1,191,217);
window(1,1,80,25);
gotoxy(x1 + (x2-x1)/2 - 5/2,y1);
cprintf(" ERROR ");
window(x1+2,y1+1,x2-2,y2-1);
gotoxy(1,1);
cprintf("%s",message);
window(1,1,80,25);
delay(1500);
puttext(1,y1,80,y2+1,scbuffer);
textattr(inforec.attribute);
gotoxy(inforec.curx,inforec.cury);
window(inforec.winleft,inforec.wintop,inforec.winright,inforec.winbottom);
}
Example #5
0
// updatePlayer
// updates the player according to game rules
void updatePlayer(Player& obj)
{
  if (obj.coolDownCounter > WEAPON_OVERHEAT) obj.overHeated = true;
  // Input velocity
  char vx = 0;
  char vy = 0;

  byte id;
  byte tileXMax;
  byte tileYMax;
  byte inputDirection = obj.direction;

  ///////////
  // input //
  ///////////

  bool left = arduboy.pressed(LEFT_BUTTON);
  bool right = arduboy.pressed(RIGHT_BUTTON);
  bool up = arduboy.pressed(UP_BUTTON);
  bool down = arduboy.pressed(DOWN_BUTTON);

  bool rungun = arduboy.pressed(A_BUTTON);
  bool standgun = arduboy.pressed(B_BUTTON);
  bool strafegun = rungun;

  obj.walking = up || down || left || right;
  //obj.walking = (standgun && !rungun) ? false : obj.walking;

  ////////////
  // timers //
  ////////////

  // Diagonal anti-jerk timer
  if (obj.diagonalTime > 0)
    obj.diagonalTime--;
  if ((up && left) || (down && left) || (up && right) || (down && right))
    obj.diagonalTime = 4;

  // Bullet timer
  if (obj.shotDelay > 0) obj.shotDelay--;

  ////////////////////////
  // horizontal physics //
  ////////////////////////

  // input
  if (left)
    vx = -1;
  else if (right)
    vx = 1;

  // update position
  //if(strafegun || !standgun)
  obj.x += vx;

  // collide with zombies
  zombieCollide(obj.x, obj.y, true, vx, PLAYER_WIDTH, PLAYER_HEIGHT);

  // collide with walls
  mapCollide(obj.x, obj.y, true, vx, PLAYER_WIDTH, PLAYER_HEIGHT);

  //////////////////////
  // vertical physics //
  //////////////////////

  // input
  if (up)
    vy = -1;
  else if (down)
    vy = 1;

  // update position
  //if(strafegun || !standgun)
  obj.y += vy;

  // collide with zombies
  zombieCollide(obj.x, obj.y, false, vy, PLAYER_WIDTH, PLAYER_HEIGHT);

  // collide with walls
  mapCollide(obj.x, obj.y, false, vy, PLAYER_WIDTH, PLAYER_HEIGHT);

  // collide with survivors
  survivorCollide(obj.x, obj.y);

  // collide with door
  if (checkDoorCollision()) gameState = STATE_GAME_PREPARE_LEVEL;

  // collide with pickup
  pickupCollision(obj.x, obj.y);

  ///////////////
  // direction //
  ///////////////

  // Update camera direction according to the way the player is moving

  if (!strafegun)
  {
    if (left)
    {
      inputDirection = PLAYER_FACING_WEST;
      if (up) inputDirection = PLAYER_FACING_NORTHWEST;
      else if (down) inputDirection = PLAYER_FACING_SOUTHWEST;
    }
    else if (right)
    {
      inputDirection = PLAYER_FACING_EAST;
      if (up) inputDirection = PLAYER_FACING_NORTHEAST;
      else if (down) inputDirection = PLAYER_FACING_SOUTHEAST;
    }
    else if (up)
    {
      inputDirection = PLAYER_FACING_NORTH;
    }
    else if (down)
    {
      inputDirection = PLAYER_FACING_SOUTH;
    }
  }

  obj.direction = inputDirection;

  // the camera will only be updated if moving nondiagonally or look mode
  if ((standgun && !rungun) || (obj.direction % 2) == 0)
  {
    obj.camDirection = inputDirection;
  }

  ////////////
  // timers //
  ////////////
  if (arduboy.everyXFrames(4))
  {
    if (obj.coolDownCounter > 1)obj.coolDownCounter--;
    if ((arduboy.pressed(A_BUTTON) || arduboy.pressed(B_BUTTON)) && !obj.overHeated) obj.coolDownCounter += 2;
    if (obj.overHeated) coolGirl.coolDownVisible = !coolGirl.coolDownVisible;
  }

  if ((standgun || rungun) && !obj.overHeated)
  {
    if (obj.shotDelay == 0)
    {
      addBullet(obj.x + 10, obj.y + 12, obj.direction, 0, 0);
      obj.shotDelay = 10;
    }
  }

  if ((obj.overHeated == true) && (obj.coolDownCounter < 2))
  {
    obj.overHeated = false;
    obj.coolDownVisible = true;
  }

  // Update animation
  if (arduboy.everyXFrames(6) && obj.walking) obj.frame++;
  if (obj.frame > 3 ) obj.frame = 0;

  // update score
  if (rollingScore > 0)
  {
    rollingScore -= 5;
    scorePlayer += 5;
  }

  // update flashing
  if (obj.flashTime > 0)
    obj.flashTime--;

  ////////////
  // camera //
  ////////////

  // update camera
  short mapGoalX = coolGirl.x - WIDTH / 2 + PLAYER_WIDTH / 2;
  short mapGoalY = coolGirl.y - HEIGHT / 2 + PLAYER_HEIGHT / 2 - 4; // hud offset

  // offset the goal by the direction
  mapGoalX += BulletXVelocities[coolGirl.camDirection] * 4;
  mapGoalY += BulletXVelocities[(coolGirl.camDirection + 6) % 8] * 4;

  // move the camera toward the desired location
  mapPositionX = burp(mapPositionX, mapGoalX, 3);
  mapPositionY = burp(mapPositionY, mapGoalY, 3);

  // Clamp on screen boundaries
  mapPositionX = (mapPositionX < 0) ? 0 : mapPositionX;
  mapPositionX = (mapPositionX > LEVEL_WIDTH - WIDTH) ? LEVEL_WIDTH - WIDTH : mapPositionX;
  mapPositionY = (mapPositionY < 0) ? 0 : mapPositionY;
  mapPositionY = (mapPositionY > LEVEL_HEIGHT - HEIGHT) ? LEVEL_HEIGHT - HEIGHT : mapPositionY;
}
Example #6
0
void showtotals()
{
char headstr[30];
char numstr1[30];
char numstr2[30];
char numstr3[30];
char endstring[30];
coltype col1,col2;
int x;
double y;

if (totalvalue >= 1.0e8 || totalvalue <= -1.0e8)
{
burp();
if (totalvalue > 0.0)
{
makewindow(10,5,60,19,"TOO RICH");
gotoxy(14,8);
cprintf("You are too Rich.");
gotoxy(14,10);
cprintf("This is a free society so you have a choice:");
gotoxy(14,12);
cprintf("1. Make a LARGE DONATION TO CHARITY.");
gotoxy(14,14);
cprintf("2. Buy an EXPENSIVE version of this program.");
gotoxy(14,16);
}
else
{
makewindow(10,5,60,19,"BANKRUPT !");
gotoxy(14,8);
cprintf("You are too Poor.");
gotoxy(14,10);
cprintf("This is a free society so you have a choice:");
gotoxy(14,12);
cprintf("1. Become a charity.");
gotoxy(14,14);
cprintf("2. Buy an EXPENSIVE version of this program.");
gotoxy(14,16);
}
cprintf("NOTE: We cannot guarantee values produced");
gotoxy(14,18);
cprintf("      when such large numbers are used.");
delay(6000);
closewindow(10,5,60,19);
totalvalue = 0.0;
}

switch (sys.screen)
{
case SCREEN1 :
		ltoa(totalputs,numstr3,10);
		ltoa(totalcalls,numstr2,10);
		col1 = HELDC;
		col2 = HELDP;
		if (sys.display == HELDS)
                {
		strcpy(headstr," Tot. Value $  ");
		sprintf(numstr1,"%-12.2f",totalvalue);
		strcpy(endstring," ");
		}
		else
		{
		strcpy(headstr," Tot. Delta    ");
		sprintf(numstr1,"%-12.2f",totaldelta);
		strcpy(endstring,"$/c");
		}
		break;


case SCREEN2 :  break;
case SCREEN3 : if (sys.display == INVVOL || sys.display == OVERVALUED)
		{
		strcpy(headstr," Weighted Vol. ");
		strcpy(endstring," \% ");
		sprintf(numstr1,"%-5.*f",2,weightedvol);
		sprintf(numstr2,"%-4.*f \%",2,weightedvolc);
		sprintf(numstr3,"%-4.*f \%",2,weightedvolp);
		col1 = VOLC;
		col2 = VOLP;
		}
		break;
}