예제 #1
0
파일: game.c 프로젝트: sergot/asteroids
game* new_game(point *s) {
    game *g = calloc(1, sizeof(game));
    g->Ship = new_ship(p_times(s, 0.5));
    g->Size = s;
    g->status = Pause;
    g->score = 0;

    int i;
    for(i = 0; i <= ASTEROID_COUNT; i++)
        new_asteroid(ASTEROID_MAX_LVL);
    
    return g;
}
예제 #2
0
파일: arith2.c 프로젝트: tacgomes/yap6.3
static Term
eval2(Int fi, Term t1, Term t2 USES_REGS) {
  arith2_op f = fi;
  switch (f) {
  case op_plus:
    return p_plus(t1, t2 PASS_REGS);
  case op_minus:
    return p_minus(t1, t2 PASS_REGS);
  case op_times:
    return p_times(t1, t2 PASS_REGS);
  case op_div:
    return p_div(t1, t2 PASS_REGS);
  case op_idiv:
    return p_div2(t1, t2 PASS_REGS);
  case op_and:
    return p_and(t1, t2 PASS_REGS);
  case op_or:
    return p_or(t1, t2 PASS_REGS);
  case op_sll:
    return p_sll(t1, t2 PASS_REGS);
  case op_slr:
    return p_slr(t1, t2 PASS_REGS);
  case op_mod:
    return p_mod(t1, t2 PASS_REGS);
  case op_rem:
    return p_rem(t1, t2 PASS_REGS);
  case op_fdiv:
    return p_fdiv(t1, t2 PASS_REGS);
  case op_xor:
    return p_xor(t1, t2 PASS_REGS);
  case op_atan2:
    return p_atan2(t1, t2 PASS_REGS);
  case op_power:
    return p_exp(t1, t2 PASS_REGS);
  case op_power2:
    return p_power(t1, t2 PASS_REGS);
  case op_gcd:
    return p_gcd(t1, t2 PASS_REGS);
  case op_min:
    return p_min(t1, t2);
  case op_max:
    return p_max(t1, t2);
  case op_rdiv:
    return p_rdiv(t1, t2 PASS_REGS);
  }
  RERROR();
}
예제 #3
0
파일: game.c 프로젝트: sergot/asteroids
void update_ship(game *g, asteroid *a) {
    if(g->Ship->time > 0)
        g->Ship->time -= 0.1;
    
    point *n1 = new_point(), *n2 = new_point();
    n1->x = g->Ship->position->x - 8 * sin(g->Ship->angle);
    n1->y = g->Ship->position->y + 20 * cos(g->Ship->angle);
    
    n2->x = g->Ship->position->x + 8 * sin(g->Ship->angle);
    n2->y = g->Ship->position->y + 20 * cos(g->Ship->angle);
    
    if((collision(a, g->Ship->position) || collision(a, n1) || collision(a,n2) ) && g->Ship->time <= 0) {
        if(--g->Ship->life <= 0)
            g->status = Lose;
        g->Ship->position = p_times(g->Size, 0.5);
        g->Ship->time = 5;
    }
    
    free(n1); free(n2);
}