Author Topic: Merry XMAS by Muneeb (The 10 years old programmer)  (Read 4982 times)

0 Members and 1 Guest are viewing this topic.

Offline Malik Muneeb

  • Newbie
  • Posts: 3
    • View Profile
Merry XMAS by Muneeb (The 10 years old programmer)
« on: June 14, 2018, 02:28:03 am »
Code: QB64: [Select]
  1.     Height AS LONG
  2.     Radius AS LONG
  3.     Position AS LONG
  4.     Move AS LONG
  5.  
  6.  
  7. DIM Music AS LONG
  8.  
  9. DIM SHARED Rootpath AS STRING
  10. DIM SHARED Fontpath(2) AS STRING
  11. DIM SHARED Font(2) AS LONG
  12.  
  13.  
  14. DIM SHARED Starx(10) AS LONG
  15. DIM SHARED Stary(10) AS LONG
  16. DIM SHARED Starfillx AS LONG
  17. DIM SHARED Starfilly AS LONG
  18. DIM SHARED Starmove AS LONG
  19.  
  20. DIM SHARED Snowx(13) AS LONG
  21. DIM SHARED Snowy(13) AS LONG
  22. DIM SHARED RNDNum(13) AS INTEGER
  23. DIM SHARED SnowMove AS INTEGER
  24.  
  25.  
  26. SCREEN _NEWIMAGE(800, 600, 32)
  27.  
  28. _TITLE "Merry XMAS"
  29.  
  30. Image = _LOADIMAGE("Attatchment/Santa Claus.jpg")
  31. Music = _SNDOPEN("Attatchment/Jingle Bells.wav", "sync,vol")
  32.  
  33. A.Height = 7
  34. A.Radius = 7
  35. A.Position = 1
  36. A.Move = 1
  37.  
  38. B.Height = 7
  39. B.Radius = 7
  40. B.Position = 1
  41. B.Move = 1
  42.  
  43. C.Height = 7
  44. C.Radius = 7
  45. C.Position = 1
  46. C.Move = 1
  47.  
  48. D.Height = 7
  49. D.Radius = 7
  50. D.Position = 1
  51. D.Move = 1
  52.  
  53. E.Height = 7
  54. E.Radius = 7
  55. E.Position = 1
  56. E.Move = 1
  57.  
  58. Rootpath = ENVIRON$("SYSTEMROOT")
  59. Fontpath(1) = Rootpath + "\Fonts\ARIALBD.ttf"
  60. Font(1) = _LOADFONT(Fontpath(1), 100)
  61.  
  62. Fontpath(2) = Rootpath + "\Fonts\SEGOESCB.ttf"
  63.  
  64. Font(2) = _LOADFONT(Fontpath(2), 72)
  65.  
  66. Starx(1) = -36
  67. Starx(2) = -27
  68. Starx(3) = 0
  69. Starx(4) = -18
  70. Starx(5) = -9
  71. Starx(6) = -36
  72. Starx(7) = -63
  73. Starx(8) = -54
  74. Starx(9) = -72
  75. Starx(10) = -45
  76.  
  77. Stary(1) = 200
  78. Stary(2) = 227
  79. Stary(3) = 227
  80. Stary(4) = 245
  81. Stary(5) = 272
  82. Stary(6) = 254
  83. Stary(7) = 272
  84. Stary(8) = 245
  85. Stary(9) = 227
  86. Stary(10) = 227
  87.  
  88. Starfillx = -36
  89. Starfilly = 236
  90. Starmove = 1
  91.  
  92. Snowx(1) = 40
  93. Snowx(2) = 100
  94. Snowx(3) = 160
  95. Snowx(4) = 220
  96. Snowx(5) = 280
  97. Snowx(6) = 340
  98. Snowx(7) = 400
  99. Snowx(8) = 460
  100. Snowx(9) = 520
  101. Snowx(10) = 580
  102. Snowx(11) = 640
  103. Snowx(12) = 700
  104. Snowx(13) = 760
  105.  
  106. Snowy(1) = -200
  107. Snowy(2) = -60
  108. Snowy(3) = -210
  109. Snowy(4) = -50
  110. Snowy(5) = -220
  111. Snowy(6) = -40
  112. Snowy(7) = -230
  113. Snowy(8) = -30
  114. Snowy(9) = -240
  115. Snowy(10) = -20
  116. Snowy(11) = -250
  117. Snowy(12) = -10
  118. Snowy(13) = -260
  119.  
  120. SnowMove = 2
  121.  
  122. FOR x = 1 TO 13
  123.  
  124.     RNDNum(x) = (RND * 2) + 6
  125.  
  126.  
  127. _SNDPLAY Music
  128.  
  129.  
  130.     _PUTIMAGE (0, 0), Image
  131.  
  132.  
  133.     Aball
  134.  
  135.  
  136. SUB Aball
  137.  
  138.     _LIMIT 40
  139.  
  140.     PCOPY _DISPLAY, 1
  141.  
  142.     CIRCLE (133.3, A.Height), A.Radius, _RGB(255, 255, 255)
  143.     PAINT (133.3, A.Height), _RGB(255, 255, 255)
  144.  
  145.     _DISPLAY
  146.     PCOPY 1, _DISPLAY
  147.  
  148.     IF A.Move = 1 THEN
  149.  
  150.         A.Height = A.Height + 3
  151.  
  152.     ELSE IF A.Move = 2 THEN
  153.  
  154.             A.Position = 2
  155.             A.Height = A.Height - 3
  156.  
  157.         END IF
  158.  
  159.     END IF
  160.  
  161.     IF A.Height >= 201 THEN
  162.  
  163.         A.Radius = A.Radius + 9
  164.         A.Move = 2
  165.  
  166.     ELSE IF A.Height <= 151 AND A.Position = 2 THEN
  167.  
  168.             DO
  169.                 A.Move = 0
  170.  
  171.                 _FONT Font(1)
  172.                 LOCATE 2, 98.3
  173.                 PRINT "M"
  174.  
  175.                 Bball
  176.  
  177.             LOOP
  178.  
  179.         END IF
  180.  
  181.     END IF
  182.  
  183.  
  184. SUB Bball
  185.  
  186.     _LIMIT 40
  187.  
  188.     PCOPY _DISPLAY, 1
  189.  
  190.     CIRCLE (266.6, B.Height), B.Radius, _RGB(255, 255, 255)
  191.     PAINT (266.6, B.Height), _RGB(255, 255, 255)
  192.  
  193.     _DISPLAY
  194.     PCOPY 1, _DISPLAY
  195.  
  196.     IF B.Move = 1 THEN
  197.  
  198.         B.Height = B.Height + 3
  199.  
  200.     ELSE IF B.Move = 2 THEN
  201.  
  202.             B.Position = 2
  203.             B.Height = B.Height - 3
  204.  
  205.         END IF
  206.  
  207.     END IF
  208.  
  209.     IF B.Height >= 201 THEN
  210.  
  211.         B.Radius = B.Radius + 9
  212.         B.Move = 2
  213.  
  214.     ELSE IF B.Height <= 151 AND B.Position = 2 THEN
  215.  
  216.             DO
  217.  
  218.  
  219.                 _FONT Font(1)
  220.                 LOCATE 2, 231.6
  221.                 PRINT "E"
  222.  
  223.                 Cball
  224.  
  225.             LOOP
  226.  
  227.         END IF
  228.  
  229.     END IF
  230.  
  231.  
  232. SUB Cball
  233.  
  234.     _LIMIT 40
  235.  
  236.     PCOPY _DISPLAY, 1
  237.  
  238.     CIRCLE (400, C.Height), C.Radius, _RGB(255, 255, 255)
  239.     PAINT (400, C.Height), _RGB(255, 255, 255)
  240.  
  241.     _DISPLAY
  242.     PCOPY 1, _DISPLAY
  243.  
  244.     IF C.Move = 1 THEN
  245.  
  246.         C.Height = C.Height + 3
  247.  
  248.     ELSE IF C.Move = 2 THEN
  249.  
  250.             C.Position = 2
  251.             C.Height = C.Height - 3
  252.  
  253.         END IF
  254.  
  255.     END IF
  256.  
  257.     IF C.Height >= 201 THEN
  258.  
  259.         C.Radius = C.Radius + 9
  260.         C.Move = 2
  261.  
  262.     ELSE IF C.Height <= 151 AND C.Position = 2 THEN
  263.  
  264.             DO
  265.  
  266.                 _FONT Font(1)
  267.                 LOCATE 2, 365
  268.                 PRINT "R"
  269.  
  270.                 Dball
  271.  
  272.             LOOP
  273.  
  274.         END IF
  275.  
  276.     END IF
  277.  
  278.  
  279. SUB Dball
  280.  
  281.     _LIMIT 40
  282.  
  283.     PCOPY _DISPLAY, 1
  284.  
  285.     CIRCLE (533.3, D.Height), D.Radius, _RGB(255, 255, 255)
  286.     PAINT (533.3, D.Height), _RGB(255, 255, 255)
  287.  
  288.     _DISPLAY
  289.     PCOPY 1, _DISPLAY
  290.  
  291.     IF D.Move = 1 THEN
  292.  
  293.         D.Height = D.Height + 3
  294.  
  295.     ELSE IF D.Move = 2 THEN
  296.  
  297.             D.Position = 2
  298.             D.Height = D.Height - 3
  299.  
  300.         END IF
  301.  
  302.     END IF
  303.  
  304.     IF D.Height >= 201 THEN
  305.  
  306.         D.Radius = D.Radius + 9
  307.         D.Move = 2
  308.  
  309.     ELSE IF D.Height <= 151 AND D.Position = 2 THEN
  310.  
  311.             DO
  312.  
  313.  
  314.                 _FONT Font(1)
  315.                 LOCATE 2, 498.3
  316.                 PRINT "R"
  317.  
  318.                 Eball
  319.  
  320.             LOOP
  321.  
  322.         END IF
  323.  
  324.     END IF
  325.  
  326.  
  327. SUB Eball
  328.  
  329.     _LIMIT 40
  330.  
  331.     PCOPY _DISPLAY, 1
  332.  
  333.     CIRCLE (666.6, E.Height), E.Radius, _RGB(255, 255, 255)
  334.     PAINT (666.6, E.Height), _RGB(255, 255, 255)
  335.  
  336.     _DISPLAY
  337.     PCOPY 1, _DISPLAY
  338.  
  339.     IF E.Move = 1 THEN
  340.  
  341.         E.Height = E.Height + 3
  342.  
  343.     ELSE IF E.Move = 2 THEN
  344.  
  345.             E.Position = 2
  346.             E.Height = E.Height - 3
  347.  
  348.         END IF
  349.  
  350.     END IF
  351.  
  352.     IF E.Height >= 201 THEN
  353.  
  354.         E.Radius = E.Radius + 9
  355.         E.Move = 2
  356.  
  357.     ELSE IF E.Height <= 151 AND E.Position = 2 THEN
  358.  
  359.             _FONT Font(1)
  360.             LOCATE 2, 631.6
  361.             PRINT "Y"
  362.  
  363.             DO
  364.  
  365.                 Star
  366.  
  367.             LOOP
  368.  
  369.         END IF
  370.  
  371.     END IF
  372.  
  373.  
  374. SUB Star
  375.  
  376.     _LIMIT 30
  377.  
  378.     PCOPY _DISPLAY, 1
  379.  
  380.     PSET (Starx(1), Stary(1)), _RGB(254, 254, 254)
  381.     LINE -(Starx(1), Stary(1)), _RGB(254, 254, 254)
  382.     LINE -(Starx(2), Stary(2)), _RGB(254, 254, 254)
  383.     LINE -(Starx(3), Stary(3)), _RGB(254, 254, 254)
  384.     LINE -(Starx(4), Stary(4)), _RGB(254, 254, 254)
  385.     LINE -(Starx(5), Stary(5)), _RGB(254, 254, 254)
  386.     LINE -(Starx(6), Stary(6)), _RGB(254, 254, 254)
  387.     LINE -(Starx(7), Stary(7)), _RGB(254, 254, 254)
  388.     LINE -(Starx(8), Stary(8)), _RGB(254, 254, 254)
  389.     LINE -(Starx(9), Stary(9)), _RGB(254, 254, 254)
  390.     LINE -(Starx(10), Stary(10)), _RGB(254, 254, 254)
  391.     LINE -(Starx(1), Stary(1)), _RGB(254, 254, 254)
  392.  
  393.     IF Starx(10) >= 0 THEN
  394.  
  395.         PAINT (Starfillx, Starfilly), _RGB(254, 254, 254)
  396.  
  397.     END IF
  398.  
  399.     _DISPLAY
  400.     PCOPY 1, _DISPLAY
  401.  
  402.     IF Starmove = 1 THEN
  403.  
  404.         FOR x = 1 TO 10
  405.  
  406.             Starx(x) = Starx(x) + 4
  407.             Stary(x) = Stary(x) + 1
  408.  
  409.         NEXT x
  410.  
  411.         Starfillx = Starfillx + 4
  412.         Starfilly = Starfilly + 1
  413.  
  414.     END IF
  415.  
  416.     IF Starmove = 2 THEN
  417.  
  418.         FOR x = 1 TO 10
  419.             Starx(x) = Starx(x) + 4
  420.             Stary(x) = Stary(x)
  421.  
  422.         NEXT x
  423.  
  424.         Starfillx = Starfillx + 4
  425.         Starfilly = Starfilly
  426.  
  427.     END IF
  428.  
  429.     IF Starmove = 3 THEN
  430.  
  431.         FOR x = 1 TO 10
  432.  
  433.             Starx(x) = Starx(x) + 4
  434.             Stary(x) = Stary(x) - 1
  435.  
  436.         NEXT x
  437.  
  438.         Starfillx = Starfillx + 4
  439.         Starfilly = Starfilly - 1
  440.  
  441.     END IF
  442.  
  443.     IF Starmove = 4 THEN
  444.  
  445.         DO
  446.  
  447.             _LIMIT 300
  448.  
  449.             _PUTIMAGE (0, 0), Image
  450.  
  451.             COLOR _RGB(255, 255, 255)
  452.             _FONT Font(1)
  453.             LOCATE 2, 98.3
  454.             PRINT "M"
  455.             LOCATE 2, 231.6
  456.             PRINT "E"
  457.             LOCATE 2, 365
  458.             PRINT "R"
  459.             LOCATE 2, 498.3
  460.             PRINT "R"
  461.             LOCATE 2, 631.6
  462.             PRINT "Y"
  463.             _FONT Font(2)
  464.             LOCATE 5, 256
  465.             PRINT "X"
  466.             LOCATE 5, 328
  467.             PRINT "M"
  468.             LOCATE 5, 400
  469.             PRINT "A"
  470.             LOCATE 5, 472
  471.             PRINT "S"
  472.  
  473.             Balls
  474.  
  475.             _DISPLAY
  476.  
  477.         LOOP
  478.  
  479.     END IF
  480.  
  481.     IF Stary(5) >= 360 THEN
  482.  
  483.         Starmove = 2
  484.  
  485.     END IF
  486.  
  487.     IF Starx(3) >= 544 THEN
  488.  
  489.         Starmove = 3
  490.  
  491.     END IF
  492.  
  493.     IF Starx(9) >= 800 THEN
  494.  
  495.         Starmove = 4
  496.  
  497.     END IF
  498.  
  499.     IF Starx(9) >= 256 THEN
  500.  
  501.         _FONT Font(2)
  502.         COLOR _RGB(255, 255, 255)
  503.         LOCATE 5, 256
  504.         PRINT "X"
  505.  
  506.     END IF
  507.  
  508.     IF Starx(9) >= 328 THEN
  509.  
  510.         _FONT Font(2)
  511.         COLOR _RGB(255, 255, 255)
  512.         LOCATE 5, 328
  513.         PRINT "M"
  514.  
  515.     END IF
  516.  
  517.     IF Starx(9) >= 400 THEN
  518.  
  519.         _FONT Font(2)
  520.         COLOR _RGB(255, 255, 255)
  521.         LOCATE 5, 400
  522.         PRINT "A"
  523.  
  524.     END IF
  525.  
  526.     IF Starx(9) >= 472 THEN
  527.  
  528.         _FONT Font(2)
  529.         COLOR _RGB(255, 255, 255)
  530.         LOCATE 5, 472
  531.         PRINT "S"
  532.  
  533.     END IF
  534.  
  535.  
  536. SUB Balls
  537.  
  538.     FOR x = 1 TO 13
  539.  
  540.         CIRCLE (Snowx(x), Snowy(x)), RNDNum(x), _RGB(253, 253, 253)
  541.         PAINT (Snowx(x), Snowy(x)), _RGB(253, 253, 253)
  542.  
  543.         SELECT CASE Snowx(2)
  544.  
  545.             CASE IS >= 140
  546.  
  547.                 SnowMove = 1
  548.  
  549.             CASE IS <= 60
  550.  
  551.                 SnowMove = 2
  552.  
  553.         END SELECT
  554.  
  555.         SELECT CASE SnowMove
  556.  
  557.             CASE 1
  558.  
  559.                 Snowx(x) = Snowx(x) - 2
  560.  
  561.             CASE 2
  562.  
  563.                 Snowx(x) = Snowx(x) + 2
  564.  
  565.         END SELECT
  566.  
  567.         Snowy(x) = Snowy(x) + INT(RND * 14) + 1
  568.  
  569.         IF Snowy(x) >= 600 THEN Snowy(x) = 0
  570.  
  571.     NEXT x
  572.  
  573.  
  574.  
* Attatchment.zip (Filesize: 4.87 MB, Downloads: 277)
I am Muneeb.I am a 10 years old Programmer and a Web Designer.I love programming.

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: Merry XMAS by Muneeb (The 10 years old programmer)
« Reply #1 on: June 14, 2018, 04:19:48 am »
Good work, kid! :D
if (Me.success) {Me.improve()} else {Me.tryAgain()}


My Projects - https://github.com/AshishKingdom?tab=repositories
OpenGL tutorials - https://ashishkingdom.github.io/OpenGL-Tutorials

Offline Malik Muneeb

  • Newbie
  • Posts: 3
    • View Profile
Re: Merry XMAS by Muneeb (The 10 years old programmer)
« Reply #2 on: June 14, 2018, 04:58:39 am »
Thanks Ashish!!!...
I am Muneeb.I am a 10 years old Programmer and a Web Designer.I love programming.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Merry XMAS by Muneeb (The 10 years old programmer)
« Reply #3 on: June 14, 2018, 09:37:07 am »
Hi Malik,

Welcome to forum! You are only 10?

Really nice first post! I will play it the hottest day in August. I like the version of Jingle bells too.

The work with text letters great!

Offline Malik Muneeb

  • Newbie
  • Posts: 3
    • View Profile
Re: Merry XMAS by Muneeb (The 10 years old programmer)
« Reply #4 on: June 14, 2018, 08:39:03 pm »
Hi BPlus!!!...
Thanks that you welcomed me!Yeah,I am only 10.
And so much Thanks that you liked and replied to my first post.
I am Muneeb.I am a 10 years old Programmer and a Web Designer.I love programming.