Автор: intre
// Pseudo 3D by intre SCREEN_WIDTH = 240 SCREEN_HEIGHT = 320 resize_pixi(0, SCREEN_WIDTH, SCREEN_HEIGHT) table_width = 20 table_height = 28 cell_width = 10 cell_height = 10 max_size = 20 table = new_array(table_width*table_height) i = 0 while 1 { clear(#505A64) rebuild_table draw_table i+1 frame(10) } draw_table: tx = table_width*cell_width/2 ty = table_height*cell_height/2 y = table_height-1 while(y >= 0){ x = table_width-1 while(x >= 0){ draw_cell x-1 } y-1 } line(-tx, -ty, -tx, ty, BLACK) line(-tx, -ty, tx, -ty, BLACK) ret draw_cell: // left side triangle(x*cell_width-tx, y*cell_height-ty, x*cell_width-tx + table[y*table_width+x], y*cell_height-ty + table[y*table_width+x], x*cell_width-tx + table[y*table_width+x], y*cell_height-ty+cell_height + table[y*table_width+x], SNEG) triangle(x*cell_width-tx, y*cell_height-ty, x*cell_width-tx + table[y*table_width+x], y*cell_height-ty+cell_height + table[y*table_width+x], x*cell_width-tx, y*cell_height-ty+cell_height, SNEG) // upper side triangle(x*cell_width-tx, y*cell_height-ty, x*cell_width-tx+cell_width, y*cell_height-ty, x*cell_width-tx+cell_width + table[y*table_width+x], y*cell_height-ty + table[y*table_width+x], SNEG) triangle(x*cell_width-tx, y*cell_height-ty, x*cell_width-tx + table[y*table_width+x], y*cell_height-ty + table[y*table_width+x], x*cell_width-tx+cell_width + table[y*table_width+x], y*cell_height-ty + table[y*table_width+x], SNEG) // edges // upper left line(x*cell_width-tx, y*cell_height-ty, x*cell_width-tx + table[y*table_width+x], y*cell_height-ty + table[y*table_width+x], BLACK) // bottom left line(x*cell_width-tx, y*cell_height-ty+cell_height, x*cell_width-tx + table[y*table_width+x], y*cell_height-ty+cell_height + table[y*table_width+x], BLACK) // upper right line(x*cell_width-tx+cell_width, y*cell_height-ty, x*cell_width-tx+cell_width + table[y*table_width+x], y*cell_height-ty + table[y*table_width+x], BLACK) fbox(x*cell_width-tx + table[y*table_width+x], y*cell_height-ty + table[y*table_width+x], cell_width, cell_height, SNEG) box(x*cell_width-tx + table[y*table_width+x], y*cell_height-ty + table[y*table_width+x], cell_width, cell_height, BLACK) ret sqrt: rslt = L div = L if L <= 0 { ret } while (1){ div = (L / div + div) / 2 if rslt > div { rslt = div } else { ret } } ret rebuild_table: x = 0 while(x < table_width){ y = 0 while(y < table_height){ L = x*x + y*y sqrt table[y*table_width+x] = (cos(rslt*30+i*4)+256)*max_size/512 y+1 } x+1 } ret
