696
727
balls[b].pos += push;
697
728
balls[b].frame += push / 2;
698
if (balls[b].frame > 100)
699
balls[b].frame -= 100;
729
if (balls[b].frame > ballAnimFrames)
730
balls[b].frame -= ballAnimFrames;
704
void BallPath::Render()
735
void BallPath::Render(bool render_balls, bool render_sprites, bool render_under, bool render_over)
706
737
glLoadIdentity();
708
739
glEnable(GL_TEXTURE_2D);
709
740
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
710
for (uint i = 0; i < balls.size(); ++i)
712
int pos = (int)balls[i].pos;
714
int fr = (int)balls[i].frame;
718
double ts = (ballOneTextureSize * 10.0) / double(ballTextureSize);
719
double tx = (double)((fr % 10) / 10.0f) * ts;
720
double ty = (double)((fr / 10) / 10.0f) * ts;
723
double bs = ((double)balls[i].size / (stepsPerBall)) * ballSize;
725
if (balls[i].pos < stepsPerBall)
727
bs = ((double)balls[i].pos / (stepsPerBall / 4)) * ballSize;
732
if (balls[i].pos > pthLen - stepsPerBall)
734
bs = ((double)(balls[i].pos - (pthLen - stepsPerBall))/ (stepsPerBall / 4)) * ballSize;
743
glTranslated(ballPath[pos].x, ballPath[pos].y, 1);
744
glBindTexture(GL_TEXTURE_2D, tex[balls[i].col]);
745
glScaled(bs, bs, bs);
746
glRotated(ballPath[pos].r, 0, 0, 1.0);
748
glTexCoord2d(tx, ty);
749
glVertex3d(-0.5, 0.5, 0);
750
glTexCoord2d(tx, ty + ts);
751
glVertex3d(-0.5, -0.5, 0);
752
glTexCoord2d(tx + ts, ty + ts);
753
glVertex3d(0.5, -0.5, 0);
754
glTexCoord2d(tx + ts, ty);
755
glVertex3d(0.5, 0.5, 0);
759
if (balls[i].bonus != BONUS_NONE)
742
for (uint i = 0; i < balls.size(); ++i)
744
uint pos = balls[i].upos();
746
int fr = (int)balls[i].frame;
747
if (fr > ballAnimFrames - 1)
750
// double ts = (ballOneTextureSize * 8.0) / double(ballTextureSize);
751
double ts = 1.0 / double(ballTextureCount);
752
double tx = (double)((fr % ballTextureCount)) * ts;
753
double ty = (double)((fr / ballTextureCount)) * ts;
756
double bs = ((double)balls[i].size / (stepsPerBall)) * ballSize;
758
if (balls[i].pos < stepsPerBall)
760
bs = ((double)balls[i].pos / (stepsPerBall / 4)) * ballSize;
765
if (balls[i].pos > pthLen - stepsPerBall)
767
bs = ((double)(balls[i].pos - (pthLen - stepsPerBall))/ (stepsPerBall / 4)) * ballSize;
773
bool render_this_ball = false;
777
render_this_ball = true;
779
if ((ballPath[pos].under || ballPath[pos].hidden) && !render_under)
780
render_this_ball = false;
782
if ((!ballPath[pos].under && !ballPath[pos].hidden) && !render_over)
783
render_this_ball = false;
786
if (render_this_ball)
761
788
glLoadIdentity();
762
789
glTranslated(ballPath[pos].x, ballPath[pos].y, 2);
790
glBindTexture(GL_TEXTURE_2D, tex[balls[i].col]);
791
if (ballPath[pos].under || ballPath[pos].hidden)
792
glTranslated(0.0, 0.0, -1);
763
794
glScaled(bs, bs, bs);
764
796
glRotated(ballPath[pos].r, 0, 0, 1.0);
765
glBindTexture(GL_TEXTURE_2D, tex[NBALLCOLORS + (balls[i].bonus - 1) ]);
766
798
glBegin(GL_QUADS);
799
glTexCoord2d(tx, ty);
768
800
glVertex3d(-0.5, 0.5, 0);
801
glTexCoord2d(tx, ty + ts);
770
802
glVertex3d(-0.5, -0.5, 0);
803
glTexCoord2d(tx + ts, ty + ts);
772
804
glVertex3d(0.5, -0.5, 0);
805
glTexCoord2d(tx + ts, ty);
774
806
glVertex3d(0.5, 0.5, 0);
809
if (balls[i].bonus != BONUS_NONE)
812
glTranslated(ballPath[pos].x, ballPath[pos].y, 2.1);
814
if (ballPath[pos].under || ballPath[pos].hidden)
815
glTranslated(0.0, 0.0, -1);
817
glScaled(bs, bs, bs);
818
glRotated(ballPath[pos].r, 0, 0, 1.0);
819
glBindTexture(GL_TEXTURE_2D, tex[NBALLCOLORS + (balls[i].bonus - 1) ]);
822
glVertex3d(-0.5, 0.5, 0);
824
glVertex3d(-0.5, -0.5, 0);
826
glVertex3d(0.5, -0.5, 0);
828
glVertex3d(0.5, 0.5, 0);
782
if (extraBallFading && balls[0].pos > stepsPerBall)
784
float alpha = float((extraBallFadeinTime - extraBallFadeinTimeout)) / float(extraBallFadeinTime);
785
int pos = (int)(alpha * (balls[0].pos - stepsPerBall));
787
double bs = ((double)balls[0].size / (stepsPerBall)) * ballSize;
788
double x = ballPath[pos].x;
789
double y = ballPath[pos].y;
790
double ts = ((ballOneTextureSize * 10.0) / double(ballTextureSize)) * 0.1;
794
glTranslated(x, y, 5);
795
glRotated(ballPath[pos].r, 0, 0, 1.0);
796
glScaled(bs, bs, bs);
797
glColor4f(1.0f, 1.0f, 1.0f, alpha);
798
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
799
glBindTexture(GL_TEXTURE_2D, tex[state.extraBall]);
802
glVertex3d(-0.5, 0.5, 0);
804
glVertex3d(-0.5, -0.5, 0);
805
glTexCoord2d(ts, ts);
806
glVertex3d(0.5, -0.5, 0);
808
glVertex3d(0.5, 0.5, 0);
810
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
837
if (extraBallFading && balls[0].pos > stepsPerBall)
839
float alpha = float((extraBallFadeinTime - extraBallFadeinTimeout)) / float(extraBallFadeinTime);
840
int pos = (int)(alpha * (balls[0].pos - stepsPerBall));
845
double bs = ((double)balls[0].size / (stepsPerBall)) * ballSize;
846
double x = ballPath[pos].x;
847
double y = ballPath[pos].y;
848
double ts = 1.0 / double(ballTextureCount);
851
glTranslated(x, y, 2);
853
bool render_this_ball = true;
855
if ((ballPath[pos].under || ballPath[pos].hidden) && !render_under)
856
render_this_ball = false;
858
if ((!ballPath[pos].under && !ballPath[pos].hidden) && !render_over)
859
render_this_ball = false;
861
if (ballPath[pos].under || ballPath[pos].hidden)
862
glTranslated(0.0, 0.0, -1);
864
if (render_this_ball)
866
glRotated(ballPath[pos].r, 0, 0, 1.0);
867
glScaled(bs, bs, bs);
868
glColor4f(1.0f, 1.0f, 1.0f, alpha);
869
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
870
glBindTexture(GL_TEXTURE_2D, tex[state.extraBall]);
873
glVertex3d(-0.5, 0.5, 0);
875
glVertex3d(-0.5, -0.5, 0);
876
glTexCoord2d(ts, ts);
877
glVertex3d(0.5, -0.5, 0);
879
glVertex3d(0.5, 0.5, 0);
881
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
814
886
vector<Explosion>::iterator expl;
817
for (expl = explosions.begin(); expl != explosions.end(); ++expl)
819
if (expl->frame < 17)
890
for (expl = explosions.begin(); expl != explosions.end(); ++expl)
821
double tx = (expl->frame % 4);
822
double ty = (expl->frame / 4);
828
glTranslated(expl->x, expl->y, z);
829
glRotated(expl->r, 0.0, 0.0, 1.0);
830
glBindTexture(GL_TEXTURE_2D, tex[NBALLCOLORS + BONUS_BOMB]);
831
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
832
glColor4d(1.0, 1.0, 1.0, 0.5);
833
glScaled(expl->s, expl->s, 1.0);
836
glTexCoord2d(tx, ty);
837
glVertex3d(-0.5, 0.5, 0);
838
glTexCoord2d(tx, ty + 0.25);
839
glVertex3d(-0.5, -0.5, 0);
840
glTexCoord2d(tx + 0.25, ty + 0.25);
841
glVertex3d(0.5, -0.5, 0);
842
glTexCoord2d(tx + 0.25, ty);
843
glVertex3d(0.5, 0.5, 0);
892
if (expl->frame < 17)
894
double tx = (expl->frame % 4);
895
double ty = (expl->frame / 4);
901
glTranslated(expl->x, expl->y, z);
902
glRotated(expl->r, 0.0, 0.0, 1.0);
903
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
904
glBindTexture(GL_TEXTURE_2D, tex[NBALLCOLORS + BONUS_BOMB]);
905
// glBindTexture(GL_TEXTURE_2D, tex[NBALLCOLORS + 1]);
906
glColor4d(1.0, 1.0, 1.0, 0.7);
907
glScaled(expl->s, expl->s, 1.0);
910
glTexCoord2d(tx, ty);
911
glVertex3d(-0.5, 0.5, 0);
912
glTexCoord2d(tx, ty + 0.25);
913
glVertex3d(-0.5, -0.5, 0);
914
glTexCoord2d(tx + 0.25, ty + 0.25);
915
glVertex3d(0.5, -0.5, 0);
916
glTexCoord2d(tx + 0.25, ty);
917
glVertex3d(0.5, 0.5, 0);
920
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
852
926
vector<PointSprite>::iterator psi;
854
for (psi = pointSprites.begin(); psi != pointSprites.end(); ++psi)
928
for (psi = pointSprites.begin(); psi != pointSprites.end(); ++psi)
858
float alpha = float(psi->time) / float(pointSpriteFadeoutTime);
860
glColor4f(1.0, 1.0, 1.0, alpha);
862
glTranslated(psi->x, psi->y, 50);
863
glScaled(0.1, 0.1, 0.1);
866
sprintf(scoretxt, "%d", psi->points);
867
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
868
font3->Render(scoretxt);
869
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
932
float alpha = float(psi->time) / float(pointSpriteFadeoutTime);
934
glColor4f(1.0, 1.0, 1.0, alpha);
936
glTranslated(psi->x, psi->y, 50);
937
glScaled(0.1, 0.1, 0.1);
940
sprintf(scoretxt, "%d", psi->points);
941
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
942
font3->Render(scoretxt);
943
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
873
947
glDisable(GL_TEXTURE_2D);