コード例 #1
0
ファイル: game.c プロジェクト: devmabbott/Invaders
static void game_draw_bullets(game_t *g) {
    SDL_Rect DestR;
    ll_node_t *node;
    bullet_t *bullet;

    node = ll_get_first_node(g->state->player_bullets);
    while(node) {
        bullet = (bullet_t *)ll_get_item(node);

        DestR.x = bullet->xpos;
        DestR.y = bullet->ypos;
        SDL_BlitSurface(sprite_get_basic_bullet()->pic, NULL, g->surface, &DestR);

        node = ll_next_node(g->state->player_bullets, node);
    }

    node = ll_get_first_node(g->state->alien_bullets);
    while(node) {
        bullet = (bullet_t *)ll_get_item(node);

        DestR.x = bullet->xpos;
        DestR.y = bullet->ypos;
        SDL_BlitSurface(sprite_get_basic_bullet()->pic, NULL, g->surface, &DestR);

        node = ll_next_node(g->state->alien_bullets, node);
    }
}
コード例 #2
0
ファイル: game.c プロジェクト: devmabbott/Invaders
static void game_draw_aliens(game_t *g) {
    SDL_Rect DestR;
    ll_node_t *node;
    alien_t *alien;

    node = ll_get_first_node(g->state->level->aliens);
    while(node) {
        alien = (alien_t *)ll_get_item(node);

        DestR.x = alien->ship->xpos;
        DestR.y = alien->ship->ypos;
        SDL_BlitSurface(alien->ship->sprite->pic, NULL, g->surface, &DestR);

        node = ll_next_node(g->state->level->aliens, node);
    }
}
コード例 #3
0
ファイル: conn.c プロジェクト: TBR-Tech/libxbee.libxbee-v2
/* validate that the given connection exists in the xbee instance
   can return the conType, or ignore of **conType = NULL */
int _xbee_conValidate(struct xbee *xbee, struct xbee_con *con, struct xbee_conType **conType) {
	int i;
	
	/* check parameters */
	if (!xbee) {
		if (!xbee_default) return XBEE_ENOXBEE;
		xbee = xbee_default;
	}
	if (!xbee_validate(xbee)) return XBEE_ENOXBEE;
	if (!xbee->mode) return XBEE_ENOMODE;
	if (!con) return XBEE_EMISSINGPARAM;
	
	/* try to find the provided connection in any of the xbee's conTypes */
	for (i = 0; xbee->mode->conTypes[i].name; i++) {
		/* look for, and break if we find it */
		if (ll_get_item(&(xbee->mode->conTypes[i].conList), con)) break;
	}
	if (!xbee->mode->conTypes[i].name) {
		/* no connection was found */
		if (conType) *conType = NULL;
		return XBEE_EFAILED;
	}
	
	/* provide the conType to the caller */
	if (conType) *conType = &(xbee->mode->conTypes[i]);
	
	/* this mapping is implemented as an extension, therefore it is entirely optional! */
	if (xbee->f->conValidate) {
		int ret;
		/* call the conValidate extension */
		if ((ret = xbee->f->conValidate(xbee, con, conType)) != 0) {
			/* ret should be either 0 / XBEE_ESTALE */;
			return ret;
		}
	}
	
	return XBEE_ENONE;
}