def draw_xy_axis(self): aFont = pygame.font.Font(None, 16) for i in range(-10, 11): pos = self.translate_xy_pos_to_screen(vec2d(i,-10)) pos2 = self.translate_xy_pos_to_screen(vec2d(i,10)) label = aFont.render('%s' % i, 1, (10, 10, 10)) self.screen.blit(label, pos) pygame.draw.line(self.screen, (0,0,0), pos, pos2) pos = self.translate_xy_pos_to_screen(vec3d(-10,i,0)) pos2 = self.translate_xy_pos_to_screen(vec3d(10,i,0)) label = aFont.render('%s' % i, 1, (10, 10, 10)) self.screen.blit(label, pos) pygame.draw.line(self.screen, (0,0,0), pos, pos2)
def draw_xy_axis(self): aFont = pygame.font.Font(None, 16) for i in range(-10, 11): pos = self.translate_xy_pos_to_screen(vec2d(i, -10)) pos2 = self.translate_xy_pos_to_screen(vec2d(i, 10)) label = aFont.render('%s' % i, 1, (10, 10, 10)) self.screen.blit(label, pos) pygame.draw.line(self.screen, (0, 0, 0), pos, pos2) pos = self.translate_xy_pos_to_screen(vec3d(-10, i, 0)) pos2 = self.translate_xy_pos_to_screen(vec3d(10, i, 0)) label = aFont.render('%s' % i, 1, (10, 10, 10)) self.screen.blit(label, pos) pygame.draw.line(self.screen, (0, 0, 0), pos, pos2)
def update(self): self.time += self.dt self.draw_wind_labels() self.draw_xz_fountain() self.draw_xz_axis() self.draw_xy_axis() self.draw_lines() self.draw_time_label() x_wind_did_change = self.update_x_wind() z_wind_did_change = self.update_z_wind() if x_wind_did_change or z_wind_did_change: self.adjust_initial_droplet_velocity() if len(self.droplets) < self.max_drops: new_d = Droplet(uniform(-5, 5), self.v, uniform(-5, 5)) self.draw_xy_droplet(vec2d(0, 0), new_d.pos) self.droplets.append(new_d) for d in self.droplets: oldpos = d.pos d.tx += self.dt d.ty += self.dt d.tz += self.dt if x_wind_did_change: d.tx = self.dt d.xp = oldpos.x if z_wind_did_change: d.tz = self.dt d.zp = oldpos.z d.pos = vec3d(d.x(d.tx, self.we, self.ww), d.y(d.ty), d.z(d.tz, self.wn, self.ws)) self.draw_xy_droplet(oldpos, d.pos) self.draw_xz_droplet(oldpos, d.pos) if d.pos.y <= 0 or self.translate_xy_pos_to_screen( d.pos).x >= self.w or self.translate_xy_pos_to_screen( d.pos).x <= 0: pygame.draw.circle( self.screen, (255, 255, 255), self.translate_xy_pos_to_screen(d.pos).inttup(), self.radius) pygame.draw.circle( self.screen, (255, 255, 255), self.translate_xz_pos_to_screen(d.pos).inttup(), self.radius) self.droplets.remove(d)
def __init__(self, xs, ys, zs): #velocities self.xs = xs self.ys = ys self.zs = zs #current pos self.pos = vec3d(0,0,0) #time counters self.ty = 0 self.tx = 0 self.tz = 0 #starting pos self.xp = 0 self.yp = 0 self.zp = 0
def __init__(self, xs, ys, zs): #velocities self.xs = xs self.ys = ys self.zs = zs #current pos self.pos = vec3d(0, 0, 0) #time counters self.ty = 0 self.tx = 0 self.tz = 0 #starting pos self.xp = 0 self.yp = 0 self.zp = 0
def update(self): self.time += self.dt self.draw_wind_labels() self.draw_xz_fountain() self.draw_xz_axis() self.draw_xy_axis() self.draw_lines() self.draw_time_label() x_wind_did_change = self.update_x_wind() z_wind_did_change = self.update_z_wind() if x_wind_did_change or z_wind_did_change: self.adjust_initial_droplet_velocity() if len(self.droplets) < self.max_drops: new_d = Droplet(uniform(-5, 5), self.v, uniform(-5, 5)) self.draw_xy_droplet(vec2d(0,0), new_d.pos) self.droplets.append(new_d) for d in self.droplets: oldpos = d.pos d.tx += self.dt d.ty += self.dt d.tz += self.dt if x_wind_did_change: d.tx = self.dt d.xp = oldpos.x if z_wind_did_change: d.tz = self.dt d.zp = oldpos.z d.pos = vec3d(d.x(d.tx, self.we, self.ww), d.y(d.ty), d.z(d.tz, self.wn, self.ws)) self.draw_xy_droplet(oldpos, d.pos) self.draw_xz_droplet(oldpos, d.pos) if d.pos.y <= 0 or self.translate_xy_pos_to_screen(d.pos).x >= self.w or self.translate_xy_pos_to_screen(d.pos).x <= 0: pygame.draw.circle(self.screen, (255,255,255), self.translate_xy_pos_to_screen(d.pos).inttup(), self.radius) pygame.draw.circle(self.screen, (255,255,255), self.translate_xz_pos_to_screen(d.pos).inttup(), self.radius) self.droplets.remove(d)
def draw_xz_fountain(self): pos = self.translate_xz_pos_to_screen(vec3d(0, 0, 0)) pos2 = self.translate_xz_pos_to_screen(vec3d(2, 0, 4)) pygame.draw.circle(self.screen, (150, 150, 150), (pos.x, pos.y), 30)
def draw_xz_fountain(self): pos = self.translate_xz_pos_to_screen(vec3d(0,0,0)) pos2 = self.translate_xz_pos_to_screen(vec3d(2,0,4)) pygame.draw.circle(self.screen, (150,150,150), (pos.x, pos.y), 30)