コード例 #1
0
ファイル: drawable.obj.c プロジェクト: haifenghuang/miranda
d_define_method(drawable, get_scaled_center)(struct s_object *self, double *x, double *y) {
	d_using(drawable);
	d_call(&(drawable_attributes->point_normalized_center), m_point_get, x, y);
	return self;
}
コード例 #2
0
ファイル: label.obj.c プロジェクト: haifenghuang/miranda
d_define_method_override(label, set_blend)(struct s_object *self, enum e_drawable_blends blend) {
	d_using(label);
	label_attributes->last_blend = blend;
	SDL_SetTextureBlendMode(label_attributes->image, blend);
	return self;
}
コード例 #3
0
ファイル: line.obj.c プロジェクト: haifenghuang/miranda
d_define_method(line, set_ending_y)(struct s_object *self, double ending_y) {
	d_using(line);
	line_attributes->ending_y = ending_y;
	return self;
}
コード例 #4
0
ファイル: drawable.obj.c プロジェクト: haifenghuang/miranda
d_define_method(drawable, set_flags)(struct s_object *self, int flags) {
	d_using(drawable);
	drawable_attributes->flags = flags;
	return self;
}
コード例 #5
0
ファイル: particle.obj.c プロジェクト: nardinan/miranda
d_define_method(particle, stop)(struct s_object *self) {
  d_using(particle);
  particle_attributes->single_shoot = d_true;
  return self;
}
コード例 #6
0
ファイル: drawable.obj.c プロジェクト: haifenghuang/miranda
d_define_method(drawable, set_center)(struct s_object *self, double x, double y) {
	d_using(drawable);
	d_call(&(drawable_attributes->point_center), m_point_set_x, x);
	d_call(&(drawable_attributes->point_center), m_point_set_y, y);
	return self;
}
コード例 #7
0
ファイル: drawable.obj.c プロジェクト: haifenghuang/miranda
d_define_method(drawable, set_zoom)(struct s_object *self, double zoom) {
	d_using(drawable);
	drawable_attributes->zoom = zoom;
	return self;
}
コード例 #8
0
ファイル: track.obj.c プロジェクト: nardinan/miranda
d_define_method(track, pause)(struct s_object *self) {
  d_using(track);
  if ((track_attributes->channel != d_track_auto_channel) && (Mix_Playing(track_attributes->channel)))
    Mix_Pause(track_attributes->channel);
  return self;
}
コード例 #9
0
ファイル: track.obj.c プロジェクト: nardinan/miranda
d_define_method(track, set_volume)(struct s_object *self, int volume) {
  d_using(track);
  track_attributes->volume = volume;
  Mix_VolumeChunk(track_attributes->chunk, volume);
  return self;
}
コード例 #10
0
ファイル: map.obj.c プロジェクト: nardinan/miranda
d_define_method(map, reset)(struct s_object *self) {
  d_using(map);
  map_attributes->pointer = 0;
  return self;
}
コード例 #11
0
ファイル: map.obj.c プロジェクト: nardinan/miranda
d_define_method(map, size)(struct s_object *self, size_t *size) {
  d_using(map);
  *size = (map_attributes->hash->mask + 1);
  return self;
}
コード例 #12
0
ファイル: map.obj.c プロジェクト: nardinan/miranda
d_define_method(map, find)(struct s_object *self, struct s_object *key) {
  d_using(map);
  d_cast_return(f_hash_get(map_attributes->hash, (void *)key));
}
コード例 #13
0
d_define_method(memory, retain)(struct s_object *self) {
    d_using(memory);
    ++(memory_attributes->references);
    return self;
}
コード例 #14
0
ファイル: particle.obj.c プロジェクト: nardinan/miranda
d_define_method(particle, update)(struct s_object *self, unsigned int max_particles) {
  d_using(particle);
  unsigned int index;
  struct timeval current, elapsed_begin, elapsed_update;
  struct s_drawable_attributes *drawable_attributes_self = d_cast(self, drawable);
  double local_position_x, local_position_y, real_elapsed_begin, real_elapsed_update, radians, speed_x, speed_y;
  unsigned int generated = 0;
  gettimeofday(&current, NULL);
  d_call(&(drawable_attributes_self->point_destination), m_point_get, (double *)&local_position_x, (double *)&local_position_y);
  for (index = 0; index < particle_attributes->configuration.particles; ++index) {
    if (particle_attributes->particles[index].alive) {
      timersub(&current, &(particle_attributes->particles[index].born), &elapsed_begin);
      real_elapsed_begin = elapsed_begin.tv_sec + ((double)(elapsed_begin.tv_usec) / 1000000.0);
      if (particle_attributes->particles[index].core.lifetime > real_elapsed_begin) {
        timersub(&current, &(particle_attributes->particles[index].update), &elapsed_update);
        real_elapsed_update = elapsed_update.tv_sec + ((double)(elapsed_update.tv_usec) / 1000000.0);
        particle_attributes->particles[index].core.mask_R += (particle_attributes->particles[index].core.speed_R * real_elapsed_update);
        particle_attributes->particles[index].core.mask_G += (particle_attributes->particles[index].core.speed_G * real_elapsed_update);
        particle_attributes->particles[index].core.mask_B += (particle_attributes->particles[index].core.speed_B * real_elapsed_update);
        particle_attributes->particles[index].core.mask_A += (particle_attributes->particles[index].core.speed_A * real_elapsed_update);
        d_particle_apply_limits(particle_attributes->particles[index].core.mask_R, 0, 255);
        d_particle_apply_limits(particle_attributes->particles[index].core.mask_G, 0, 255);
        d_particle_apply_limits(particle_attributes->particles[index].core.mask_B, 0, 255);
        d_particle_apply_limits(particle_attributes->particles[index].core.mask_A, 0, 255);
        particle_attributes->particles[index].core.zoom += (particle_attributes->particles[index].core.speed_zoom * real_elapsed_update);
        particle_attributes->particles[index].core.angle += (particle_attributes->particles[index].core.speed_angle * real_elapsed_update);
        particle_attributes->particles[index].core.direction_angle += (particle_attributes->particles[index].core.speed_direction_angle * real_elapsed_update);
        radians = (particle_attributes->particles[index].core.direction_angle * d_math_pi) / 180.0;
        speed_x = particle_attributes->particles[index].core.speed_linear * cos(radians);
        speed_y = particle_attributes->particles[index].core.speed_linear * sin(radians);
        speed_x += (particle_attributes->particles[index].core.gravity_x * real_elapsed_begin);
        speed_y += (particle_attributes->particles[index].core.gravity_y * real_elapsed_begin);
        particle_attributes->particles[index].core.position_x += (speed_x * real_elapsed_update);
        particle_attributes->particles[index].core.position_y += (speed_y * real_elapsed_update);
        memcpy(&(particle_attributes->particles[index].update), &current, sizeof(struct timeval));
      } else
        particle_attributes->particles[index].alive = d_false;
    } else if ((generated < max_particles) &&
               ((particle_attributes->particles[index].was_alive == d_false) || (particle_attributes->single_shoot == d_false))) {
      particle_attributes->particles[index].was_alive = d_true;
      memcpy(&(particle_attributes->particles[index].born), &current, sizeof(struct timeval));
      memcpy(&(particle_attributes->particles[index].update), &current, sizeof(struct timeval));
      particle_attributes->particles[index].core.position_x = d_particle_randomizeF(particle_attributes, position_x) + local_position_x;
      particle_attributes->particles[index].core.position_y = d_particle_randomizeF(particle_attributes, position_y) + local_position_y;
      particle_attributes->particles[index].core.zoom = d_particle_randomizeF(particle_attributes, zoom);
      particle_attributes->particles[index].core.angle = d_particle_randomizeF(particle_attributes, angle);
      particle_attributes->particles[index].core.gravity_x = d_particle_randomizeF(particle_attributes, gravity_x);
      particle_attributes->particles[index].core.gravity_y = d_particle_randomizeF(particle_attributes, gravity_y);
      particle_attributes->particles[index].core.direction_angle = d_particle_randomizeF(particle_attributes, direction_angle);
      particle_attributes->particles[index].core.speed_linear = d_particle_randomizeF(particle_attributes, speed_linear);
      particle_attributes->particles[index].core.speed_direction_angle = d_particle_randomizeF(particle_attributes, speed_direction_angle);
      particle_attributes->particles[index].core.speed_zoom = d_particle_randomizeF(particle_attributes, speed_zoom);
      particle_attributes->particles[index].core.speed_angle = d_particle_randomizeF(particle_attributes, speed_angle);
      particle_attributes->particles[index].core.mask_R = d_particle_randomizeF(particle_attributes, mask_R);
      particle_attributes->particles[index].core.mask_G = d_particle_randomizeF(particle_attributes, mask_G);
      particle_attributes->particles[index].core.mask_B = d_particle_randomizeF(particle_attributes, mask_B);
      particle_attributes->particles[index].core.mask_A = d_particle_randomizeF(particle_attributes, mask_A);
      particle_attributes->particles[index].core.speed_R = d_particle_randomizeF(particle_attributes, speed_R);
      particle_attributes->particles[index].core.speed_G = d_particle_randomizeF(particle_attributes, speed_G);
      particle_attributes->particles[index].core.speed_B = d_particle_randomizeF(particle_attributes, speed_B);
      particle_attributes->particles[index].core.speed_A = d_particle_randomizeF(particle_attributes, speed_A);
      particle_attributes->particles[index].core.lifetime = d_particle_randomizeF(particle_attributes, lifetime);
      if (particle_attributes->configuration.initializer)
        particle_attributes->configuration.initializer(&(particle_attributes->particles[index].core));
      particle_attributes->particles[index].alive = d_true;
      ++generated;
    }
  }
  return self;
}
コード例 #15
0
ファイル: drawable.obj.c プロジェクト: haifenghuang/miranda
d_define_method(drawable, set_dimension_h)(struct s_object *self, double h) {
	d_using(drawable);
	d_call(&(drawable_attributes->point_dimension), m_point_set_y, h);
	return self;
}
コード例 #16
0
ファイル: track.obj.c プロジェクト: nardinan/miranda
d_define_method(track, set_loops)(struct s_object *self, int loops) {
  d_using(track);
  track_attributes->loops = loops;
  return self;
}
コード例 #17
0
ファイル: drawable.obj.c プロジェクト: haifenghuang/miranda
d_define_method(drawable, get_scaled_dimension)(struct s_object *self, double *w, double *h) {
	d_using(drawable);
	d_call(&(drawable_attributes->point_normalized_dimension), m_point_get, w, h);
	return self;
}
コード例 #18
0
d_define_method(mutex, trylock)(struct s_object *self) {
    d_using(mutex);
    return (pthread_mutex_trylock(&(mutex_attributes->mutex)) == 0)?self:NULL;
}
コード例 #19
0
ファイル: drawable.obj.c プロジェクト: haifenghuang/miranda
d_define_method(drawable, set_angle)(struct s_object *self, double angle) {
	d_using(drawable);
	drawable_attributes->angle = fmod(angle, 360.0);
	return self;
}
コード例 #20
0
d_define_method(mutex, unlock)(struct s_object *self) {
    d_using(mutex);
    pthread_mutex_unlock(&(mutex_attributes->mutex));
    return self;
}
コード例 #21
0
ファイル: drawable.obj.c プロジェクト: haifenghuang/miranda
d_define_method(drawable, flip)(struct s_object *self, enum e_drawable_flips flip) {
	d_using(drawable);
	drawable_attributes->flip = flip;
	return self;
}
コード例 #22
0
ファイル: label.obj.c プロジェクト: haifenghuang/miranda
d_define_method_override(label, set_maskA)(struct s_object *self, unsigned int alpha) {
	d_using(label);
	label_attributes->last_mask_A = alpha;
	SDL_SetTextureAlphaMod(label_attributes->image, alpha);
	return self;
}
コード例 #23
0
ファイル: drawable.obj.c プロジェクト: haifenghuang/miranda
d_define_method(drawable, get_flags)(struct s_object *self) {
	d_using(drawable);
	d_cast_return(drawable_attributes->flags);
}
コード例 #24
0
ファイル: particle.obj.c プロジェクト: nardinan/miranda
d_define_method_override(particle, set_blend)(struct s_object *self, enum e_drawable_blends blend) {
  d_using(particle);
  struct s_drawable_attributes *drawable_attributes = d_cast(self, drawable);
  drawable_attributes->last_blend = blend;
  return d_call(particle_attributes->drawable_core, m_drawable_set_blend, blend);
}