Author Topic: Simplifying code  (Read 4230 times)

0 Members and 1 Guest are viewing this topic.

Offline eddy498

  • Newbie
  • Posts: 25
    • View Profile
Simplifying code
« on: March 23, 2019, 08:36:14 pm »
I am currently doing a brick type background for something im working on. Currently im doing it row by row adding the white line as light and black line as a shadow to make it somewhat a 2d/3d ish. this is the code.
Code: QB64: [Select]
  1. DIM SHARED scrn&, background&
  2. DIM SHARED white&, black&, red&, grey&, darkgrey&
  3. scrn& = _NEWIMAGE(800, 600, 32)
  4.  
  5. SCREEN scrn&
  6. CALL MakeColors
  7. CALL MakeBackground
  8.  
  9. _DEST display&
  10. gameover$ = "false"
  11.  
  12.     CLS
  13.     _PUTIMAGE (0, 0), background&
  14.     _DISPLAY
  15.  
  16. LOOP UNTIL gameover$ = "true"
  17.     _DISPLAY
  18.  
  19. SUB MakeColors
  20.  
  21.     white& = _RGB(255, 255, 255)
  22.     black& = _RGB(0, 0, 0)
  23.     red& = _RGB(255, 0, 0)
  24.     grey& = _RGB(125, 125, 125)
  25.     darkgrey& = _RGB(50, 50, 50)
  26.  
  27.  
  28. SUB MakeBackground
  29.  
  30.     background& = _NEWIMAGE(800, 600)
  31.     _DEST background&
  32.     'background color
  33.     LINE (0, 0)-(800, 600), darkgrey&, BF
  34.  
  35.     'row 1
  36.     LINE (4, 578)-(54, 597), red&, BF
  37.     LINE (57, 578)-(107, 597), red&, BF
  38.     LINE (110, 578)-(160, 597), red&, BF
  39.     LINE (163, 578)-(213, 597), red&, BF
  40.     LINE (216, 578)-(266, 597), red&, BF
  41.     LINE (269, 578)-(319, 597), red&, BF
  42.     LINE (322, 578)-(372, 597), red&, BF
  43.     LINE (375, 578)-(425, 597), red&, BF
  44.     LINE (428, 578)-(478, 597), red&, BF
  45.     LINE (481, 578)-(531, 597), red&, BF
  46.     LINE (534, 578)-(584, 597), red&, BF
  47.     LINE (587, 578)-(637, 597), red&, BF
  48.     LINE (640, 578)-(690, 597), red&, BF
  49.     LINE (693, 578)-(743, 597), red&, BF
  50.     LINE (746, 578)-(796, 597), red&, BF
  51.  
  52.     'lighting row 1
  53.     LINE (4, 578)-(54, 578), white& 'first horizontal line
  54.     LINE (54, 578)-(54, 597), white& 'second vertical line
  55.     LINE (57, 578)-(107, 578), white&
  56.     LINE (107, 578)-(107, 597), white&
  57.     LINE (110, 578)-(160, 578), white&
  58.     LINE (160, 578)-(160, 597), white&
  59.     LINE (163, 578)-(213, 578), white&
  60.     LINE (213, 578)-(213, 597), white&
  61.     LINE (216, 578)-(266, 578), white&
  62.     LINE (266, 578)-(266, 597), white&
  63.     LINE (269, 578)-(319, 578), white&
  64.     LINE (319, 578)-(319, 597), white&
  65.     LINE (322, 578)-(372, 578), white&
  66.     LINE (372, 578)-(372, 597), white&
  67.     LINE (375, 578)-(425, 578), white&
  68.     LINE (425, 578)-(425, 597), white&
  69.     LINE (428, 578)-(478, 578), white&
  70.     LINE (478, 578)-(478, 597), white&
  71.     LINE (471, 578)-(531, 578), white&
  72.     LINE (531, 578)-(531, 597), white&
  73.     LINE (534, 578)-(584, 578), white&
  74.     LINE (584, 578)-(584, 597), white&
  75.     LINE (587, 578)-(637, 578), white&
  76.     LINE (637, 578)-(637, 597), white&
  77.     LINE (640, 578)-(690, 578), white&
  78.     LINE (690, 578)-(690, 597), white&
  79.     LINE (693, 578)-(743, 578), white&
  80.     LINE (743, 578)-(743, 597), white&
  81.     LINE (746, 578)-(796, 578), white&
  82.     LINE (796, 578)-(796, 597), white&
  83.  
  84.  
  85.  
  86.     'shadow row 1
  87.     LINE (4, 578)-(4, 597), black& 'first vertical line
  88.     LINE (4, 597)-(54, 597), black& 'second horizontal line
  89.     LINE (57, 578)-(57, 597), black&
  90.     LINE (57, 597)-(107, 597), black&
  91.     LINE (110, 578)-(110, 597), black&
  92.     LINE (110, 597)-(160, 597), black&
  93.     LINE (163, 578)-(163, 597), black&
  94.     LINE (163, 597)-(213, 597), black&
  95.     LINE (216, 578)-(216, 597), black&
  96.     LINE (216, 597)-(266, 597), black&
  97.     LINE (269, 578)-(269, 597), black&
  98.     LINE (269, 597)-(319, 597), black&
  99.     LINE (322, 578)-(322, 597), black&
  100.     LINE (322, 597)-(372, 597), black&
  101.     LINE (375, 578)-(375, 597), black&
  102.     LINE (375, 597)-(425, 597), black&
  103.     LINE (428, 578)-(428, 597), black&
  104.     LINE (428, 597)-(478, 597), black&
  105.     LINE (481, 578)-(481, 597), black&
  106.     LINE (481, 597)-(531, 597), black&
  107.     LINE (534, 578)-(534, 597), black&
  108.     LINE (534, 597)-(584, 597), black&
  109.     LINE (587, 578)-(587, 597), black&
  110.     LINE (587, 597)-(637, 597), black&
  111.     LINE (640, 578)-(640, 597), black&
  112.     LINE (640, 597)-(690, 597), black&
  113.     LINE (693, 578)-(693, 597), black&
  114.     LINE (693, 597)-(743, 597), black&
  115.     LINE (746, 578)-(746, 597), black&
  116.     LINE (746, 597)-(796, 597), black&
  117.  
  118.  
  119.  
  120.     'row 2
  121.     LINE (4, 555)-(28, 575), red&, BF
  122.     LINE (31, 555)-(81, 575), red&, BF
  123.     LINE (84, 555)-(134, 575), red&, BF
  124.     LINE (137, 555)-(187, 575), red&, BF
  125.     LINE (190, 555)-(240, 575), red&, BF
  126.     LINE (243, 555)-(293, 575), red&, BF
  127.     LINE (296, 555)-(346, 575), red&, BF
  128.     LINE (349, 555)-(399, 575), red&, BF
  129.     LINE (402, 555)-(452, 575), red&, BF
  130.     LINE (455, 555)-(505, 575), red&, BF
  131.     LINE (508, 555)-(558, 575), red&, BF
  132.     LINE (561, 555)-(611, 575), red&, BF
  133.     LINE (614, 555)-(664, 575), red&, BF
  134.     LINE (667, 555)-(717, 575), red&, BF
  135.     LINE (720, 555)-(770, 575), red&, BF
  136.     LINE (773, 555)-(796, 575), red&, BF
  137.  
  138.     'lighting row 2
  139.     LINE (4, 555)-(28, 555), white&
  140.     LINE (28, 555)-(28, 575), white&
  141.     LINE (31, 555)-(81, 555), white&
  142.     LINE (81, 555)-(81, 575), white&
  143.     LINE (84, 555)-(134, 555), white&
  144.     LINE (134, 555)-(134, 575), white&
  145.     LINE (137, 555)-(187, 555), white&
  146.     LINE (187, 555)-(187, 575), white&
  147.     LINE (190, 555)-(240, 555), white&
  148.     LINE (240, 555)-(240, 575), white&
  149.     LINE (243, 555)-(293, 555), white&
  150.     LINE (293, 555)-(293, 575), white&
  151.     LINE (296, 555)-(346, 555), white&
  152.     LINE (346, 555)-(346, 575), white&
  153.     LINE (349, 555)-(399, 555), white&
  154.     LINE (399, 555)-(399, 575), white&
  155.     LINE (402, 555)-(452, 555), white&
  156.     LINE (452, 555)-(452, 575), white&
  157.     LINE (455, 555)-(505, 555), white&
  158.     LINE (505, 555)-(505, 575), white&
  159.     LINE (508, 555)-(558, 555), white&
  160.     LINE (558, 555)-(558, 575), white&
  161.     LINE (561, 555)-(611, 555), white&
  162.     LINE (611, 555)-(611, 575), white&
  163.     LINE (614, 555)-(664, 555), white&
  164.     LINE (664, 555)-(664, 575), white&
  165.     LINE (667, 555)-(717, 555), white&
  166.     LINE (717, 555)-(717, 575), white&
  167.     LINE (720, 555)-(770, 555), white&
  168.     LINE (770, 555)-(770, 575), white&
  169.     LINE (773, 555)-(796, 555), white&
  170.     LINE (796, 555)-(796, 575), white&
  171.  
  172.     'shadow row 2
  173.     LINE (4, 555)-(4, 575), black&
  174.     LINE (4, 575)-(28, 575), black&
  175.     LINE (31, 555)-(31, 575), black&
  176.     LINE (31, 575)-(81, 575), black&
  177.     LINE (84, 555)-(84, 575), black&
  178.     LINE (84, 575)-(134, 575), black&
  179.     LINE (137, 555)-(137, 575), black&
  180.     LINE (137, 575)-(187, 575), black&
  181.     LINE (190, 555)-(190, 575), black&
  182.     LINE (190, 575)-(240, 575), black&
  183.     LINE (243, 555)-(243, 575), black&
  184.     LINE (243, 575)-(293, 575), black&
  185.     LINE (296, 555)-(296, 575), black&
  186.     LINE (296, 575)-(346, 575), black&
  187.     LINE (349, 555)-(349, 575), black&
  188.     LINE (349, 575)-(399, 575), black&
  189.     LINE (402, 555)-(402, 575), black&
  190.     LINE (402, 575)-(452, 575), black&
  191.     LINE (455, 555)-(455, 575), black&
  192.     LINE (455, 575)-(505, 575), black&
  193.     LINE (508, 555)-(508, 575), black&
  194.     LINE (508, 575)-(558, 575), black&
  195.     LINE (561, 555)-(561, 575), black&
  196.     LINE (561, 575)-(611, 575), black&
  197.     LINE (614, 555)-(614, 575), black&
  198.     LINE (614, 575)-(664, 575), black&
  199.     LINE (667, 555)-(667, 575), black&
  200.     LINE (667, 575)-(717, 575), black&
  201.     LINE (720, 555)-(720, 575), black&
  202.     LINE (720, 575)-(770, 575), black&
  203.     LINE (773, 555)-(773, 575), black&
  204.     LINE (773, 575)-(796, 575), black&
  205.  
  206.  
  207.  
  208.  
  209.     'row 3
  210.     LINE (4, 532)-(54, 552), red&, BF
  211.     LINE (57, 532)-(107, 552), red&, BF
  212.     LINE (110, 532)-(160, 552), red&, BF
  213.     LINE (163, 532)-(213, 552), red&, BF
  214.     LINE (216, 532)-(266, 552), red&, BF
  215.     LINE (269, 532)-(319, 552), red&, BF
  216.     LINE (322, 532)-(372, 552), red&, BF
  217.     LINE (375, 532)-(425, 552), red&, BF
  218.     LINE (428, 532)-(478, 552), red&, BF
  219.     LINE (481, 532)-(531, 552), red&, BF
  220.     LINE (534, 532)-(584, 552), red&, BF
  221.     LINE (587, 532)-(637, 552), red&, BF
  222.     LINE (640, 532)-(690, 552), red&, BF
  223.     LINE (693, 532)-(743, 552), red&, BF
  224.     LINE (746, 532)-(796, 552), red&, BF
  225.  
  226.  
  227.     'lighting row 3
  228.     LINE (4, 532)-(54, 532), white& 'first horizontal line
  229.     LINE (54, 532)-(54, 552), white& 'second vertical line
  230.     LINE (57, 532)-(107, 532), white&
  231.     LINE (107, 532)-(107, 552), white&
  232.     LINE (110, 532)-(160, 532), white&
  233.     LINE (160, 532)-(160, 552), white&
  234.     LINE (163, 532)-(213, 532), white&
  235.     LINE (213, 532)-(213, 552), white&
  236.     LINE (216, 532)-(266, 532), white&
  237.     LINE (266, 532)-(266, 552), white&
  238.     LINE (269, 532)-(319, 532), white&
  239.     LINE (319, 532)-(319, 552), white&
  240.     LINE (322, 532)-(372, 532), white&
  241.     LINE (372, 532)-(372, 552), white&
  242.     LINE (375, 532)-(425, 532), white&
  243.     LINE (425, 532)-(425, 552), white&
  244.     LINE (428, 532)-(478, 532), white&
  245.     LINE (478, 532)-(478, 552), white&
  246.     LINE (471, 532)-(531, 532), white&
  247.     LINE (531, 532)-(531, 552), white&
  248.     LINE (534, 532)-(584, 532), white&
  249.     LINE (584, 532)-(584, 552), white&
  250.     LINE (587, 532)-(637, 532), white&
  251.     LINE (637, 532)-(637, 552), white&
  252.     LINE (640, 532)-(690, 532), white&
  253.     LINE (690, 532)-(690, 552), white&
  254.     LINE (693, 532)-(743, 532), white&
  255.     LINE (743, 532)-(743, 552), white&
  256.     LINE (746, 532)-(796, 532), white&
  257.     LINE (796, 532)-(796, 552), white&
  258.  
  259.  
  260.     'shadow row 3
  261.     LINE (4, 532)-(4, 552), black& 'first vertical line
  262.     LINE (4, 552)-(54, 552), black& 'second horizontal line
  263.     LINE (57, 532)-(57, 552), black&
  264.     LINE (57, 552)-(107, 552), black&
  265.     LINE (110, 532)-(110, 552), black&
  266.     LINE (110, 552)-(160, 552), black&
  267.     LINE (163, 532)-(163, 552), black&
  268.     LINE (163, 552)-(213, 552), black&
  269.     LINE (216, 532)-(216, 552), black&
  270.     LINE (216, 552)-(266, 552), black&
  271.     LINE (269, 532)-(269, 552), black&
  272.     LINE (269, 552)-(319, 552), black&
  273.     LINE (322, 532)-(322, 552), black&
  274.     LINE (322, 552)-(372, 552), black&
  275.     LINE (375, 532)-(375, 552), black&
  276.     LINE (375, 552)-(425, 552), black&
  277.     LINE (428, 532)-(428, 552), black&
  278.     LINE (428, 552)-(478, 552), black&
  279.     LINE (481, 532)-(481, 552), black&
  280.     LINE (481, 552)-(531, 552), black&
  281.     LINE (534, 532)-(534, 552), black&
  282.     LINE (534, 552)-(584, 552), black&
  283.     LINE (587, 532)-(587, 552), black&
  284.     LINE (587, 552)-(637, 552), black&
  285.     LINE (640, 532)-(640, 552), black&
  286.     LINE (640, 552)-(690, 552), black&
  287.     LINE (693, 532)-(693, 552), black&
  288.     LINE (693, 552)-(743, 552), black&
  289.     LINE (746, 532)-(746, 552), black&
  290.     LINE (746, 552)-(796, 552), black&
  291.  
  292.  
  293.  
  294.  
  295.  
  296.     'row 4
  297.     LINE (4, 509)-(28, 529), red&, BF
  298.     LINE (31, 509)-(81, 529), red&, BF
  299.     LINE (84, 509)-(134, 529), red&, BF
  300.     LINE (137, 509)-(187, 529), red&, BF
  301.     LINE (190, 509)-(240, 529), red&, BF
  302.     LINE (243, 509)-(293, 529), red&, BF
  303.     LINE (296, 509)-(346, 529), red&, BF
  304.     LINE (349, 509)-(399, 529), red&, BF
  305.     LINE (402, 509)-(452, 529), red&, BF
  306.     LINE (455, 509)-(505, 529), red&, BF
  307.     LINE (508, 509)-(558, 529), red&, BF
  308.     LINE (561, 509)-(611, 529), red&, BF
  309.     LINE (614, 509)-(664, 529), red&, BF
  310.     LINE (667, 509)-(717, 529), red&, BF
  311.     LINE (720, 509)-(770, 529), red&, BF
  312.     LINE (773, 509)-(796, 529), red&, BF
  313.  
  314.  
  315.     'lighting row 4
  316.     LINE (4, 509)-(28, 509), white&
  317.     LINE (28, 509)-(28, 529), white&
  318.     LINE (31, 509)-(81, 509), white&
  319.     LINE (81, 509)-(81, 529), white&
  320.     LINE (84, 509)-(134, 509), white&
  321.     LINE (134, 509)-(134, 529), white&
  322.     LINE (137, 509)-(187, 509), white&
  323.     LINE (187, 509)-(187, 529), white&
  324.     LINE (190, 509)-(240, 509), white&
  325.     LINE (240, 509)-(240, 529), white&
  326.     LINE (243, 509)-(293, 509), white&
  327.     LINE (293, 509)-(293, 529), white&
  328.     LINE (296, 509)-(346, 509), white&
  329.     LINE (346, 509)-(346, 529), white&
  330.     LINE (349, 509)-(399, 509), white&
  331.     LINE (399, 509)-(399, 529), white&
  332.     LINE (402, 509)-(452, 509), white&
  333.     LINE (452, 509)-(452, 529), white&
  334.     LINE (455, 509)-(505, 509), white&
  335.     LINE (505, 509)-(505, 529), white&
  336.     LINE (508, 509)-(558, 509), white&
  337.     LINE (558, 509)-(558, 529), white&
  338.     LINE (561, 509)-(611, 509), white&
  339.     LINE (611, 509)-(611, 529), white&
  340.     LINE (614, 509)-(664, 509), white&
  341.     LINE (664, 509)-(664, 529), white&
  342.     LINE (667, 509)-(717, 509), white&
  343.     LINE (717, 509)-(717, 529), white&
  344.     LINE (720, 509)-(770, 509), white&
  345.     LINE (770, 509)-(770, 529), white&
  346.     LINE (773, 509)-(796, 509), white&
  347.     LINE (796, 509)-(796, 529), white&
  348.  
  349.     'shadow row 4
  350.     LINE (4, 509)-(4, 529), black&
  351.     LINE (4, 529)-(28, 529), black&
  352.     LINE (31, 509)-(31, 529), black&
  353.     LINE (31, 529)-(81, 529), black&
  354.     LINE (84, 509)-(84, 529), black&
  355.     LINE (84, 529)-(134, 529), black&
  356.     LINE (137, 509)-(137, 529), black&
  357.     LINE (137, 529)-(187, 529), black&
  358.     LINE (190, 509)-(190, 529), black&
  359.     LINE (190, 529)-(240, 529), black&
  360.     LINE (243, 509)-(243, 529), black&
  361.     LINE (243, 529)-(293, 529), black&
  362.     LINE (296, 509)-(296, 529), black&
  363.     LINE (296, 529)-(346, 529), black&
  364.     LINE (349, 509)-(349, 529), black&
  365.     LINE (349, 529)-(399, 529), black&
  366.     LINE (402, 509)-(402, 529), black&
  367.     LINE (402, 529)-(452, 529), black&
  368.     LINE (455, 509)-(455, 529), black&
  369.     LINE (455, 529)-(505, 529), black&
  370.     LINE (508, 509)-(508, 529), black&
  371.     LINE (508, 529)-(558, 529), black&
  372.     LINE (561, 509)-(561, 529), black&
  373.     LINE (561, 529)-(611, 529), black&
  374.     LINE (614, 509)-(614, 529), black&
  375.     LINE (614, 529)-(664, 529), black&
  376.     LINE (667, 509)-(667, 529), black&
  377.     LINE (667, 529)-(717, 529), black&
  378.     LINE (720, 509)-(720, 529), black&
  379.     LINE (720, 529)-(770, 529), black&
  380.     LINE (773, 509)-(773, 529), black&
  381.     LINE (773, 529)-(796, 529), black&
  382.  
  383.  
  384.     'row 5
  385.     LINE (4, 486)-(54, 506), red&, BF
  386.     LINE (57, 486)-(107, 506), red&, BF
  387.     LINE (110, 486)-(160, 506), red&, BF
  388.     LINE (163, 486)-(213, 506), red&, BF
  389.     LINE (216, 486)-(266, 506), red&, BF
  390.     LINE (269, 486)-(319, 506), red&, BF
  391.     LINE (322, 486)-(372, 506), red&, BF
  392.     LINE (375, 486)-(425, 506), red&, BF
  393.     LINE (428, 486)-(478, 506), red&, BF
  394.     LINE (481, 486)-(531, 506), red&, BF
  395.     LINE (534, 486)-(584, 506), red&, BF
  396.     LINE (587, 486)-(637, 506), red&, BF
  397.     LINE (640, 486)-(690, 506), red&, BF
  398.     LINE (693, 486)-(743, 506), red&, BF
  399.     LINE (746, 486)-(796, 506), red&, BF
  400.  
  401.     'lighting row 5
  402.     LINE (4, 486)-(54, 486), white& 'first horizontal line
  403.     LINE (54, 486)-(54, 506), white& 'second vertical line
  404.     LINE (57, 486)-(107, 486), white&
  405.     LINE (107, 486)-(107, 506), white&
  406.     LINE (110, 486)-(160, 486), white&
  407.     LINE (160, 486)-(160, 506), white&
  408.     LINE (163, 486)-(213, 486), white&
  409.     LINE (213, 486)-(213, 506), white&
  410.     LINE (216, 486)-(266, 486), white&
  411.     LINE (266, 486)-(266, 506), white&
  412.     LINE (269, 486)-(319, 486), white&
  413.     LINE (319, 486)-(319, 506), white&
  414.     LINE (322, 486)-(372, 486), white&
  415.     LINE (372, 486)-(372, 506), white&
  416.     LINE (375, 486)-(425, 486), white&
  417.     LINE (425, 486)-(425, 506), white&
  418.     LINE (428, 486)-(478, 486), white&
  419.     LINE (478, 486)-(478, 506), white&
  420.     LINE (471, 486)-(531, 486), white&
  421.     LINE (531, 486)-(531, 506), white&
  422.     LINE (534, 486)-(584, 486), white&
  423.     LINE (584, 486)-(584, 506), white&
  424.     LINE (587, 486)-(637, 486), white&
  425.     LINE (637, 486)-(637, 506), white&
  426.     LINE (640, 486)-(690, 486), white&
  427.     LINE (690, 486)-(690, 506), white&
  428.     LINE (693, 486)-(743, 486), white&
  429.     LINE (743, 486)-(743, 506), white&
  430.     LINE (746, 486)-(796, 486), white&
  431.     LINE (796, 486)-(796, 506), white&
  432.  
  433.  
  434.     'shadow row 5
  435.     LINE (4, 486)-(4, 506), black& 'first vertical line
  436.     LINE (4, 506)-(54, 506), black& 'second horizontal line
  437.     LINE (57, 486)-(57, 506), black&
  438.     LINE (57, 506)-(107, 506), black&
  439.     LINE (110, 486)-(110, 506), black&
  440.     LINE (110, 506)-(160, 506), black&
  441.     LINE (163, 486)-(163, 506), black&
  442.     LINE (163, 506)-(213, 506), black&
  443.     LINE (216, 486)-(216, 506), black&
  444.     LINE (216, 506)-(266, 506), black&
  445.     LINE (269, 486)-(269, 506), black&
  446.     LINE (269, 506)-(319, 506), black&
  447.     LINE (322, 486)-(322, 506), black&
  448.     LINE (322, 506)-(372, 506), black&
  449.     LINE (375, 486)-(375, 506), black&
  450.     LINE (375, 506)-(425, 506), black&
  451.     LINE (428, 486)-(428, 506), black&
  452.     LINE (428, 506)-(478, 506), black&
  453.     LINE (481, 486)-(481, 506), black&
  454.     LINE (481, 506)-(531, 506), black&
  455.     LINE (534, 486)-(534, 506), black&
  456.     LINE (534, 506)-(584, 506), black&
  457.     LINE (587, 486)-(587, 506), black&
  458.     LINE (587, 506)-(637, 506), black&
  459.     LINE (640, 486)-(640, 506), black&
  460.     LINE (640, 506)-(690, 506), black&
  461.     LINE (693, 486)-(693, 506), black&
  462.     LINE (693, 506)-(743, 506), black&
  463.     LINE (746, 486)-(746, 506), black&
  464.     LINE (746, 506)-(796, 506), black&
  465.  
  466.  
  467.     'row 6
  468.     LINE (4, 463)-(28, 483), red&, BF
  469.     LINE (31, 463)-(81, 483), red&, BF
  470.     LINE (84, 463)-(134, 483), red&, BF
  471.     LINE (137, 463)-(187, 483), red&, BF
  472.     LINE (190, 463)-(240, 483), red&, BF
  473.     LINE (243, 463)-(293, 483), red&, BF
  474.     LINE (296, 463)-(346, 483), red&, BF
  475.     LINE (349, 463)-(399, 483), red&, BF
  476.     LINE (402, 463)-(452, 483), red&, BF
  477.     LINE (455, 463)-(505, 483), red&, BF
  478.     LINE (508, 463)-(558, 483), red&, BF
  479.     LINE (561, 463)-(611, 483), red&, BF
  480.     LINE (614, 463)-(664, 483), red&, BF
  481.     LINE (667, 463)-(717, 483), red&, BF
  482.     LINE (720, 463)-(770, 483), red&, BF
  483.     LINE (773, 463)-(796, 483), red&, BF
  484.  
  485.  
  486.     'lighting row 6
  487.     LINE (4, 463)-(28, 463), white&
  488.     LINE (28, 463)-(28, 483), white&
  489.     LINE (31, 463)-(81, 463), white&
  490.     LINE (81, 463)-(81, 483), white&
  491.     LINE (84, 463)-(134, 463), white&
  492.     LINE (134, 463)-(134, 483), white&
  493.     LINE (137, 463)-(187, 463), white&
  494.     LINE (187, 463)-(187, 483), white&
  495.     LINE (190, 463)-(240, 463), white&
  496.     LINE (240, 463)-(240, 483), white&
  497.     LINE (243, 463)-(293, 463), white&
  498.     LINE (293, 463)-(293, 483), white&
  499.     LINE (296, 463)-(346, 463), white&
  500.     LINE (346, 463)-(346, 483), white&
  501.     LINE (349, 463)-(399, 463), white&
  502.     LINE (399, 463)-(399, 483), white&
  503.     LINE (402, 463)-(452, 463), white&
  504.     LINE (452, 463)-(452, 483), white&
  505.     LINE (455, 463)-(505, 463), white&
  506.     LINE (505, 463)-(505, 483), white&
  507.     LINE (508, 463)-(558, 463), white&
  508.     LINE (558, 463)-(558, 483), white&
  509.     LINE (561, 463)-(611, 463), white&
  510.     LINE (611, 463)-(611, 483), white&
  511.     LINE (614, 463)-(664, 463), white&
  512.     LINE (664, 463)-(664, 483), white&
  513.     LINE (667, 463)-(717, 463), white&
  514.     LINE (717, 463)-(717, 483), white&
  515.     LINE (720, 463)-(770, 463), white&
  516.     LINE (770, 463)-(770, 483), white&
  517.     LINE (773, 463)-(796, 463), white&
  518.     LINE (796, 463)-(796, 483), white&
  519.  
  520.     'shadow row 6
  521.     LINE (4, 463)-(4, 483), black&
  522.     LINE (4, 483)-(28, 483), black&
  523.     LINE (31, 463)-(31, 483), black&
  524.     LINE (31, 483)-(81, 483), black&
  525.     LINE (84, 463)-(84, 483), black&
  526.     LINE (84, 483)-(134, 483), black&
  527.     LINE (137, 463)-(137, 483), black&
  528.     LINE (137, 483)-(187, 483), black&
  529.     LINE (190, 463)-(190, 483), black&
  530.     LINE (190, 483)-(240, 483), black&
  531.     LINE (243, 463)-(243, 483), black&
  532.     LINE (243, 483)-(293, 483), black&
  533.     LINE (296, 463)-(296, 483), black&
  534.     LINE (296, 483)-(346, 483), black&
  535.     LINE (349, 463)-(349, 483), black&
  536.     LINE (349, 483)-(399, 483), black&
  537.     LINE (402, 463)-(402, 483), black&
  538.     LINE (402, 483)-(452, 483), black&
  539.     LINE (455, 463)-(455, 483), black&
  540.     LINE (455, 483)-(505, 483), black&
  541.     LINE (508, 463)-(508, 483), black&
  542.     LINE (508, 483)-(558, 483), black&
  543.     LINE (561, 463)-(561, 483), black&
  544.     LINE (561, 483)-(611, 483), black&
  545.     LINE (614, 463)-(614, 483), black&
  546.     LINE (614, 483)-(664, 483), black&
  547.     LINE (667, 463)-(667, 483), black&
  548.     LINE (667, 483)-(717, 483), black&
  549.     LINE (720, 463)-(720, 483), black&
  550.     LINE (720, 483)-(770, 483), black&
  551.     LINE (773, 463)-(773, 483), black&
  552.     LINE (773, 483)-(796, 483), black&
  553.  
  554.  
  555.  
  556.  
  557.  
  558.     'row 7
  559.     LINE (4, 440)-(54, 460), red&, BF
  560.     LINE (57, 440)-(107, 460), red&, BF
  561.     LINE (110, 440)-(160, 460), red&, BF
  562.     LINE (163, 440)-(213, 460), red&, BF
  563.     LINE (216, 440)-(266, 460), red&, BF
  564.     LINE (269, 440)-(319, 460), red&, BF
  565.     LINE (322, 440)-(372, 460), red&, BF
  566.     LINE (375, 440)-(425, 460), red&, BF
  567.     LINE (428, 440)-(478, 460), red&, BF
  568.     LINE (481, 440)-(531, 460), red&, BF
  569.     LINE (534, 440)-(584, 460), red&, BF
  570.     LINE (587, 440)-(637, 460), red&, BF
  571.     LINE (640, 440)-(690, 460), red&, BF
  572.     LINE (693, 440)-(743, 460), red&, BF
  573.     LINE (746, 440)-(796, 460), red&, BF
  574.  
  575.  
  576.     'lighting row 7
  577.     LINE (4, 440)-(54, 440), white& 'first horizontal line
  578.     LINE (54, 440)-(54, 460), white& 'second vertical line
  579.     LINE (57, 440)-(107, 440), white&
  580.     LINE (107, 440)-(107, 460), white&
  581.     LINE (110, 440)-(160, 440), white&
  582.     LINE (160, 440)-(160, 460), white&
  583.     LINE (163, 440)-(213, 440), white&
  584.     LINE (213, 440)-(213, 460), white&
  585.     LINE (216, 440)-(266, 440), white&
  586.     LINE (266, 440)-(266, 460), white&
  587.     LINE (269, 440)-(319, 440), white&
  588.     LINE (319, 440)-(319, 460), white&
  589.     LINE (322, 440)-(372, 440), white&
  590.     LINE (372, 440)-(372, 460), white&
  591.     LINE (375, 440)-(425, 440), white&
  592.     LINE (425, 440)-(425, 460), white&
  593.     LINE (428, 440)-(478, 440), white&
  594.     LINE (478, 440)-(478, 460), white&
  595.     LINE (471, 440)-(531, 440), white&
  596.     LINE (531, 440)-(531, 460), white&
  597.     LINE (534, 440)-(584, 440), white&
  598.     LINE (584, 440)-(584, 460), white&
  599.     LINE (587, 440)-(637, 440), white&
  600.     LINE (637, 440)-(637, 460), white&
  601.     LINE (640, 440)-(690, 440), white&
  602.     LINE (690, 440)-(690, 460), white&
  603.     LINE (693, 440)-(743, 440), white&
  604.     LINE (743, 440)-(743, 460), white&
  605.     LINE (746, 440)-(796, 440), white&
  606.     LINE (796, 440)-(796, 460), white&
  607.  
  608.  
  609.     'shadow row 7
  610.     LINE (4, 440)-(4, 460), black& 'first vertical line
  611.     LINE (4, 460)-(54, 460), black& 'second horizontal line
  612.     LINE (57, 440)-(57, 460), black&
  613.     LINE (57, 460)-(107, 460), black&
  614.     LINE (110, 440)-(110, 460), black&
  615.     LINE (110, 460)-(160, 460), black&
  616.     LINE (163, 440)-(163, 460), black&
  617.     LINE (163, 460)-(213, 460), black&
  618.     LINE (216, 440)-(216, 460), black&
  619.     LINE (216, 460)-(266, 460), black&
  620.     LINE (269, 440)-(269, 460), black&
  621.     LINE (269, 460)-(319, 460), black&
  622.     LINE (322, 440)-(322, 460), black&
  623.     LINE (322, 460)-(372, 460), black&
  624.     LINE (375, 440)-(375, 460), black&
  625.     LINE (375, 460)-(425, 460), black&
  626.     LINE (428, 440)-(428, 460), black&
  627.     LINE (428, 460)-(478, 460), black&
  628.     LINE (481, 440)-(481, 460), black&
  629.     LINE (481, 460)-(531, 460), black&
  630.     LINE (534, 440)-(534, 460), black&
  631.     LINE (534, 460)-(584, 460), black&
  632.     LINE (587, 440)-(587, 460), black&
  633.     LINE (587, 460)-(637, 460), black&
  634.     LINE (640, 440)-(640, 460), black&
  635.     LINE (640, 460)-(690, 460), black&
  636.     LINE (693, 440)-(693, 460), black&
  637.     LINE (693, 460)-(743, 460), black&
  638.     LINE (746, 440)-(746, 460), black&
  639.     LINE (746, 460)-(796, 460), black&
  640.  
  641.  
  642.  
  643.     'row 8
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  

I want to know if there is a simpler way to do this. like maybe create one and put at code that copies and pastes it.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Simplifying code
« Reply #1 on: March 23, 2019, 10:39:59 pm »
Quote
like maybe create one and put at code that copies and pastes it.

Make the overall Brick size easy to lay out with x and y loop stepping and add the darkgrey to right and bottom of brick or half brick.
Code: QB64: [Select]
  1. CONST white = &HFFFFFFFF
  2. CONST black = &HFF000000
  3. CONST red = &HFFFF0000
  4. CONST grey = &HFF7C7C7C
  5. CONST darkgrey = &HFF323232
  6.  
  7. DIM SHARED scrn&, background&
  8.  
  9. scrn& = _NEWIMAGE(800, 600, 32)
  10.  
  11. SCREEN scrn&
  12.  
  13. CALL MakeBackground
  14.  
  15. _DEST display&
  16. gameover$ = "false"
  17.  
  18.     CLS
  19.     _PUTIMAGE (0, 0), background&
  20.     _DISPLAY
  21.     _LIMIT 60
  22. LOOP UNTIL gameover$ = "true"
  23.     _DISPLAY
  24.  
  25. 'for ease of brick laying I made 1 brick 49 wide and 24 high so next brick starts 50 before or after or 25 above or below
  26. SUB drawBrick (x, y)
  27.     LINE (x, y)-STEP(49, 24), darkgrey, BF
  28.     LINE (x + 1, y + 1)-STEP(46, 20), red, BF
  29.     LINE (x + 1, y)-STEP(46, 0), white
  30.     LINE (x + 47, y)-STEP(0, 21), white
  31.     LINE (x, y)-STEP(0, 22), black
  32.     LINE (x, y + 22)-STEP(47, 0), black
  33.  
  34. SUB drawHalfBrick (x, y)
  35.     LINE (x, y)-STEP(24, 24), darkgrey, BF
  36.     LINE (x + 1, y + 1)-STEP(21, 20), red, BF
  37.     LINE (x + 1, y)-STEP(21, 0), white
  38.     LINE (x + 22, y)-STEP(0, 21), white
  39.     LINE (x, y)-STEP(0, 22), black
  40.     LINE (x, y + 22)-STEP(22, 0), black
  41.  
  42. SUB MakeBackground
  43.     background& = _NEWIMAGE(800, 600)
  44.     _DEST background&
  45.     'make sky
  46.     LINE (0, 0)-(800, 460), &HFF00AAFF, BF
  47.     i = 0
  48.     FOR y = 450 TO 600 STEP 25 'all bricks start 25 pixels after last
  49.         i = (i + 1) MOD 2
  50.         IF i MOD 2 THEN adj = 25 ELSE adj = 0
  51.         FOR x = 0 + adj TO 800 - 2 * adj STEP 50 'all bricks start 50 pxels after last
  52.             drawBrick x, y
  53.         NEXT
  54.         IF i THEN drawHalfBrick 0, y
  55.         IF i THEN drawHalfBrick 775, y
  56.     NEXT
  57.  

It might even be better to make brick images.
« Last Edit: March 23, 2019, 10:43:17 pm by bplus »

Offline eddy498

  • Newbie
  • Posts: 25
    • View Profile
Re: Simplifying code
« Reply #2 on: March 23, 2019, 11:59:04 pm »
i havnt done anything with images yet tho, dont want to incorporate images and textures yet untill i have a better understanding of the basics.

okay so that code you draw the brick and half brick then set it up to do the pattern.. what is that step you put while drawaing the bricks?

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Simplifying code
« Reply #3 on: March 24, 2019, 12:10:54 am »
i = (i+1) mod 2
Keeps i either 0 or 1.
If i = 1 the row is odd and needs a half brick on each end or even and uses only whole bricks (because the brick width divides the screen width) so adj (adjustment) is set to 25, a half a brick off from edge.
« Last Edit: March 24, 2019, 12:13:16 am by bplus »

Offline eddy498

  • Newbie
  • Posts: 25
    • View Profile
Re: Simplifying code
« Reply #4 on: March 24, 2019, 12:14:48 am »
no yeah i got that but i meant.

LINE (x + 1, y)-STEP(21, 0), white

that step there that u wrote what does it do? i havnt seen that before

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Simplifying code
« Reply #5 on: March 24, 2019, 12:26:16 am »
STEP(add to x, add to y)

line (x, y) - step( a, b) is same as line (x,y) - (x+a, y + b)


Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Simplifying code
« Reply #6 on: March 24, 2019, 12:29:49 am »
Quote
gotta try to get a bit more into the art so my backgrounds dont look so bland in the game. any ideas where i can find some references for objects such as rocks, trees, ext?

How do you like my rock collection?
Code: QB64: [Select]
  1. _TITLE "Draw Rock" 'B+ started 2019-03-21
  2. SCREEN _NEWIMAGE(700, 700, 32)
  3. _SCREENMOVE 300, 20
  4. FOR y = 100 TO 600 STEP 100
  5.     FOR x = 100 TO 600 STEP 100
  6.         drawRock x, y, x * y / 1000
  7.         _PRINTSTRING (x - 20, y + 30), STR$(x * y / 1000)
  8.     NEXT
  9.  
  10. SUB drawRock (x0, y0, seed)
  11.     RANDOMIZE USING seed 'this prevents having to save a particular sequence of random numbers
  12.     pd6 = _PI / 6
  13.     rr = RND * 40 + 10
  14.     FOR j = 9 TO 3 STEP -1
  15.         rRad = .1 * j * rr
  16.         leg = rRad * (RND * .8 + .2)
  17.         x1 = x0: y1 = y0
  18.         xoff = RND * rRad - .5 * rRad + x0
  19.         yoff = RND * rRad - .5 * rRad + y0
  20.         rc = RND * 100 + 40
  21.         c& = _RGB32(rc, rc, rc)
  22.         FOR i = 0 TO 12
  23.             leg = rRad * (RND * .45 + .55)
  24.             x2 = xoff + leg * COS(i * pd6)
  25.             y2 = yoff + leg * SIN(i * pd6)
  26.             ftri x0, y0, x1, y1, x2, y2, c&
  27.             x1 = x2: y1 = y2
  28.             '_LIMIT 1
  29.         NEXT
  30.     NEXT
  31.  
  32. ' found at [abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]:    http://www.[abandoned, outdated and now likely malicious qb64 dot net website - don’t go there]/forum/index.php?topic=14425.0
  33. SUB ftri (x1, y1, x2, y2, x3, y3, K AS _UNSIGNED LONG)
  34.     a& = _NEWIMAGE(1, 1, 32)
  35.     _DEST a&
  36.     PSET (0, 0), K
  37.     _DEST 0
  38.     _MAPTRIANGLE _SEAMLESS(0, 0)-(0, 0)-(0, 0), a& TO(x1, y1)-(x2, y2)-(x3, y3)
  39.     _FREEIMAGE a& '<<< this is important!
  40.  

EDIT: needed square display case
« Last Edit: March 24, 2019, 12:37:02 am by bplus »

Offline eddy498

  • Newbie
  • Posts: 25
    • View Profile
Re: Simplifying code
« Reply #7 on: March 24, 2019, 12:42:27 am »
Sat here looking at that step code for a while lost xD. Okay let's see if I understood it. So basically it's getting the (x, y) and the doing the step (49, 24). Or whatever number you place inside is what it's adding to the x and y right?

Nice rocks. I'm saving these codes as references so I can use later :)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Simplifying code
« Reply #8 on: March 24, 2019, 12:52:38 am »
I am surprised you knew about MOD but not STEP ?? Yep, I think you have it, stare at this case of steps.

Code: QB64: [Select]
  1. LINE (0, 480)-STEP(20, 0)
  2. FOR i = 1 TO 30
  3.     LINE -STEP(0, -20)
  4.     LINE -STEP(20, 0)
« Last Edit: March 24, 2019, 12:53:49 am by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Simplifying code
« Reply #9 on: March 24, 2019, 01:29:58 am »
Quote
i havnt done anything with images yet tho,

You make a brick image the exact same way you make a background.

Oh hey! use the brick image to make the halfBrick image!
Code: QB64: [Select]
  1. CONST white = &HFFFFFFFF
  2. CONST black = &HFF000000
  3. CONST red = &HFFFF0000
  4. CONST grey = &HFF7C7C7C
  5. CONST darkgrey = &HFF323232
  6.  
  7. DIM SHARED scrn&, background&, brick&, halfBrick&
  8.  
  9. scrn& = _NEWIMAGE(800, 600, 32)
  10. SCREEN scrn&
  11. makeBrick
  12. makeHalfBrick
  13. MakeBackground
  14. _DEST display& '<<< or just plain 0
  15. gameover$ = "false"
  16.     CLS
  17.     _PUTIMAGE (0, 0), background&
  18.     _DISPLAY
  19.     _LIMIT 60
  20. LOOP UNTIL gameover$ = "true"
  21.     _DISPLAY
  22.  
  23. 'for ease of brick laying I made 1 brick 49 wide and 24 high so next brick starts 50 before or after or 25 above or below
  24. SUB makeBrick ()
  25.     brick& = _NEWIMAGE(50, 25, 32)
  26.     _DEST brick&
  27.     LINE (0, 0)-STEP(49, 24), darkgrey, BF
  28.     LINE (1, 1)-STEP(46, 20), red, BF
  29.     LINE (1, 0)-STEP(46, 0), white
  30.     LINE (47, 0)-STEP(0, 21), white
  31.     LINE (0, 0)-STEP(0, 22), black
  32.     LINE (0, 0 + 22)-STEP(47, 0), black
  33.  
  34. SUB makeHalfBrick ()
  35.     halfBrick& = _NEWIMAGE(25, 25, 32)
  36.     _DEST halfBrick&
  37.     _SOURCE brick&
  38.     _PUTIMAGE (0, 0)-(25, 25), brick&, halfBrick&, (25, 0)-(50, 25)
  39.  
  40. SUB MakeBackground
  41.     background& = _NEWIMAGE(800, 600)
  42.     _DEST background&
  43.     'make sky
  44.     LINE (0, 0)-(800, 460), &HFF00AAFF, BF
  45.     i = 0
  46.     FOR y = 450 TO 600 STEP 25 'all bricks start 25 pixels after last
  47.         i = (i + 1) MOD 2
  48.         IF i MOD 2 THEN adj = 25 ELSE adj = 0
  49.         FOR x = 0 + adj TO 800 - 2 * adj STEP 50 'all bricks start 50 pxels after last
  50.             _PUTIMAGE (x, y), brick&, background&
  51.         NEXT
  52.         IF i THEN _PUTIMAGE (0, y), halfBrick&, background&
  53.         IF i THEN _PUTIMAGE (775, y), halfBrick&, background&
  54.     NEXT
  55.  
  56.  
« Last Edit: March 24, 2019, 01:33:21 am by bplus »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Simplifying code
« Reply #10 on: March 24, 2019, 10:24:49 am »
I had my magnifying glass out this morning and noticed something slightly off with the left side of the half bricks along the right edge.

This fixes the makeHalfBrick sub:
Code: QB64: [Select]
  1. SUB makeHalfBrick ()
  2.     halfBrick& = _NEWIMAGE(25, 25, 32)
  3.     _DEST halfBrick&
  4.     '_SOURCE brick&   '<<< not needed
  5.  
  6.     'oh the left side of the half bricks on right edge are off, need more space
  7.     _PUTIMAGE (0, 0)-(25, 25), brick&, halfBrick&, (25, 0)-(50, 25)
  8.     'need to add black line on left side
  9.     LINE (0, 0)-STEP(0, 22), black 'EDIT add a black line to left side of half brick
  10.  
  11.  

I left the original sub intact in post above, if anyone wants to compare the results.


Offline eddy498

  • Newbie
  • Posts: 25
    • View Profile
Re: Simplifying code
« Reply #11 on: March 24, 2019, 11:00:37 pm »
ohh i see how you made the brick as a source and then halfed it.

Offline eddy498

  • Newbie
  • Posts: 25
    • View Profile
Re: Simplifying code
« Reply #12 on: March 26, 2019, 10:49:21 pm »
Hey bplus, for the next few days imma off of my usual comp so I want to work on something different since I don't have my full codes with Me on my laptop. Is there a way to do text that scrolls off the screen lime star wars or text that scrolls like the rpg games? If possible don't give me a full answer code done just the methods and explanation to see if I can figure it out myself through actual processes. I learn faster trying to solve it ;) thanks I'm looking through Google on my phone but Google is a mess for qb64 tutorials idk why

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Simplifying code
« Reply #13 on: March 26, 2019, 11:19:16 pm »
Hey bplus, for the next few days imma off of my usual comp so I want to work on something different since I don't have my full codes with Me on my laptop. Is there a way to do text that scrolls off the screen lime star wars or text that scrolls like the rpg games? If possible don't give me a full answer code done just the methods and explanation to see if I can figure it out myself through actual processes. I learn faster trying to solve it ;) thanks I'm looking through Google on my phone but Google is a mess for qb64 tutorials idk why

Not right off hand, that angle on z axis calls for 3D handling. Maybe Steve or Fellippe know some trick or Ashish with GL.

Nice Challenge!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Simplifying code
« Reply #14 on: March 26, 2019, 11:42:49 pm »
Hey bplus, for the next few days imma off of my usual comp so I want to work on something different since I don't have my full codes with Me on my laptop. Is there a way to do text that scrolls off the screen lime star wars or text that scrolls like the rpg games? If possible don't give me a full answer code done just the methods and explanation to see if I can figure it out myself through actual processes. I learn faster trying to solve it ;) thanks I'm looking through Google on my phone but Google is a mess for qb64 tutorials idk why

Not right off hand, that angle on z axis calls for 3D handling. Maybe Steve or Fellippe know some trick or Ashish with GL.

Nice Challenge!

I don’t think you’d actually need to worry with the z-axis.  Draw a line of text on a non-visible screen, and then use MAPTRIANGLE to copy the image of it to a new area where the top is smaller than the bottom.  It should imitate the effect, I’d think.

From a line of text in an area like:

 _______________
|                          |
——————————

To an area shaped like:

  ______________
/                          \
——————————-

Then scale size down as the text scrolls up the screen to fade into the distance.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!