ref: b31dbda66878a93ba307ee9875fb41585f6d2edf
parent: 2866d5d0666715ecb66540ab5f5db4b0df3ed8ca
author: LTCHIPS <ltchips994@gmail.com>
date: Mon May 7 14:05:19 EDT 2018
more tweaks to rotate scale code
--- a/rott/modexlib.c
+++ b/rott/modexlib.c
@@ -1039,24 +1039,79 @@
void CalcTics (void);
-void DoScreenRotateZoom(int startAngle, int endAngle, int startScale, int endScale, int time, boolean zoomInOrOut)
+
+
+//void DrawRotatedScreen(int cx, int cy, byte *destscreen, int angle, int scale, int masked)
+
+void DoScreenRotateScale(int w, int h, SDL_Texture * tex, int angle, float scale)
{
+
+/*
+ printf("center x: %d \n", w);
+ printf("center y: %d \n", h);
+ printf("angle: %d \n", angle);
+ printf("scale: %f \n", scale);
+*/
+
+ SDL_RenderClear(renderer);
+
+ SDL_Rect output;
+
+
+ output.w = w;
+
+ output.h = h;
+
+/*
+ printf("width: %d \n", output.w);
+ printf("height: %d \n", output.h);
+*/
+
+ output.x = (iGLOBAL_SCREENWIDTH - output.w)/2;
+
+ output.y = (iGLOBAL_SCREENHEIGHT - output.h)/2;
+
+ SDL_RenderCopyEx(renderer, tex, NULL, &output, angle, NULL, SDL_FLIP_NONE);
+
+ SDL_RenderPresent(renderer);
+
+
+}
+
+
+void DoScreenRotateZoom(int startAngle, int endAngle, int startScale, int endScale, int time)
+{
//STUB_FUNCTION;
/*
+ if (startScale > endScale)
+ {
+ printf("STARTSCALE IS SMALLER THAN ENDSCALE!\n");
+ //int tempStart = startScale;
+ //int tempEnd = endScale;
+ //startScale = endScale;
+ endScale = startScale * endScale;
+ }
+*/
+
+
printf("startAngle: %d \n", startAngle);
printf("endAngle: %d \n", endAngle);
printf("startScale: %d \n", startScale);
printf("endScale: %d \n", endScale);
printf("time: %d \n", time);
-*/
+
+
int angle = startAngle;
float scalestep =(float)((endScale - startScale)/time);
+ if (startScale > endScale)
+ scalestep = (float)((startScale - endScale)/time)*6; //added * 6 because it wasn't zooming in as much as OG ROTT did
+
int scale = startScale;
int anglestep = (endAngle - startAngle)/(time*6); //added *6 because it was rotating too effing fast
@@ -1063,10 +1118,8 @@
//float scalestep =(float)((endScale - startScale)/time);
-/*
printf("anglestep: %d \n", anglestep);
printf("scalestep: %f \n", scalestep);
-*/
CalcTics();
@@ -1074,33 +1127,31 @@
int i;
+ SDL_Texture * newTex = SDL_CreateTextureFromSurface(renderer, sdl_surface);
+
for (i=0; i<time; i+=tics)
{
//printf("tics: %d\n", tics);
-
- SDL_Texture * newTex = SDL_CreateTextureFromSurface(renderer, sdl_surface);
SDL_RenderClear(renderer);
SDL_Rect output;
- //int scaleShft = (scale)>>6;
+ float factor = 0;
- float factor;
-
-
- if (zoomInOrOut)
+ if (startScale > endScale)
{
- factor = ((float)(scale)/(endScale));
-
+ factor = 1 + ((float)(scale)/(abs(startScale - endScale)));
}
else
{
- factor = 1 - ((float)(scale)/(endScale));
+ factor = ((float)(scale)/(abs(startScale - endScale)));
+
}
- //printf("factor: %f \n", factor);
+ printf("factor: %f \n", factor);
+
float width = iGLOBAL_SCREENWIDTH * factor;
float height = iGLOBAL_SCREENHEIGHT * factor;
@@ -1122,8 +1173,8 @@
SDL_RenderPresent(renderer);
- SDL_DestroyTexture(newTex);
+
scale+=(scalestep);
angle+=(anglestep);
@@ -1131,7 +1182,14 @@
}
+ SDL_DestroyTexture(newTex);
+
//RenderSurface(); //render the image straight...yeah yeah i know that's cheating
}
+const SDL_Renderer * GetRenderer(void)
+{
+ return renderer;
+
+}
\ No newline at end of file
--- a/rott/rt_draw.c
+++ b/rott/rt_draw.c
@@ -2729,7 +2729,7 @@
========================
*/
-void RotateScreen(int startAngle, int endAngle, int startScale, int endScale, int time, boolean zoomInOrOut);
+void RotateScreen(int startAngle, int endAngle, int startScale, int endScale, int time, int option);
int playerview=0;
void ThreeDRefresh (void)
{
@@ -2838,7 +2838,7 @@
bufferofs-=screenofs;
DrawPlayScreen (true);
//void RotateScreen(int startAngle, int endAngle, int startScale, int endScale, int time);
- RotateScreen(0,FINEANGLES,FINEANGLES,FINEANGLES*8,(VBLCOUNTER*3)/4, true);
+ RotateScreen(0,FINEANGLES,FINEANGLES,FINEANGLES*8,(VBLCOUNTER*3)/4, 0);
//RotateBuffer(0,FINEANGLES,FINEANGLES*8,FINEANGLES,(VBLCOUNTER*3)/4);
bufferofs+=screenofs;
fizzlein = false;
@@ -3366,22 +3366,94 @@
SetFastTics(savetics);
}
-void DoScreenRotateZoom(int startAngle, int endAngle, int startScale, int endScale, int time, boolean zoomInOrOut);
+const SDL_Renderer * GetRenderer(void);
-void RotateScreen(int startAngle, int endAngle, int startScale, int endScale, int time, boolean zoomInOrOut)
+void DoScreenRotateZoom(int startAngle, int endAngle, int startScale, int endScale, int time);
+
+void DoScreenRotateScale(int cx, int cy, SDL_Texture * tex, int angle, float scale);
+
+
+//A note about option
+//When option is set to
+// 0: factor is set to equal scale value every time. This is good for starting from a small screen to eventually grow to a larger screen.
+// 1: factor is set to equal 1 + scale value. This is good for zooming into the screen.
+// 2: factor is set to equal 1 - scale value. This is good for zooming out from the screen.
+void RotateScreen(int startAngle, int endAngle, int startScale, int endScale, int time, int option)
{
DisableScreenStretch();
- //printf("%d \n", startScale);
- //printf("%d \n", endScale);
+ //STUB_FUNCTION;
-//RotateScreen(0, 0, (FINEANGLES), (FINEANGLES>>6), (VBLCOUNTER*(1+slowrate)));
+ printf("startAngle: %d \n", startAngle);
+ printf("endAngle: %d \n", endAngle);
+ printf("startScale: %d \n", startScale);
+ printf("endScale: %d \n", endScale);
+ printf("time: %d \n", time);
+
+ int angle = startAngle;
+
+ float scalestep = (float)((endScale/endScale) - ((float)startScale/(float)endScale))/((float)time);
+
+ float scale = ((float)startScale/(float)endScale);
+
+ if (option == 1)
+ {
+ scale = 1.0;
+
+ }
+
+ int anglestep = (endAngle - startAngle)/(time*6); //added *6 because it was rotating too effing fast
+
+ printf("anglestep: %d \n", anglestep);
+ printf("scalestep: %f \n", scalestep);
+ printf("startingScale: %f \n", scale);
+
+ CalcTics();
+ CalcTics();
+
+ int i;
+
+ int x;
+
+ int y;
+
+ SDL_Texture * newTex = SDL_CreateTextureFromSurface((SDL_Renderer *) GetRenderer(), sdl_surface);
+
+ for (i=0; i<time; i+=tics)
+ {
+ float factor;
+
+ if (option == 0)
+ factor = scale;
+ if (option == 1)
+ factor = 1 + scale*-1;
+ if (option == 2)
+ factor = 1 - scale;
+ else
+ factor = scale;
+
+
+
+ printf("factor: %f \n", factor);
+
+ x = (int)((float) iGLOBAL_SCREENWIDTH * factor);
+
+ y = (int)((float) (iGLOBAL_SCREENHEIGHT * factor));
+
+ DoScreenRotateScale(x, y, newTex, angle, factor);
+
+ scale+=(scalestep);
+ if (angle < endAngle)
+ angle+=(anglestep);
+
+ CalcTics();
+
+ }
+
+ //DoScreenRotateScale(iGLOBAL_SCREENWIDTH, iGLOBAL_SCREENHEIGHT, newTex, 0, 1.0);
+
+ SDL_DestroyTexture(newTex);
- //DoScreenRotateZoom(0, 0, (FINEANGLES), (FINEANGLES>>6), (VBLCOUNTER*(1+3)));
- DoScreenRotateZoom(startAngle, endAngle, startScale, endScale, time, zoomInOrOut);
-
-
-
}
@@ -3407,6 +3479,9 @@
// SetTextMode ( );
c = FixedMulShift(scale,costable[angle],11);
s = FixedMulShift(scale,sintable[angle],11);
+
+ printf("c: %d \n", c);
+ printf("s: %d \n", s);
// c = c/2; //these values are to rotate degres or?
// s = s/2;
@@ -3426,7 +3501,7 @@
else if ((iGLOBAL_SCREENWIDTH == 1024 )&&(masked == false)) {
xst = (((-cx)*s)+((410)<<16))-(cy*c);// 1024/768=1.3333
xct = (((-cx)*c)+((500)<<16)+(1<<18)-(1<<16))+(cy*s);
- }//388 397
+ }//388 397
else if ((iGLOBAL_SCREENWIDTH >= 1152) && (masked == false))
{
xst = (((-cx)*s)+((432)<<16))-(cy*c);
--- a/rott/rt_game.c
+++ b/rott/rt_game.c
@@ -4445,7 +4445,7 @@
#define DEATHROTATE 6
-void RotateScreen(int startAngle, int endAngle, int startScale, int endScale, int time, boolean zoomInOrOut);
+void RotateScreen(int startAngle, int endAngle, int startScale, int endScale, int time, int option);
extern boolean dopefish;
void Died (void)
@@ -4674,12 +4674,14 @@
rng = RandomNumber ("Died",0);
+ rng = 191;
+
//zooms in on screen
if (pstate->falling==true)
{
printf("doing death 0 rotate \n");
//RotateBuffer (0, 0, (FINEANGLES), (FINEANGLES>>6), (VBLCOUNTER*(1+slowrate)));
- RotateScreen (0, 0, (FINEANGLES), (FINEANGLES>>6), (VBLCOUNTER*(1+slowrate)), true);
+ RotateScreen (0, 0, (FINEANGLES), (FINEANGLES>>6), (VBLCOUNTER*(1+slowrate)), 1);
SD_Play (SD_PLAYERTCDEATHSND+(pstate->player));
pstate->falling=false;
}
@@ -4688,7 +4690,7 @@
{
printf("doing death 1 rotate \n");
//RotateBuffer (0, 0, (FINEANGLES>>6), (FINEANGLES), (VBLCOUNTER*(2+slowrate)));
- RotateScreen (0, 0, (FINEANGLES), (FINEANGLES*64), (VBLCOUNTER*(2+slowrate)), false);
+ RotateScreen (0, 0, (FINEANGLES), (FINEANGLES*64), (VBLCOUNTER*(2+slowrate)), 2);
}
//zooms in on screen
@@ -4696,7 +4698,7 @@
{
printf("doing death 2 rotate \n");
//RotateBuffer (0, 0, (FINEANGLES), (FINEANGLES>>6), (VBLCOUNTER*(1+slowrate)));
- RotateScreen(0, 0, (FINEANGLES), (FINEANGLES>>6), (VBLCOUNTER*(1+slowrate)), true);
+ RotateScreen(0, 0, (FINEANGLES), (FINEANGLES>>6), (VBLCOUNTER*(1+slowrate)), 1);
}
//zooms out with spinning
@@ -4704,7 +4706,7 @@
{
printf("doing death 3 rotate \n");
//RotateBuffer(0, (FINEANGLES*4), (FINEANGLES), (FINEANGLES*64), (VBLCOUNTER*(3+slowrate)));
- RotateScreen(0, (FINEANGLES*4), (FINEANGLES), (FINEANGLES*64), (VBLCOUNTER*(3+slowrate)), false);
+ RotateScreen(0, (FINEANGLES*4), (FINEANGLES), (FINEANGLES*64), (VBLCOUNTER*(3+slowrate)), 2);
}
//fade to red
else
@@ -4734,17 +4736,28 @@
SD_Play (SD_GAMEOVERSND);
rng=RandomNumber("Died",0);
if (rng<64)
+ {
+ printf("GAME OVER SEQUENCE 1 \n");
//RotateBuffer(0,(FINEANGLES>>1),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)));
- RotateScreen(0,(FINEANGLES>>1),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)), false);
+ RotateScreen(0,(FINEANGLES>>1),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)), 2);
+ }
else if (rng<128)
+ {
+ printf("GAME OVER SEQUENCE 2 \n");
VL_FadeToColor (VBLCOUNTER*3, 255, 255, 255);
+ }
else if (rng<192)
+ {
+ printf("GAME OVER SEQUENCE 3 \n");
//RotateBuffer(0,(FINEANGLES*2),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)));
- RotateScreen(0,(FINEANGLES*2),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)), false);
+ RotateScreen(0,(FINEANGLES*2),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)), 2);
+ }
else
+ {
+ printf("GAME OVER SEQUENCE 4 \n");
//RotateBuffer(0,(FINEANGLES*2),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)));
- RotateScreen(0,(FINEANGLES*2),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)), false);
-
+ RotateScreen(0,(FINEANGLES*2),(FINEANGLES),(FINEANGLES*64),(VBLCOUNTER*(3+slowrate)), 2);
+ }
screenfaded=false;
VL_FadeOut (0, 255, 0,0,0,VBLCOUNTER>>1);