コード例 #1
0
ファイル: Perso.cpp プロジェクト: petitlapin/WarriorOfGujoong
void
Perso::add_XP(int val){
    _xp += val;
    while(_xp >= XP_FOR_WINNING_LEVEL) { // Can't win 2 levels at the same time ?
        _xp -= XP_FOR_WINNING_LEVEL;
        inc_level();
        emit signal_perso_win_level(this);
    }
}
コード例 #2
0
ファイル: pub3debug.C プロジェクト: aosmith/okws
 void
 dumper_t::begin_obj (str s, const void *p, lineno_t l)
 {
   strbuf b;
   b.fmt ("-{ %s (%p", s.cstr (), p);
   if (l) b << "," << l;
   b << ")";
   dump (b, true);
   inc_level ();
 }
コード例 #3
0
ファイル: gbc_trans_tree.c プロジェクト: ramonelalto/gambas
static void analyze_expr(short priority, short op_main)
{
	short op, op_curr, op_not;
	short prio;
	short nparam;

	inc_level();

	op_curr = op_main;
	op_not = RS_NONE;
	nparam = (op_main == RS_NONE || op_main == RS_UNARY) ? 0 : 1;

	if (PATTERN_is(*current, RS_NEW))
		THROW("Cannot use NEW operator there");

READ_OPERAND:

	//analyze_expr_check_first(op_curr);

	analyze_single(op_curr);
	nparam++;

	if (nparam > MAX_PARAM_OP)
		THROW("Expression too complex. Too many operands");

READ_OPERATOR:

	if (!PATTERN_is_reserved(*current))
		goto OPERATOR_END;

	op = PATTERN_index(*current);

	if (!RES_is_operator(op))
		goto OPERATOR_END;

	if (op == RS_AND || op == RS_OR)
		if (PATTERN_is(current[1], RS_IF))
			goto OPERATOR_END;

	current++;
	
	if (op == RS_NOT && PATTERN_is_reserved(*current))
	{
		op_not = PATTERN_index(*current);
		if (RES_is_operator(op_not) && RES_can_have_not_before(op_not))
		{
			op = op_not + 1;
			current++;
		}
	}
	
	if (priority)
		prio = priority;
	else if (op_curr == RS_NONE)
		prio = 0;
	else
		prio = RES_priority(op_curr);

	if (op_curr == RS_NONE)
	{
		if (RES_is_binary(op) || RES_is_n_ary(op))
		{
			op_curr = op;
			goto READ_OPERAND;
		}
	}

	if (op_curr == op)
	{
		if (!(RES_is_binary(op) && nparam == 2))
			goto READ_OPERAND;
	}

	if (RES_priority(op) > prio)
	{
		if (op == RS_LSQR)
			analyze_array();
		else if (op == RS_LBRA)
			analyze_call();
		else
			analyze_expr(RES_priority(op), op);

		goto READ_OPERATOR;
	}

	if (RES_priority(op) == prio)
	{
		add_operator(op_curr, nparam);

		if (op == RS_LSQR)
		{
			analyze_array();
			goto READ_OPERATOR;
		}
		else if (op == RS_LBRA)
		{
			analyze_call();
			goto READ_OPERATOR;
		}
		else
		{
			if (RES_is_only(op_curr) || RES_is_only(op))
				THROW("Ambiguous expression. Please use brackets");

			nparam = 1;
			op_curr = op;
			goto READ_OPERAND;
		}
	}

	if (RES_priority(op) < prio)
	{
		if ((op_main != RS_NONE) || (priority > 0))
		{
			add_operator(op_curr, nparam);
			current--;
			if (op_not != RS_NONE)
				current--;
			goto END;
		}

		add_operator(op_curr, nparam);

		if (op == RS_LSQR)
		{
			analyze_array();
			nparam = 1;
			op_curr = op_main;
			goto READ_OPERATOR;
		}
		else if (op == RS_LBRA)
		{
			analyze_call();
			nparam = 1;
			op_curr = op_main;
			goto READ_OPERATOR;
		}
		else
		{
			nparam = 1;
			op_curr = op;
			goto READ_OPERAND;
		}
	}

	dec_level();
	return;

OPERATOR_END:

	add_operator(op_curr, nparam);

END:

	dec_level();
	return;

}
コード例 #4
0
ファイル: game.c プロジェクト: LordSputnik/pacman-clone
void update_game(struct Anim* anims, struct Image* images, uint32_t dt)
{
  if(pacman_dead == 1)
  {
    pacman_dead = isPacmanDying();
    if(pacman_dead == 0)
    {
      end_kill_pacman();
    }
    return;
  }

  level_time += dt;

  if(bonus_spawned == 1)
    bonus_timer -= dt;

  blinky_update(&blinky,&pacman,&my_grid);
  pinky_update(&pinky,&pacman,&my_grid);
  inky_update(&inky,&blinky, &pacman,&my_grid);
  clyde_update(&clyde,&pacman,&my_grid);
  pacman_update(&pacman,&my_grid);

  if(frightened_ == 1)
  {
    fright_timer -= dt;
    if(fright_timer < 0)
    {
      set_frightened(0);
    }
  }
  else
  {
    if(stage < 7)
    {
      stage_times[stage] -= dt;

      if(stage_times[stage] < 0)
      {

        if(behaviour_ == 1)
          set_behaviour(2);
        else
          set_behaviour(1);

        printf("Level: %i Level Time: %i Stage: %i Stage Time: %i\n",effective_level,level_time,stage,stage_times[stage]);
        printf("Behaviour: %i\n",behaviour_);

        ++stage;
      }
    }
  }

  if(get_remaining_dots() == 0)
  {
    inc_level();
    init_level();

    grid_reload(&my_grid);

    pacman_reset(&pacman);
    blinky_init(&blinky,anims,images);
    pinky_init(&pinky,anims,images);
    inky_init(&inky,anims,images);
    clyde_init(&clyde,anims,images);
  }
  else if(get_remaining_dots() == 170)
  {
    spawn_bonus();
    bonus_timer = (rand() % 1000) + 9000;
  }
  else if(get_remaining_dots() == 70)
  {
    spawn_bonus();
    bonus_timer = (rand() % 1000) + 9000;
  }


  if(bonus_timer <= 0 && bonus_spawned == 1)
  {
    kill_bonus();
  }
}