-/*
+/*
* Copyright (C) 2003 Robert Kooima
*
* NEVERBALL is free software; you can redistribute it and/or modify
/*---------------------------------------------------------------------------*/
-static GLfloat gcoltab[] = {0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f};
-
void part_reset(float h)
{
int i;
float t = rnd(+0.1f, +1.0f);
float a = rnd(-1.0f * PI, +1.0f * PI);
float w = rnd(-2.0f * PI, +2.0f * PI);
- int k = i % 6;
part_goal[i].t = t;
part_goal[i].a = V_DEG(a);
part_goal[i].w = V_DEG(w);
- part_goal[i].c[0] = gcoltab[k];
- part_goal[i].c[1] = gcoltab[k+1];
- part_goal[i].c[2] = gcoltab[k+2];
+ part_goal[i].c[0] = 1.0f;
+ part_goal[i].c[1] = 1.0f;
+ part_goal[i].c[2] = 0.0f;
part_goal[i].p[0] = fsinf(a);
part_goal[i].p[1] = (1.f - t) * h;
memset(part_coin, 0, PART_MAX_COIN * sizeof (struct part));
memset(part_goal, 0, PART_MAX_GOAL * sizeof (struct part));
- part_text = make_image_from_file(NULL, NULL, NULL, NULL, IMG_PART);
+ part_text = make_image_from_file(IMG_PART);
part_list = glGenLists(1);
glNewList(part_list, GL_COMPILE);
/*---------------------------------------------------------------------------*/
-static void part_draw(const float p[3], const float c[3],
- float a, float r, float rx, float ry, float rz)
+static void part_draw(const float *M,
+ const float *p, float r, float rz)
{
glPushMatrix();
{
glTranslatef(r * p[0], p[1], r * p[2]);
- glRotatef(ry, 0.f, 1.f, 0.f);
- glRotatef(rx, 1.f, 0.f, 0.f);
+ glMultMatrixf(M);
glRotatef(rz, 0.f, 0.f, 1.f);
- glColor4f(c[0], c[1], c[2], a);
-
glCallList(part_list);
}
glPopMatrix();
}
-void part_draw_coin(float rx, float ry)
+void part_draw_coin(const float *M, float t)
{
- float r = (float) SDL_GetTicks() / 1000.f;
int i;
- glPushAttrib(GL_LIGHTING_BIT | GL_DEPTH_BUFFER_BIT);
- {
- glDisable(GL_LIGHTING);
- glEnable(GL_COLOR_MATERIAL);
-
- glDepthMask(GL_FALSE);
- glBindTexture(GL_TEXTURE_2D, part_text);
-
- for (i = 0; i < PART_MAX_COIN; i++)
- if (part_coin[i].t > 0.f)
- part_draw(part_coin[i].p,
- part_coin[i].c,
- part_coin[i].t,
- 1.f, rx, ry, r * part_coin[i].w);
- }
- glPopAttrib();
+ glBindTexture(GL_TEXTURE_2D, part_text);
+
+ for (i = 0; i < PART_MAX_COIN; i++)
+ if (part_coin[i].t > 0.f)
+ {
+ glColor4f(part_coin[i].c[0],
+ part_coin[i].c[1],
+ part_coin[i].c[2],
+ part_coin[i].t);
+
+ part_draw(M, part_coin[i].p, 1.0f, t * part_coin[i].w);
+ }
}
-void part_draw_goal(float rx, float ry, float radius, float a, int spe)
+void part_draw_goal(const float *M, float radius, float a, float t)
{
- float r = (float) SDL_GetTicks() / 1000.f;
int i;
- GLfloat yel[3] = {1.0f, 1.0f, 0.0f};
-
- glPushAttrib(GL_LIGHTING_BIT | GL_DEPTH_BUFFER_BIT);
- {
- glDisable(GL_LIGHTING);
- glEnable(GL_COLOR_MATERIAL);
+ glBindTexture(GL_TEXTURE_2D, part_text);
- glDepthMask(GL_FALSE);
- glBindTexture(GL_TEXTURE_2D, part_text);
+ glColor4f(1.0f, 1.0f, 0.0f, a);
- for (i = 0; i < PART_MAX_GOAL; i++)
- if (part_goal[i].t > 0.f)
- part_draw(part_goal[i].p,
- spe ? part_goal[i].c : yel,
- a,
- radius - 0.05f, rx, ry, r * part_goal[i].w);
- }
- glPopAttrib();
+ for (i = 0; i < PART_MAX_GOAL; i++)
+ if (part_goal[i].t > 0.0f)
+ part_draw(M, part_goal[i].p, radius - 0.05f, t * part_goal[i].w);
}
/*---------------------------------------------------------------------------*/