Lines Matching refs:sp
58 #define X(t,b) (sp->x[(t)*sp->beecount+(b)])
59 #define Y(t,b) (sp->y[(t)*sp->beecount+(b)])
86 swarmstruct *sp = &swarms[screen];
89 sp->startTime = seconds();
92 sp->beecount = (uint_t) batchcount;
95 sp->width = xgwa.width;
96 sp->height = xgwa.height;
100 XFillRectangle(dsp, win, Scr[screen].gc, 0, 0, sp->width, sp->height);
104 if (!sp->segs) {
105 sp->segs = malloc(sizeof(XSegment) * sp->beecount);
106 sp->old_segs = malloc(sizeof(XSegment) * sp->beecount);
107 sp->x = malloc(sizeof(short) * sp->beecount * TIMES);
108 sp->y = malloc(sizeof(short) * sp->beecount * TIMES);
109 sp->xv = malloc(sizeof(short) * sp->beecount);
110 sp->yv = malloc(sizeof(short) * sp->beecount);
112 if ((sp->segs == NULL) || (sp->old_segs == NULL) ||
113 (sp->x == NULL) || (sp->y == NULL) ||
114 (sp->xv == NULL) || (sp->yv == NULL)) {
121 sp->wx[0] = (short) (BORDER + random() % (sp->width - 2 * BORDER));
122 sp->wy[0] = (short) (BORDER + random() % (sp->height - 2 * BORDER));
123 sp->wx[1] = sp->wx[0];
124 sp->wy[1] = sp->wy[0];
125 sp->wxv = 0;
126 sp->wyv = 0;
129 for (b = 0; b < sp->beecount; b++) {
130 X(0, b) = (short) (random() % sp->width);
132 Y(0, b) = (short) (random() % sp->height);
134 sp->xv[b] = (short) RAND(7);
135 sp->yv[b] = (short) RAND(7);
144 swarmstruct *sp = &swarms[screen];
149 sp->wx[2] = sp->wx[1];
150 sp->wx[1] = sp->wx[0];
151 sp->wy[2] = sp->wy[1];
152 sp->wy[1] = sp->wy[0];
154 sp->wxv += (short) RAND(WASPACC);
155 sp->wyv += (short) RAND(WASPACC);
158 if (sp->wxv > WASPVEL)
159 sp->wxv = WASPVEL;
160 if (sp->wxv < -WASPVEL)
161 sp->wxv = -WASPVEL;
162 if (sp->wyv > WASPVEL)
163 sp->wyv = WASPVEL;
164 if (sp->wyv < -WASPVEL)
165 sp->wyv = -WASPVEL;
168 sp->wx[0] = (short) (sp->wx[1] + sp->wxv);
169 sp->wy[0] = (short) (sp->wy[1] + sp->wyv);
172 if ((sp->wx[0] < BORDER) || (sp->wx[0] > sp->width - BORDER - 1)) {
173 sp->wxv = -sp->wxv;
174 sp->wx[0] += sp->wxv;
176 if ((sp->wy[0] < BORDER) || (sp->wy[0] > sp->height - BORDER - 1)) {
177 sp->wyv = -sp->wyv;
178 sp->wy[0] += sp->wyv;
181 sp->xv[random() % sp->beecount] += (short) RAND(3);
182 sp->yv[random() % sp->beecount] += (short) RAND(3);
185 for (b = 0; b < sp->beecount; b++) {
196 dx = sp->wx[1] - X(1, b);
197 dy = sp->wy[1] - Y(1, b);
201 sp->xv[b] += (dx * BEEACC) / distance;
202 sp->yv[b] += (dy * BEEACC) / distance;
205 if (sp->xv[b] > BEEVEL)
206 sp->xv[b] = BEEVEL;
207 if (sp->xv[b] < -BEEVEL)
208 sp->xv[b] = -BEEVEL;
209 if (sp->yv[b] > BEEVEL)
210 sp->yv[b] = BEEVEL;
211 if (sp->yv[b] < -BEEVEL)
212 sp->yv[b] = -BEEVEL;
215 X(0, b) = X(1, b) + sp->xv[b];
216 Y(0, b) = Y(1, b) + sp->yv[b];
219 sp->segs[b].x1 = X(0, b);
220 sp->segs[b].y1 = Y(0, b);
221 sp->segs[b].x2 = X(1, b);
222 sp->segs[b].y2 = Y(1, b);
223 sp->old_segs[b].x1 = X(1, b);
224 sp->old_segs[b].y1 = Y(1, b);
225 sp->old_segs[b].x2 = X(2, b);
226 sp->old_segs[b].y2 = Y(2, b);
231 sp->wx[1], sp->wy[1], sp->wx[2], sp->wy[2]);
232 XDrawSegments(dsp, win, Scr[screen].gc, sp->old_segs, (int) sp->beecount);
236 sp->wx[0], sp->wy[0], sp->wx[1], sp->wy[1]);
238 XSetForeground(dsp, Scr[screen].gc, Scr[screen].pixels[sp->pix]);
239 if (++sp->pix >= Scr[screen].npixels)
240 sp->pix = 0;
242 XDrawSegments(dsp, win, Scr[screen].gc, sp->segs, (int) sp->beecount);