Subversion Repositories Kolibri OS

Rev

Rev 5237 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #include "rsgamedraw.h"
  2. #include "rsgametext.h"
  3. #include "rsgamemenu.h"
  4.  
  5. #include "rskos.h"
  6.  
  7. #include "rsnoise.h"
  8.  
  9. #include "strings.h"
  10.  
  11.  
  12. void game_draw() {
  13.  
  14.         int w = GAME_WIDTH;
  15.         int h = GAME_HEIGHT;
  16.        
  17.  
  18. //      int kk = 20; // (rskos_get_time()/1) % 160;
  19. //     
  20. //      unsigned char *c = game.framebuffer.data;
  21. //     
  22. //      int i;
  23. //      for (i = 0; i < w*h*4; i+=4) {
  24. //          c[i+0] = 10; //  i/w/3;
  25. //          c[i+1] = (( (1*i)*(i + kk)/70) & 5) ? 70 : 0;
  26. //          c[i+2] = 50;
  27. //          c[i+3] = i % 128;
  28. //      };
  29.  
  30.  
  31. //    texture_clear(&game.framebuffer, COLOR_DARK_RED);
  32. //    texture_clear(&game.tex);
  33.    
  34. //    texture_draw(&game.framebuffer, &game.tex, 40, 40, DRAW_MODE_ADDITIVE);
  35. //    texture_draw(&game.framebuffer, &game.tex, 70, 50, DRAW_MODE_ADDITIVE);
  36. //    texture_draw(&game.framebuffer, &game.tex, 20, 60, DRAW_MODE_ADDITIVE);
  37. //    texture_draw(&game.framebuffer, &game.tex, 60, 70, DRAW_MODE_ADDITIVE);
  38. //    
  39. //    texture_draw(&game.framebuffer, &game.tex, 111, 150, DRAW_MODE_ADDITIVE);
  40.  
  41. //    int i, c, c2, c3;
  42. //    for (i = 0; i < 100; i++) {
  43. ////        DEBUG10f("i = %d, v1 = %.4f, v2 = %.4f \n", i, rs_noise(kk+100, kk+i)*10, rs_noise(kk+200, kk+i+300)*10);
  44. //        c = (0.5+0.45*rs_noise(kk+150, kk+i))*255;
  45. //        c2 = c + 0.05*rs_noise(kk+150, kk+i)*255;
  46. //        c3 = c2; // (0.5+0.49*rs_noise(kk+150, kk+i+2))*255;
  47. //        texture_set_pixel(&game.framebuffer, (0.5+0.49*rs_noise(kk+1100, kk+i))*GAME_WIDTH, (0.5+0.49*rs_noise(kk+1200, kk+i+1300))*GAME_HEIGHT,
  48. //                          c + (c2<<8) + (c3<<16) + 0xFF000000);
  49. //    };
  50.  
  51. //    texture_clear(&game.tex_ground, COLOR_TRANSPARENT);
  52. //    rs_perlin_configure(47, 4, 0.5, 1000, 256);
  53. //    for (i = 0; i < game.tex_ground.w; i++) {
  54. //        texture_draw_vline(&game.tex_ground, i, 25 + rs_perlin(0,i+game.tz)*25, 2, 0xFF113300);
  55. //        texture_draw_vline(&game.tex_ground, i, 25 + rs_perlin(0,i+game.tz)*25 + 2, 999, 0xFF000000);
  56. //    };
  57. //    
  58. ////    texture_draw(&game.tex_ground, &game.tex_clouds, game.tz, 0, /* game.tx, game.ty, */ DRAW_MODE_ADDITIVE | DRAW_TILED_FLAG );
  59. //    texture_draw(&game.framebuffer, &game.tex_ground, 0, GAME_HEIGHT-50, DRAW_MODE_ALPHA);
  60.    
  61.     texture_draw(&game.framebuffer, &game.tex_bg, 0, 0, DRAW_MODE_REPLACE);
  62.  
  63.     if ( (game.status == STATUS_MENU) || (game.status == STATUS_LOADING) ){
  64.  
  65. //        char **title = menu_titles[game.menu_index];
  66. //        int y = (game.menu_index == MENU_MAIN) ? 280 : 250;
  67. //        texture_draw(&game.framebuffer, &game.tex_gui_line, 0, y+15*game.menu_item_index, DRAW_MODE_ALPHA);
  68. //        while (*title) {
  69. //            game_textout(20, y, (*(title))[0]==' ' ? 3 : 0 , (*(title))+1 );  // first (zero) char defines action, title starts from second (1st) char
  70. //            title++;
  71. //            y+=15;
  72. //        };
  73.        
  74.         if (game.menu_index == MENU_MAIN) {
  75.                
  76.             if (game.status == STATUS_LOADING) {
  77.                 game_textout( GAME_WIDTH/2 - 192, 240, 0, "        L0ADING```      " );
  78.             }
  79.             else {
  80. //                game_textout( GAME_WIDTH/2 - 192, 100, 1,  "MARBLE");
  81. //                game_textout( GAME_WIDTH/2 - 192, 160, 1,  "MATCH3");
  82.  
  83.                 texture_draw( &game.framebuffer, &game.tex_logo, 0, 50, DRAW_MODE_ALPHA );
  84.  
  85.                 if (game.time) {
  86.                    
  87.                     game_textout( GAME_WIDTH/2 - 192, 230, 3, "     LEVEL PA55ED     " );
  88.                    
  89.                     char s[] = "     TIME: 000         ";
  90.                     int time_sec = game.time / 25;
  91.                     s[11] = '0' + (( time_sec / 100 ) % 10);
  92.                     s[12] = '0' + (( time_sec / 10 ) % 10);
  93.                     s[13] = '0' + (( time_sec / 1 ) % 10);
  94.                     game_textout( GAME_WIDTH/2 - 192, 260, 3, s );
  95.                 };
  96.  
  97.                 game_textout( GAME_WIDTH/2 - 192, 300, 0, "     CLICK T0 5TART     " );
  98.                
  99.                
  100.             };
  101.            
  102.             game_textout( 2, GAME_HEIGHT-10, 2,  "DEVEL0PED BY R0MAN 5HUVAL0V");
  103.         };
  104.    
  105.     }
  106.     else {
  107.            
  108.         int i, j;
  109.         for (i = 0; i < FIELD_HEIGHT; i++) {
  110.             for (j = 0; j < FIELD_WIDTH; j++) {
  111.                 if ( IS_BIT_SET( game.field[i*FIELD_WIDTH + j], CRYSTAL_VISIBLE_BIT )) {
  112.                     texture_draw( &game.framebuffer, &game.tex_crystals[ game.field[i*FIELD_WIDTH + j] & CRYSTAL_INDEX_MASK ], FIELD_X0+ j*CRYSTAL_SIZE, FIELD_Y0+ i*CRYSTAL_SIZE, DRAW_MODE_ALPHA );
  113.                     if (game.selected) {
  114.                         if ( (j == game.selected_x) && (i == game.selected_y) ) {
  115.                             texture_draw( &game.framebuffer, &game.tex_cursor, FIELD_X0+ j*CRYSTAL_SIZE, FIELD_Y0+ i*CRYSTAL_SIZE, DRAW_MODE_ALPHA );
  116.                         };
  117.                     };
  118.                 };
  119.             };
  120.         };
  121.        
  122.         for (i = 0; i < game.explosions_count; i++) {
  123.             texture_draw( &game.framebuffer, &(game.tex_explosion[  (game.explosions[i]>>16) & 0xFF  ]),
  124.                 FIELD_X0 + CRYSTAL_SIZE*( game.explosions[i] & 0xFF) - (EXPLOSION_SIZE-CRYSTAL_SIZE)/2 ,
  125.                 FIELD_Y0 + CRYSTAL_SIZE*( (game.explosions[i]>>8) & 0xFF) - (EXPLOSION_SIZE-CRYSTAL_SIZE)/2 ,
  126.                 DRAW_MODE_ALPHA);
  127.         };
  128.  
  129.  
  130.         char str[] = "TIME: 999    ";
  131.         int time_sec = game.time / 25;
  132.         str[6] = '0' + ( (time_sec / 100) % 10);
  133.         str[7] = '0' + ( (time_sec / 10) % 10);
  134.         str[8] = '0' + ( (time_sec / 1) % 10);
  135.        
  136.         game_textout( 32, 32, 3, str );
  137.        
  138.         char sstr[] = "5C0RE: 000 0F 100   ";
  139.         sstr[7] = '0' + ( (game.score / 100) % 10);
  140.         sstr[8] = '0' + ( (game.score / 10) % 10);
  141.         sstr[9] = '0' + ( (game.score / 1) % 10);
  142.        
  143.         game_textout( 32, GAME_HEIGHT-48, 3, sstr );
  144.                    
  145. //        char s[] = "YOUR TIME: 000";
  146. //        s[11] = '3';
  147. //        s[12] = '9';
  148. //        s[13] = '4';
  149.         //game_textout( GAME_WIDTH/2 - 192, 260, 0, s );
  150.            
  151.        
  152. //        texture_draw(&game.framebuffer, &game.tex_ship[0], game.tx-8, game.ty-4, DRAW_MODE_ALPHA);
  153. //        texture_draw(&game.framebuffer, &game.tex_ship[1], game.tx-8, game.ty-4, DRAW_MODE_ALPHA);
  154. //        texture_draw(&game.framebuffer, &game.tex_ship[2], game.tx, game.ty-4, DRAW_MODE_ALPHA);
  155. //        texture_draw(&game.framebuffer, &game.tex_ship[3], game.tx, game.ty-4, DRAW_MODE_ALPHA);
  156.        
  157. //        int i;
  158. //        for (i = 0; i < BULLETS_COUNT; i++) {
  159. //            if (game.bullet_y[i]) {
  160. //                texture_set_pixel(&game.framebuffer, game.bullet_x[i]-4, game.bullet_y[i], 0xFF00BB00);
  161. //                texture_set_pixel(&game.framebuffer, game.bullet_x[i]-3, game.bullet_y[i], 0xFF00CC00);
  162. //                texture_set_pixel(&game.framebuffer, game.bullet_x[i]-2, game.bullet_y[i], 0xFF00DD00);
  163. //                texture_set_pixel(&game.framebuffer, game.bullet_x[i]-1, game.bullet_y[i], 0xFF00EE00);
  164. //                texture_set_pixel(&game.framebuffer, game.bullet_x[i]-0, game.bullet_y[i], 0xFF00FF00);
  165. //            };
  166. //        };
  167.        
  168. //        game_textout( 2, 2, 2, L_TECHDEMO_LINE1 );
  169. //        game_textout( 2, 12, 2, L_TECHDEMO_LINE2 );
  170.        
  171.     };
  172.  
  173.  
  174.         rskos_draw_area(0, 0, w, h, game.window_scale, game.framebuffer.data, game.scaled_framebuffer);
  175.  
  176. };
  177.  
  178.