Subversion Repositories Kolibri OS

Rev

Rev 5225 | Rev 5291 | 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 = 320;
  15.         int h = 180;
  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_BLACK);
  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.  
  62.     if (game.status == STATUS_MENU) {
  63.  
  64.         char **title = menu_titles[game.menu_index];
  65.         int y = (game.menu_index == MENU_MAIN) ? 80 : 50;
  66.         texture_draw(&game.framebuffer, &game.tex_gui_line, 0, y+15*game.menu_item_index, DRAW_MODE_ALPHA);
  67.         while (*title) {
  68.             game_textout(20, y, (*(title))[0]==' ' ? 3 : 0 , (*(title))+1 );  // first (zero) char defines action, title starts from second (1st) char
  69.             title++;
  70.             y+=15;
  71.         };
  72.        
  73.         if (game.menu_index == MENU_MAIN) {
  74.                
  75.             for (i = 0; i < ROCKS_COUNT; i++) {
  76.                 texture_draw(&game.framebuffer, &game.tex_rocks[i], 250+80*rs_noise(i,150), 60+60*rs_noise(i,1110), DRAW_MODE_ADDITIVE );
  77.             };
  78.                
  79.             game_textout( GAME_WIDTH/2 - 100, 40, 1,  "HELI0THRYX");
  80.             game_textout( GAME_WIDTH/2 - 8, 58, 3,  "TECHDEM0");
  81.             game_textout( 2, GAME_HEIGHT-10, 2,  L_BOTTOM_LINE_DEVELOPER_INFO);
  82.         };
  83.    
  84.     }
  85.     else {
  86.        
  87.         texture_draw(&game.framebuffer, &game.tex_ship[0], game.tx-8, game.ty-4, DRAW_MODE_ALPHA);
  88.         texture_draw(&game.framebuffer, &game.tex_ship[1], game.tx-8, game.ty-4, DRAW_MODE_ALPHA);
  89.         texture_draw(&game.framebuffer, &game.tex_ship[2], game.tx, game.ty-4, DRAW_MODE_ALPHA);
  90.         texture_draw(&game.framebuffer, &game.tex_ship[3], game.tx, game.ty-4, DRAW_MODE_ALPHA);
  91.        
  92.         int i;
  93.         for (i = 0; i < BULLETS_COUNT; i++) {
  94.             if (game.bullet_y[i]) {
  95.                 texture_set_pixel(&game.framebuffer, game.bullet_x[i]-4, game.bullet_y[i], 0xFF00BB00);
  96.                 texture_set_pixel(&game.framebuffer, game.bullet_x[i]-3, game.bullet_y[i], 0xFF00CC00);
  97.                 texture_set_pixel(&game.framebuffer, game.bullet_x[i]-2, game.bullet_y[i], 0xFF00DD00);
  98.                 texture_set_pixel(&game.framebuffer, game.bullet_x[i]-1, game.bullet_y[i], 0xFF00EE00);
  99.                 texture_set_pixel(&game.framebuffer, game.bullet_x[i]-0, game.bullet_y[i], 0xFF00FF00);
  100.             };
  101.         };
  102.        
  103.         game_textout( 2, 2, 2, L_TECHDEMO_LINE1 );
  104.         game_textout( 2, 12, 2, L_TECHDEMO_LINE2 );
  105.        
  106.     };
  107.  
  108.  
  109.         rskos_draw_area(0, 0, w, h, game.window_scale, game.framebuffer.data, game.scaled_framebuffer);
  110.  
  111. };
  112.  
  113.