Advertisement
NovaYoshi

mode 7

Apr 24th, 2017
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.96 KB | None | 0 0
  1. void mode_7(SDL_Texture *Tile, int ScrollX, int ScrollY, int CenterX, int CenterY, double ScaleX, double ScaleY, double Angle) {
  2.   SDL_SetRenderDrawColor(ScreenRenderer, 64, 64, 64, 255);
  3.   SDL_RenderClear(ScreenRenderer);
  4.  
  5.   double M7A = +cos(Angle)*ScaleX;
  6.   double M7B = +sin(Angle)*ScaleX;
  7.   double M7C = -sin(Angle)*ScaleY;
  8.   double M7D = +cos(Angle)*ScaleY;
  9. /*
  10.   ( VRAM.X )  =  ( M7A M7B )  *  ( ScreenX+ScrollX-CenterX )  +  ( CenterX )
  11.   ( VRAM.Y )     ( M7C M7D )     ( ScreenY+ScrollY-CenterY )     ( CenterY )
  12. */
  13.  
  14.   for(int ScreenY=0; ScreenY<ScreenHeight; ScreenY++) {
  15.     double temp1 = 0+ScrollX-CenterX;
  16.     double temp2 = ScreenY+ScrollY-CenterY;
  17.     double src_x = M7A*temp1 + M7B*temp2 + CenterX;
  18.     double src_y = M7C*temp1 + M7D*temp2 + CenterY;
  19.  
  20.     for(int ScreenX=0; ScreenX<ScreenWidth; ScreenX++) {
  21.        blit(Tile, ScreenRenderer, (int)src_x, (int)src_y, ScreenX, ScreenY, 1, 1);
  22.        src_x += M7A;
  23.        src_y += M7C;
  24.     }
  25.   }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement