Author Topic: Animated Walking Man  (Read 4546 times)

0 Members and 1 Guest are viewing this topic.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Animated Walking Man
« on: October 22, 2019, 09:47:35 pm »
This might be my very first animated walking man I ever made, believe it or not. I've tried a few times with QBasic ages ago but could never get it down really good. _DISPLAY really does a great job with anything animated. Feel free to use this code on anything you want. I might use it again later on to make a simple game of some kind. This is just something I threw together tonight. I've been sort of on a break programming lately, giving myself some rest a bit. The first few months of QB64 I went wild as you all know. LOL If you have questions or comments, please do so.
To make him walk, use the left and right arrow keys. He doesn't jump yet. I might add that later sometime.

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(800, 600, 32)
  2. start:
  3. 'grass
  4. LINE (0, 300)-(800, 600), _RGB32(127, 255, 127), BF
  5. 'sky
  6. LINE (0, 0)-(800, 299), _RGB32(127, 127, 255), BF
  7. x = 100: y = 270
  8. m = 1
  9. LINE (0, 0)-(800, 299), _RGB32(127, 127, 255), BF
  10. FOR sz = .25 TO 5 STEP .25
  11.     CIRCLE (x, y), sz, _RGB32(128, 0, 166)
  12. NEXT sz
  13. 'hat
  14. LINE (x - 8, y - 4)-(x + 8, y - 4), _RGB32(155, 177, 61)
  15. LINE (x - 5, y - 7)-(x + 5, y - 4), _RGB32(155, 177, 61), BF
  16. 'body
  17. LINE (x, y + 5)-(x, y + 15), _RGB32(128, 0, 166)
  18. 'arms
  19. LINE (x, y + 10)-(x, y + 25), _RGB32(128, 0, 166)
  20. LINE (x, y + 10)-(x, y + 25), _RGB32(128, 0, 166)
  21. 'legs
  22. LINE (x, y + 15)-(x, y + 29), _RGB32(128, 0, 166)
  23. LINE (x, y + 15)-(x, y + 29), _RGB32(128, 0, 166)
  24.     _LIMIT 500
  25.     a$ = INKEY$
  26.     IF a$ = CHR$(27) THEN END
  27.     'Move Right
  28.     IF a$ = CHR$(0) + CHR$(77) THEN
  29.         m = m + 1: x = x + 5
  30.         IF x > 785 THEN x = 785
  31.         d = 1
  32.         GOSUB check:
  33.     END IF
  34.     'Move Left
  35.     IF a$ = CHR$(0) + CHR$(75) THEN
  36.         m = m - 1: x = x - 5
  37.         IF x < 15 THEN x = 15
  38.         d = 2
  39.         GOSUB check:
  40.     END IF
  41. check:
  42. IF m = 11 THEN m = 1
  43. IF m = 0 THEN m = 10
  44. IF m = 1 THEN GOSUB frame1:
  45. IF m = 2 THEN GOSUB frame2:
  46. IF m = 3 THEN GOSUB frame3:
  47. IF m = 4 THEN GOSUB frame4:
  48. IF m = 5 THEN GOSUB frame5:
  49. IF m = 6 THEN GOSUB frame6:
  50. IF m = 7 THEN GOSUB frame5:
  51. IF m = 8 THEN GOSUB frame4:
  52. IF m = 9 THEN GOSUB frame3:
  53. IF m = 10 THEN GOSUB frame2:
  54. frame1:
  55. 'erase first
  56. LINE (0, 0)-(800, 299), _RGB32(127, 127, 255), BF
  57. 'head
  58. FOR sz = .25 TO 4 STEP .25
  59.     CIRCLE (x, y), sz, _RGB32(128, 0, 166)
  60. NEXT sz
  61. 'hat
  62. LINE (x - 8, y - 4)-(x + 8, y - 4), _RGB32(155, 177, 61)
  63. LINE (x - 5, y - 7)-(x + 5, y - 4), _RGB32(155, 177, 61), BF
  64. 'body
  65. LINE (x, y + 4)-(x, y + 15), _RGB32(128, 0, 166)
  66. 'arms
  67. LINE (x, y + 10)-(x - 18, y + 20), _RGB32(128, 0, 166)
  68. LINE (x, y + 10)-(x + 18, y + 20), _RGB32(128, 0, 166)
  69. 'legs
  70. LINE (x, y + 15)-(x - 18, y + 29), _RGB32(128, 0, 166)
  71. LINE (x, y + 15)-(x + 18, y + 29), _RGB32(128, 0, 166)
  72. frame2:
  73. 'erase first
  74. LINE (0, 0)-(800, 299), _RGB32(127, 127, 255), BF
  75. 'head
  76. FOR sz = .25 TO 4 STEP .25
  77.     CIRCLE (x, y), sz, _RGB32(128, 0, 166)
  78. NEXT sz
  79. 'hat
  80. LINE (x - 8, y - 4)-(x + 8, y - 4), _RGB32(155, 177, 61)
  81. LINE (x - 5, y - 7)-(x + 5, y - 4), _RGB32(155, 177, 61), BF
  82. 'body
  83. LINE (x, y + 4)-(x, y + 15), _RGB32(128, 0, 166)
  84. 'arms
  85. LINE (x, y + 10)-(x - 15, y + 20), _RGB32(128, 0, 166)
  86. LINE (x, y + 10)-(x + 15, y + 20), _RGB32(128, 0, 166)
  87. 'legs
  88. LINE (x, y + 15)-(x - 15, y + 29), _RGB32(128, 0, 166)
  89. LINE (x, y + 15)-(x + 15, y + 29), _RGB32(128, 0, 166)
  90. frame3:
  91. 'erase first
  92. LINE (0, 0)-(800, 299), _RGB32(127, 127, 255), BF
  93. 'head
  94. FOR sz = .25 TO 4 STEP .25
  95.     CIRCLE (x, y), sz, _RGB32(128, 0, 166)
  96. NEXT sz
  97. 'hat
  98. LINE (x - 8, y - 4)-(x + 8, y - 4), _RGB32(155, 177, 61)
  99. LINE (x - 5, y - 7)-(x + 5, y - 4), _RGB32(155, 177, 61), BF
  100. 'body
  101. LINE (x, y + 4)-(x, y + 15), _RGB32(128, 0, 166)
  102. 'arms
  103. LINE (x, y + 10)-(x - 12, y + 20), _RGB32(128, 0, 166)
  104. LINE (x, y + 10)-(x + 12, y + 20), _RGB32(128, 0, 166)
  105. 'legs
  106. LINE (x, y + 15)-(x - 12, y + 29), _RGB32(128, 0, 166)
  107. LINE (x, y + 15)-(x + 12, y + 29), _RGB32(128, 0, 166)
  108.  
  109. frame4:
  110. 'erase first
  111. LINE (0, 0)-(800, 299), _RGB32(127, 127, 255), BF
  112. 'head
  113. FOR sz = .25 TO 4 STEP .25
  114.     CIRCLE (x, y), sz, _RGB32(128, 0, 166)
  115. NEXT sz
  116. 'hat
  117. LINE (x - 8, y - 4)-(x + 8, y - 4), _RGB32(155, 177, 61)
  118. LINE (x - 5, y - 7)-(x + 5, y - 4), _RGB32(155, 177, 61), BF
  119. 'body
  120. LINE (x, y + 4)-(x, y + 15), _RGB32(128, 0, 166)
  121. 'arms
  122. LINE (x, y + 10)-(x - 9, y + 20), _RGB32(128, 0, 166)
  123. LINE (x, y + 10)-(x + 9, y + 20), _RGB32(128, 0, 166)
  124. 'legs
  125. LINE (x, y + 15)-(x - 9, y + 29), _RGB32(128, 0, 166)
  126. LINE (x, y + 15)-(x + 9, y + 29), _RGB32(128, 0, 166)
  127.  
  128. frame5:
  129. 'erase first
  130. LINE (0, 0)-(800, 299), _RGB32(127, 127, 255), BF
  131. 'head
  132. FOR sz = .25 TO 4 STEP .25
  133.     CIRCLE (x, y), sz, _RGB32(128, 0, 166)
  134. NEXT sz
  135. 'hat
  136. LINE (x - 8, y - 4)-(x + 8, y - 4), _RGB32(155, 177, 61)
  137. LINE (x - 5, y - 7)-(x + 5, y - 4), _RGB32(155, 177, 61), BF
  138. 'body
  139. LINE (x, y + 4)-(x, y + 15), _RGB32(128, 0, 166)
  140. 'arms
  141. LINE (x, y + 10)-(x - 6, y + 25), _RGB32(128, 0, 166)
  142. LINE (x, y + 10)-(x + 6, y + 25), _RGB32(128, 0, 166)
  143. 'legs
  144. LINE (x, y + 15)-(x - 6, y + 29), _RGB32(128, 0, 166)
  145. LINE (x, y + 15)-(x + 6, y + 29), _RGB32(128, 0, 166)
  146. frame6:
  147. 'erase first
  148. LINE (0, 0)-(800, 299), _RGB32(127, 127, 255), BF
  149. 'head
  150. FOR sz = .25 TO 4 STEP .25
  151.     CIRCLE (x, y), sz, _RGB32(128, 0, 166)
  152. NEXT sz
  153. 'hat
  154. LINE (x - 8, y - 4)-(x + 8, y - 4), _RGB32(155, 177, 61)
  155. LINE (x - 5, y - 7)-(x + 5, y - 4), _RGB32(155, 177, 61), BF
  156. 'body
  157. LINE (x, y + 4)-(x, y + 15), _RGB32(128, 0, 166)
  158. 'arms
  159. LINE (x, y + 10)-(x, y + 25), _RGB32(128, 0, 166)
  160. LINE (x, y + 10)-(x, y + 25), _RGB32(128, 0, 166)
  161. 'legs
  162. LINE (x, y + 15)-(x, y + 29), _RGB32(128, 0, 166)
  163. LINE (x, y + 15)-(x, y + 29), _RGB32(128, 0, 166)
  164.  

« Last Edit: October 22, 2019, 09:50:52 pm by SierraKen »

Offline Ashish

  • Forum Resident
  • Posts: 630
  • Never Give Up!
    • View Profile
Re: Animated Walking Man
« Reply #1 on: October 23, 2019, 10:21:02 am »
Good job!
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 TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Animated Walking Man
« Reply #2 on: October 23, 2019, 03:32:14 pm »
Hi SierraKen
I find it very fine! The colors and the movement of the character!

Indeed I see that do you like old programming style with GOTO and GOSUB!

Moreover I have thought that your slim man walking is only half of the universe... and "per par condicio" I post this little mod : big man walking (sorry I have more comfort using closed block of code for my way to code)!
Thanks to share

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(800, 600, 32)
  2. start:
  3. 'grass
  4. LINE (0, 300)-(800, 600), _RGB32(127, 255, 127), BF
  5. 'sky
  6. LINE (0, 0)-(800, 299), _RGB32(127, 127, 255), BF
  7. x = 100: y = 270
  8. m = 1
  9. LINE (0, 0)-(800, 299), _RGB32(127, 127, 255), BF
  10. FOR sz = .25 TO 5 STEP .25
  11.     CIRCLE (x, y), sz, _RGB32(128, 0, 166)
  12. NEXT sz
  13. 'hat
  14. LINE (x - 8, y - 4)-(x + 8, y - 4), _RGB32(155, 177, 61)
  15. LINE (x - 5, y - 7)-(x + 5, y - 4), _RGB32(155, 177, 61), BF
  16. 'body
  17. 'LINE (x, y + 5)-(x, y + 15), _RGB32(128, 0, 166)
  18. body x, y
  19. 'arms
  20. LINE (x, y + 10)-(x, y + 25), _RGB32(128, 0, 166)
  21. LINE (x, y + 10)-(x, y + 25), _RGB32(128, 0, 166)
  22. 'legs
  23. LINE (x, y + 15)-(x, y + 29), _RGB32(128, 0, 166)
  24. LINE (x, y + 15)-(x, y + 29), _RGB32(128, 0, 166)
  25.     _LIMIT 500
  26.     a$ = INKEY$
  27.     IF a$ = CHR$(27) THEN END
  28.     'Move Right
  29.     IF a$ = CHR$(0) + CHR$(77) THEN
  30.         m = m + 1: x = x + 5
  31.         IF x > 785 THEN x = 785
  32.         d = 1
  33.         GOSUB check:
  34.     END IF
  35.     'Move Left
  36.     IF a$ = CHR$(0) + CHR$(75) THEN
  37.         m = m - 1: x = x - 5
  38.         IF x < 15 THEN x = 15
  39.         d = 2
  40.         GOSUB check:
  41.     END IF
  42. check:
  43. IF m = 11 THEN m = 1
  44. IF m = 0 THEN m = 10
  45. IF m = 1 THEN GOSUB frame1:
  46. IF m = 2 THEN GOSUB frame2:
  47. IF m = 3 THEN GOSUB frame3:
  48. IF m = 4 THEN GOSUB frame4:
  49. IF m = 5 THEN GOSUB frame5:
  50. IF m = 6 THEN GOSUB frame6:
  51. IF m = 7 THEN GOSUB frame5:
  52. IF m = 8 THEN GOSUB frame4:
  53. IF m = 9 THEN GOSUB frame3:
  54. IF m = 10 THEN GOSUB frame2:
  55. frame1:
  56. 'erase first
  57. LINE (0, 0)-(800, 299), _RGB32(127, 127, 255), BF
  58. 'head
  59. FOR sz = .25 TO 4 STEP .25
  60.     CIRCLE (x, y), sz, _RGB32(128, 0, 166)
  61. NEXT sz
  62. 'hat
  63. LINE (x - 8, y - 4)-(x + 8, y - 4), _RGB32(155, 177, 61)
  64. LINE (x - 5, y - 7)-(x + 5, y - 4), _RGB32(155, 177, 61), BF
  65. 'body
  66. 'LINE (x, y + 4)-(x, y + 15), _RGB32(128, 0, 166)
  67. body x, y
  68. 'arms
  69. LINE (x, y + 10)-(x - 18, y + 20), _RGB32(128, 0, 166)
  70. LINE (x, y + 10)-(x + 18, y + 20), _RGB32(128, 0, 166)
  71. 'legs
  72. LINE (x, y + 15)-(x - 18, y + 29), _RGB32(128, 0, 166)
  73. LINE (x, y + 15)-(x + 18, y + 29), _RGB32(128, 0, 166)
  74. frame2:
  75. 'erase first
  76. LINE (0, 0)-(800, 299), _RGB32(127, 127, 255), BF
  77. 'head
  78. FOR sz = .25 TO 4 STEP .25
  79.     CIRCLE (x, y), sz, _RGB32(128, 0, 166)
  80. NEXT sz
  81. 'hat
  82. LINE (x - 8, y - 4)-(x + 8, y - 4), _RGB32(155, 177, 61)
  83. LINE (x - 5, y - 7)-(x + 5, y - 4), _RGB32(155, 177, 61), BF
  84. 'body
  85. 'LINE (x, y + 4)-(x, y + 15), _RGB32(128, 0, 166)
  86. body x, y
  87. 'arms
  88. LINE (x, y + 10)-(x - 15, y + 20), _RGB32(128, 0, 166)
  89. LINE (x, y + 10)-(x + 15, y + 20), _RGB32(128, 0, 166)
  90. 'legs
  91. LINE (x, y + 15)-(x - 15, y + 29), _RGB32(128, 0, 166)
  92. LINE (x, y + 15)-(x + 15, y + 29), _RGB32(128, 0, 166)
  93. frame3:
  94. 'erase first
  95. LINE (0, 0)-(800, 299), _RGB32(127, 127, 255), BF
  96. 'head
  97. FOR sz = .25 TO 4 STEP .25
  98.     CIRCLE (x, y), sz, _RGB32(128, 0, 166)
  99. NEXT sz
  100. 'hat
  101. LINE (x - 8, y - 4)-(x + 8, y - 4), _RGB32(155, 177, 61)
  102. LINE (x - 5, y - 7)-(x + 5, y - 4), _RGB32(155, 177, 61), BF
  103. 'body
  104. 'LINE (x, y + 4)-(x, y + 15), _RGB32(128, 0, 166)
  105. body x, y
  106. 'arms
  107. LINE (x, y + 10)-(x - 12, y + 20), _RGB32(128, 0, 166)
  108. LINE (x, y + 10)-(x + 12, y + 20), _RGB32(128, 0, 166)
  109. 'legs
  110. LINE (x, y + 15)-(x - 12, y + 29), _RGB32(128, 0, 166)
  111. LINE (x, y + 15)-(x + 12, y + 29), _RGB32(128, 0, 166)
  112.  
  113. frame4:
  114. 'erase first
  115. LINE (0, 0)-(800, 299), _RGB32(127, 127, 255), BF
  116. 'head
  117. FOR sz = .25 TO 4 STEP .25
  118.     CIRCLE (x, y), sz, _RGB32(128, 0, 166)
  119. NEXT sz
  120. 'hat
  121. LINE (x - 8, y - 4)-(x + 8, y - 4), _RGB32(155, 177, 61)
  122. LINE (x - 5, y - 7)-(x + 5, y - 4), _RGB32(155, 177, 61), BF
  123. 'body
  124. 'LINE (x, y + 4)-(x, y + 15), _RGB32(128, 0, 166)
  125. body x, y
  126. 'arms
  127. LINE (x, y + 10)-(x - 9, y + 20), _RGB32(128, 0, 166)
  128. LINE (x, y + 10)-(x + 9, y + 20), _RGB32(128, 0, 166)
  129. 'legs
  130. LINE (x, y + 15)-(x - 9, y + 29), _RGB32(128, 0, 166)
  131. LINE (x, y + 15)-(x + 9, y + 29), _RGB32(128, 0, 166)
  132.  
  133. frame5:
  134. 'erase first
  135. LINE (0, 0)-(800, 299), _RGB32(127, 127, 255), BF
  136. 'head
  137. FOR sz = .25 TO 4 STEP .25
  138.     CIRCLE (x, y), sz, _RGB32(128, 0, 166)
  139. NEXT sz
  140. 'hat
  141. LINE (x - 8, y - 4)-(x + 8, y - 4), _RGB32(155, 177, 61)
  142. LINE (x - 5, y - 7)-(x + 5, y - 4), _RGB32(155, 177, 61), BF
  143. 'body
  144. 'LINE (x, y + 4)-(x, y + 15), _RGB32(128, 0, 166)
  145. body x, y
  146. 'arms
  147. LINE (x, y + 10)-(x - 6, y + 25), _RGB32(128, 0, 166)
  148. LINE (x, y + 10)-(x + 6, y + 25), _RGB32(128, 0, 166)
  149. 'legs
  150. LINE (x, y + 15)-(x - 6, y + 29), _RGB32(128, 0, 166)
  151. LINE (x, y + 15)-(x + 6, y + 29), _RGB32(128, 0, 166)
  152. frame6:
  153. 'erase first
  154. LINE (0, 0)-(800, 299), _RGB32(127, 127, 255), BF
  155. 'head
  156. FOR sz = .25 TO 4 STEP .25
  157.     CIRCLE (x, y), sz, _RGB32(128, 0, 166)
  158. NEXT sz
  159. 'hat
  160. LINE (x - 8, y - 4)-(x + 8, y - 4), _RGB32(155, 177, 61)
  161. LINE (x - 5, y - 7)-(x + 5, y - 4), _RGB32(155, 177, 61), BF
  162. 'body
  163. 'LINE (x, y + 4)-(x, y + 15), _RGB32(128, 0, 166)
  164. body x, y
  165. 'arms
  166. LINE (x, y + 10)-(x, y + 25), _RGB32(128, 0, 166)
  167. LINE (x, y + 10)-(x, y + 25), _RGB32(128, 0, 166)
  168. 'legs
  169. LINE (x, y + 15)-(x, y + 29), _RGB32(128, 0, 166)
  170. LINE (x, y + 15)-(x, y + 29), _RGB32(128, 0, 166)
  171.  
  172. SUB body (x, y)
  173.     CIRCLE (x, y + 10), 7, _RGB32(128, 0, 166), , , 1.3
  174.     PAINT (x, y + 10), _RGB32(128, 0, 166), _RGB32(128, 0, 166)
Programming isn't difficult, only it's  consuming time and coffee

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Animated Walking Man
« Reply #3 on: October 23, 2019, 03:51:45 pm »
GOTO's, GOSUB's or not, I find animation performed without sprites fascinating. Apart from the diminutive size of the main character in both examples, which gave these old eyes a workout, you both did a marvellous job. Thank you.
Logic is the beginning of wisdom.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Animated Walking Man
« Reply #4 on: October 23, 2019, 04:14:47 pm »
Wow thank you everyone! TempodiBasic, I like how you made him. I think next I'll change it from stopping at the ends of the window to just appearing on the other side of the window to have a non-stop walking man. I think I'll be slowly turning this into a simple game. :)

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Animated Walking Man
« Reply #5 on: October 23, 2019, 04:34:03 pm »
Nice work, SierraKen

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Animated Walking Man
« Reply #6 on: October 24, 2019, 12:46:21 am »
Thanks Petr!

This is a game in progress now. Tonight I made another personal breakthrough and figured out how to make him jump in both directions! I used that same Fun With Math program I made months ago but changed it to make an arch angle for X. I also made him larger so he's easier to see and added a funny sound when you jump. Plus I added a face to his head that looks in the direction you are moving. And as I stated before, I changed it so he can walk past the screen now in both directions and end up on another screen. Next I plan on making shapes to jump over.

Here is my work-in-progress. I added a title bar saying how to use the game and that it's at version 0.5 right now.

(Edit: There's an updated version after this post on this forum page.)

Code: QB64: [Select]
  1. _TITLE "Walking Man by Ken G. v.0.5 | Use Arrow Keys and Space Bar to Jump"
  2. SCREEN _NEWIMAGE(800, 600, 32)
  3. start:
  4. 'grass
  5. LINE (0, 270)-(800, 600), _RGB32(127, 255, 127), BF
  6. 'sky
  7. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  8. x = 100: y = 211
  9. m = 1
  10. d = 1
  11. 'head
  12. FOR sz = .25 TO 8 STEP .25
  13.     CIRCLE (x, y), sz, _RGB32(128, 0, 166)
  14. NEXT sz
  15. 'hat
  16. LINE (x - 16, y - 8)-(x + 16, y - 8), _RGB32(155, 177, 61)
  17. LINE (x - 10, y - 14)-(x + 10, y - 8), _RGB32(155, 177, 61), BF
  18. 'body
  19. LINE (x, y + 8)-(x, y + 30), _RGB32(128, 0, 166)
  20. 'arms
  21. LINE (x, y + 20)-(x - 36, y + 40), _RGB32(128, 0, 166)
  22. LINE (x, y + 20)-(x + 36, y + 40), _RGB32(128, 0, 166)
  23. 'legs
  24. LINE (x, y + 30)-(x - 36, y + 58), _RGB32(128, 0, 166)
  25. LINE (x, y + 30)-(x + 36, y + 58), _RGB32(128, 0, 166)
  26. 'face
  27. FOR sz = .25 TO 1 STEP .25
  28.     CIRCLE (x + 4, y - 1), sz, _RGB32(127, 255, 127)
  29. NEXT sz
  30. LINE (x + 3, y + 4)-(x + 6, y + 5), _RGB32(127, 255, 127), BF
  31.     _LIMIT 500
  32.     a$ = INKEY$
  33.     IF a$ = CHR$(27) THEN END
  34.     'Move Right
  35.     IF a$ = CHR$(0) + CHR$(77) THEN
  36.         m = m + 1: x = x + 5
  37.         IF x > 785 THEN x = 15
  38.         d = 1
  39.         GOSUB check:
  40.     END IF
  41.     'Move Left
  42.     IF a$ = CHR$(0) + CHR$(75) THEN
  43.         m = m - 1: x = x - 5
  44.         IF x < 15 THEN x = 785
  45.         d = 2
  46.         GOSUB check:
  47.     END IF
  48.     IF a$ = " " THEN
  49.         IF d = 1 THEN GOSUB jumpright:
  50.         IF d = 2 THEN GOSUB jumpleft:
  51.     END IF
  52. check:
  53. IF m = 11 THEN m = 1
  54. IF m = 0 THEN m = 10
  55. IF m = 1 THEN GOSUB frame1:
  56. IF m = 2 THEN GOSUB frame2:
  57. IF m = 3 THEN GOSUB frame3:
  58. IF m = 4 THEN GOSUB frame4:
  59. IF m = 5 THEN GOSUB frame5:
  60. IF m = 6 THEN GOSUB frame6:
  61. IF m = 7 THEN GOSUB frame5:
  62. IF m = 8 THEN GOSUB frame4:
  63. IF m = 9 THEN GOSUB frame3:
  64. IF m = 10 THEN GOSUB frame2:
  65. frame1:
  66. 'erase first
  67. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  68. 'head
  69. FOR sz = .25 TO 8 STEP .25
  70.     CIRCLE (x, y), sz, _RGB32(128, 0, 166)
  71. NEXT sz
  72. GOSUB face:
  73. 'hat
  74. LINE (x - 16, y - 8)-(x + 16, y - 8), _RGB32(155, 177, 61)
  75. LINE (x - 10, y - 14)-(x + 10, y - 8), _RGB32(155, 177, 61), BF
  76. 'body
  77. LINE (x, y + 8)-(x, y + 30), _RGB32(128, 0, 166)
  78. 'arms
  79. LINE (x, y + 20)-(x - 36, y + 40), _RGB32(128, 0, 166)
  80. LINE (x, y + 20)-(x + 36, y + 40), _RGB32(128, 0, 166)
  81. 'legs
  82. LINE (x, y + 30)-(x - 36, y + 58), _RGB32(128, 0, 166)
  83. LINE (x, y + 30)-(x + 36, y + 58), _RGB32(128, 0, 166)
  84. frame2:
  85. 'erase first
  86. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  87. 'head
  88. FOR sz = .25 TO 8 STEP .25
  89.     CIRCLE (x, y), sz, _RGB32(128, 0, 166)
  90. NEXT sz
  91. GOSUB face:
  92. 'hat
  93. LINE (x - 16, y - 8)-(x + 16, y - 8), _RGB32(155, 177, 61)
  94. LINE (x - 10, y - 14)-(x + 10, y - 8), _RGB32(155, 177, 61), BF
  95. 'body
  96. LINE (x, y + 8)-(x, y + 30), _RGB32(128, 0, 166)
  97.  
  98. 'arms
  99. LINE (x, y + 20)-(x - 30, y + 40), _RGB32(128, 0, 166)
  100. LINE (x, y + 20)-(x + 30, y + 40), _RGB32(128, 0, 166)
  101. 'legs
  102. LINE (x, y + 30)-(x - 30, y + 58), _RGB32(128, 0, 166)
  103. LINE (x, y + 30)-(x + 30, y + 58), _RGB32(128, 0, 166)
  104. frame3:
  105. 'erase first
  106. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  107. 'head
  108. FOR sz = .25 TO 8 STEP .25
  109.     CIRCLE (x, y), sz, _RGB32(128, 0, 166)
  110. NEXT sz
  111. GOSUB face:
  112. 'hat
  113. LINE (x - 16, y - 8)-(x + 16, y - 8), _RGB32(155, 177, 61)
  114. LINE (x - 10, y - 14)-(x + 10, y - 8), _RGB32(155, 177, 61), BF
  115. 'body
  116. LINE (x, y + 8)-(x, y + 30), _RGB32(128, 0, 166)
  117.  
  118. 'arms
  119. LINE (x, y + 20)-(x - 24, y + 40), _RGB32(128, 0, 166)
  120. LINE (x, y + 20)-(x + 24, y + 40), _RGB32(128, 0, 166)
  121. 'legs
  122. LINE (x, y + 30)-(x - 24, y + 58), _RGB32(128, 0, 166)
  123. LINE (x, y + 30)-(x + 24, y + 58), _RGB32(128, 0, 166)
  124.  
  125. frame4:
  126. 'erase first
  127. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  128. 'head
  129. FOR sz = .25 TO 8 STEP .25
  130.     CIRCLE (x, y), sz, _RGB32(128, 0, 166)
  131. NEXT sz
  132. GOSUB face:
  133. 'hat
  134. LINE (x - 16, y - 8)-(x + 16, y - 8), _RGB32(155, 177, 61)
  135. LINE (x - 10, y - 14)-(x + 10, y - 8), _RGB32(155, 177, 61), BF
  136. 'body
  137. LINE (x, y + 8)-(x, y + 30), _RGB32(128, 0, 166)
  138. 'arms
  139. LINE (x, y + 20)-(x - 18, y + 40), _RGB32(128, 0, 166)
  140. LINE (x, y + 20)-(x + 18, y + 40), _RGB32(128, 0, 166)
  141. 'legs
  142. LINE (x, y + 30)-(x - 18, y + 58), _RGB32(128, 0, 166)
  143. LINE (x, y + 30)-(x + 18, y + 58), _RGB32(128, 0, 166)
  144.  
  145. frame5:
  146. 'erase first
  147. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  148. 'head
  149. FOR sz = .25 TO 8 STEP .25
  150.     CIRCLE (x, y), sz, _RGB32(128, 0, 166)
  151. NEXT sz
  152. GOSUB face:
  153. 'hat
  154. LINE (x - 16, y - 8)-(x + 16, y - 8), _RGB32(155, 177, 61)
  155. LINE (x - 10, y - 14)-(x + 10, y - 8), _RGB32(155, 177, 61), BF
  156. 'body
  157. LINE (x, y + 8)-(x, y + 30), _RGB32(128, 0, 166)
  158. 'arms
  159. LINE (x, y + 20)-(x - 12, y + 50), _RGB32(128, 0, 166)
  160. LINE (x, y + 20)-(x + 12, y + 50), _RGB32(128, 0, 166)
  161. 'legs
  162. LINE (x, y + 30)-(x - 12, y + 58), _RGB32(128, 0, 166)
  163. LINE (x, y + 30)-(x + 12, y + 58), _RGB32(128, 0, 166)
  164. frame6:
  165. 'erase first
  166. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  167. 'head
  168. FOR sz = .25 TO 8 STEP .25
  169.     CIRCLE (x, y), sz, _RGB32(128, 0, 166)
  170. NEXT sz
  171. GOSUB face:
  172. 'hat
  173. LINE (x - 16, y - 8)-(x + 16, y - 8), _RGB32(155, 177, 61)
  174. LINE (x - 10, y - 14)-(x + 10, y - 8), _RGB32(155, 177, 61), BF
  175. 'body
  176. LINE (x, y + 8)-(x, y + 30), _RGB32(128, 0, 166)
  177. 'arms
  178. LINE (x, y + 20)-(x, y + 50), _RGB32(128, 0, 166)
  179. LINE (x, y + 20)-(x, y + 50), _RGB32(128, 0, 166)
  180. 'legs
  181. LINE (x, y + 30)-(x, y + 58), _RGB32(128, 0, 166)
  182. LINE (x, y + 30)-(x, y + 58), _RGB32(128, 0, 166)
  183. 'Face
  184. face:
  185. IF d = 1 THEN
  186.     FOR sz = .25 TO 1 STEP .25
  187.         CIRCLE (x + 4, y - 1), sz, _RGB32(127, 255, 127)
  188.     NEXT sz
  189.     LINE (x + 3, y + 4)-(x + 6, y + 5), _RGB32(127, 255, 127), BF
  190. IF d = 2 THEN
  191.     FOR sz = .25 TO 1 STEP .25
  192.         CIRCLE (x - 4, y - 1), sz, _RGB32(127, 255, 127)
  193.     NEXT sz
  194.     LINE (x - 3, y + 4)-(x - 6, y + 5), _RGB32(127, 255, 127), BF
  195. jumpright:
  196. 'erase first
  197. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  198. seconds = 45
  199. xxx = x
  200. yyy = y
  201. t = 200
  202. one:
  203. t = t + 5
  204. SOUND t, .25
  205. _DELAY .05
  206. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  207. seconds = seconds + .5
  208. s = (60 - seconds) * 6 + 180
  209. x = INT(SIN(s / 180 * 3.141592) * 180) + xxx + 180
  210. y = INT(COS(s / 180 * 3.141592) * 180) + yyy
  211. IF x > 785 THEN x = 15
  212. 'head
  213. FOR sz = .25 TO 8 STEP .25
  214.     CIRCLE (x, y), sz, _RGB32(128, 0, 166)
  215. NEXT sz
  216. 'hat
  217. LINE (x - 16, y - 8)-(x + 16, y - 8), _RGB32(155, 177, 61)
  218. LINE (x - 10, y - 14)-(x + 10, y - 8), _RGB32(155, 177, 61), BF
  219. 'body
  220. LINE (x, y + 8)-(x, y + 30), _RGB32(128, 0, 166)
  221. 'arms
  222. LINE (x, y + 20)-(x - 36, y + 40), _RGB32(128, 0, 166)
  223. LINE (x, y + 20)-(x + 36, y + 40), _RGB32(128, 0, 166)
  224. 'legs
  225. LINE (x, y + 30)-(x - 36, y + 58), _RGB32(128, 0, 166)
  226. LINE (x, y + 30)-(x + 36, y + 58), _RGB32(128, 0, 166)
  227. 'face
  228. FOR sz = .25 TO 1 STEP .25
  229.     CIRCLE (x + 4, y - 1), sz, _RGB32(127, 255, 127)
  230. NEXT sz
  231. LINE (x + 3, y + 4)-(x + 6, y + 5), _RGB32(127, 255, 127), BF
  232. IF seconds = 75 THEN
  233.     y = 211
  234.     t = 0
  235.     LINE (0, 270)-(800, 600), _RGB32(127, 255, 127), BF
  236.     GOSUB frame1:
  237.     RETURN
  238. GOTO one:
  239. jumpleft:
  240. 'erase first
  241. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  242. seconds = 75
  243. xxx = x
  244. yyy = y
  245. t = 200
  246. one2:
  247. t = t + 5
  248. SOUND t, .25
  249. _DELAY .05
  250. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  251. seconds = seconds - .5
  252. s = (60 - seconds) * 6 + 180
  253. x = INT(SIN(s / 180 * 3.141592) * 180) + xxx - 180
  254. y = INT(COS(s / 180 * 3.141592) * 180) + yyy
  255. IF x < 15 THEN x = 785
  256. 'head
  257. FOR sz = .25 TO 8 STEP .25
  258.     CIRCLE (x, y), sz, _RGB32(128, 0, 166)
  259. NEXT sz
  260. 'hat
  261. LINE (x - 16, y - 8)-(x + 16, y - 8), _RGB32(155, 177, 61)
  262. LINE (x - 10, y - 14)-(x + 10, y - 8), _RGB32(155, 177, 61), BF
  263. 'body
  264. LINE (x, y + 8)-(x, y + 30), _RGB32(128, 0, 166)
  265. 'arms
  266. LINE (x, y + 20)-(x - 36, y + 40), _RGB32(128, 0, 166)
  267. LINE (x, y + 20)-(x + 36, y + 40), _RGB32(128, 0, 166)
  268. 'legs
  269. LINE (x, y + 30)-(x - 36, y + 58), _RGB32(128, 0, 166)
  270. LINE (x, y + 30)-(x + 36, y + 58), _RGB32(128, 0, 166)
  271. 'face
  272. FOR sz = .25 TO 1 STEP .25
  273.     CIRCLE (x - 4, y - 1), sz, _RGB32(127, 255, 127)
  274. NEXT sz
  275. LINE (x - 3, y + 4)-(x - 6, y + 5), _RGB32(127, 255, 127), BF
  276. IF seconds = 45 THEN
  277.     y = 211
  278.     t = 0
  279.     LINE (0, 270)-(800, 600), _RGB32(127, 255, 127), BF
  280.     GOSUB frame1:
  281.     RETURN
  282. GOTO one2:
  283.  
« Last Edit: October 24, 2019, 01:11:49 am by SierraKen »

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Animated Walking Man
« Reply #7 on: October 24, 2019, 01:18:15 am »
I decided to change his head color a bit to be a little bit more my own ethnicity. I didn't want to offend anyone by making him different than I am. Although I'm sure he is fine either way.
The eyes and mouth I just changed to black so it stands out as a computer graphic. Being such a small face it's hard to make out such features without heavy contrast. 
I also fixed the jumping sound to match the jump better.
Here is the updated version:

Code: QB64: [Select]
  1. _TITLE "Walking Man by Ken G. v.0.5 | Use Arrow Keys and Space Bar to Jump"
  2. SCREEN _NEWIMAGE(800, 600, 32)
  3. start:
  4. 'grass
  5. LINE (0, 270)-(800, 600), _RGB32(127, 255, 127), BF
  6. 'sky
  7. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  8. x = 100: y = 211
  9. m = 1
  10. d = 1
  11. 'head
  12. FOR sz = .25 TO 8 STEP .25
  13.     CIRCLE (x, y), sz, _RGB32(255, 139, 6)
  14. NEXT sz
  15. 'hat
  16. LINE (x - 16, y - 8)-(x + 16, y - 8), _RGB32(155, 177, 61)
  17. LINE (x - 10, y - 14)-(x + 10, y - 8), _RGB32(155, 177, 61), BF
  18. 'body
  19. LINE (x, y + 8)-(x, y + 30), _RGB32(128, 0, 166)
  20. 'arms
  21. LINE (x, y + 20)-(x - 36, y + 40), _RGB32(128, 0, 166)
  22. LINE (x, y + 20)-(x + 36, y + 40), _RGB32(128, 0, 166)
  23. 'legs
  24. LINE (x, y + 30)-(x - 36, y + 58), _RGB32(128, 0, 166)
  25. LINE (x, y + 30)-(x + 36, y + 58), _RGB32(128, 0, 166)
  26. 'face
  27. FOR sz = .25 TO 1 STEP .25
  28.     CIRCLE (x + 4, y - 1), sz, _RGB32(0, 0, 0)
  29. NEXT sz
  30. LINE (x + 3, y + 4)-(x + 6, y + 5), _RGB32(0, 0, 0), BF
  31.     _LIMIT 500
  32.     a$ = INKEY$
  33.     IF a$ = CHR$(27) THEN END
  34.     'Move Right
  35.     IF a$ = CHR$(0) + CHR$(77) THEN
  36.         m = m + 1: x = x + 5
  37.         IF x > 785 THEN x = 15
  38.         d = 1
  39.         GOSUB check:
  40.     END IF
  41.     'Move Left
  42.     IF a$ = CHR$(0) + CHR$(75) THEN
  43.         m = m - 1: x = x - 5
  44.         IF x < 15 THEN x = 785
  45.         d = 2
  46.         GOSUB check:
  47.     END IF
  48.     IF a$ = " " THEN
  49.         IF d = 1 THEN GOSUB jumpright:
  50.         IF d = 2 THEN GOSUB jumpleft:
  51.     END IF
  52. check:
  53. IF m = 11 THEN m = 1
  54. IF m = 0 THEN m = 10
  55. IF m = 1 THEN GOSUB frame1:
  56. IF m = 2 THEN GOSUB frame2:
  57. IF m = 3 THEN GOSUB frame3:
  58. IF m = 4 THEN GOSUB frame4:
  59. IF m = 5 THEN GOSUB frame5:
  60. IF m = 6 THEN GOSUB frame6:
  61. IF m = 7 THEN GOSUB frame5:
  62. IF m = 8 THEN GOSUB frame4:
  63. IF m = 9 THEN GOSUB frame3:
  64. IF m = 10 THEN GOSUB frame2:
  65. frame1:
  66. 'erase first
  67. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  68. 'head
  69. FOR sz = .25 TO 8 STEP .25
  70.     CIRCLE (x, y), sz, _RGB32(255, 139, 6)
  71. NEXT sz
  72. GOSUB face:
  73. 'hat
  74. LINE (x - 16, y - 8)-(x + 16, y - 8), _RGB32(155, 177, 61)
  75. LINE (x - 10, y - 14)-(x + 10, y - 8), _RGB32(155, 177, 61), BF
  76. 'body
  77. LINE (x, y + 8)-(x, y + 30), _RGB32(128, 0, 166)
  78. 'arms
  79. LINE (x, y + 20)-(x - 36, y + 40), _RGB32(128, 0, 166)
  80. LINE (x, y + 20)-(x + 36, y + 40), _RGB32(128, 0, 166)
  81. 'legs
  82. LINE (x, y + 30)-(x - 36, y + 58), _RGB32(128, 0, 166)
  83. LINE (x, y + 30)-(x + 36, y + 58), _RGB32(128, 0, 166)
  84. frame2:
  85. 'erase first
  86. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  87. 'head
  88. FOR sz = .25 TO 8 STEP .25
  89.     CIRCLE (x, y), sz, _RGB32(255, 139, 6)
  90. NEXT sz
  91. GOSUB face:
  92. 'hat
  93. LINE (x - 16, y - 8)-(x + 16, y - 8), _RGB32(155, 177, 61)
  94. LINE (x - 10, y - 14)-(x + 10, y - 8), _RGB32(155, 177, 61), BF
  95. 'body
  96. LINE (x, y + 8)-(x, y + 30), _RGB32(128, 0, 166)
  97.  
  98. 'arms
  99. LINE (x, y + 20)-(x - 30, y + 40), _RGB32(128, 0, 166)
  100. LINE (x, y + 20)-(x + 30, y + 40), _RGB32(128, 0, 166)
  101. 'legs
  102. LINE (x, y + 30)-(x - 30, y + 58), _RGB32(128, 0, 166)
  103. LINE (x, y + 30)-(x + 30, y + 58), _RGB32(128, 0, 166)
  104. frame3:
  105. 'erase first
  106. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  107. 'head
  108. FOR sz = .25 TO 8 STEP .25
  109.     CIRCLE (x, y), sz, _RGB32(255, 139, 6)
  110. NEXT sz
  111. GOSUB face:
  112. 'hat
  113. LINE (x - 16, y - 8)-(x + 16, y - 8), _RGB32(155, 177, 61)
  114. LINE (x - 10, y - 14)-(x + 10, y - 8), _RGB32(155, 177, 61), BF
  115. 'body
  116. LINE (x, y + 8)-(x, y + 30), _RGB32(128, 0, 166)
  117.  
  118. 'arms
  119. LINE (x, y + 20)-(x - 24, y + 40), _RGB32(128, 0, 166)
  120. LINE (x, y + 20)-(x + 24, y + 40), _RGB32(128, 0, 166)
  121. 'legs
  122. LINE (x, y + 30)-(x - 24, y + 58), _RGB32(128, 0, 166)
  123. LINE (x, y + 30)-(x + 24, y + 58), _RGB32(128, 0, 166)
  124.  
  125. frame4:
  126. 'erase first
  127. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  128. 'head
  129. FOR sz = .25 TO 8 STEP .25
  130.     CIRCLE (x, y), sz, _RGB32(255, 139, 6)
  131. NEXT sz
  132. GOSUB face:
  133. 'hat
  134. LINE (x - 16, y - 8)-(x + 16, y - 8), _RGB32(155, 177, 61)
  135. LINE (x - 10, y - 14)-(x + 10, y - 8), _RGB32(155, 177, 61), BF
  136. 'body
  137. LINE (x, y + 8)-(x, y + 30), _RGB32(128, 0, 166)
  138. 'arms
  139. LINE (x, y + 20)-(x - 18, y + 40), _RGB32(128, 0, 166)
  140. LINE (x, y + 20)-(x + 18, y + 40), _RGB32(128, 0, 166)
  141. 'legs
  142. LINE (x, y + 30)-(x - 18, y + 58), _RGB32(128, 0, 166)
  143. LINE (x, y + 30)-(x + 18, y + 58), _RGB32(128, 0, 166)
  144.  
  145. frame5:
  146. 'erase first
  147. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  148. 'head
  149. FOR sz = .25 TO 8 STEP .25
  150.     CIRCLE (x, y), sz, _RGB32(255, 139, 6)
  151. NEXT sz
  152. GOSUB face:
  153. 'hat
  154. LINE (x - 16, y - 8)-(x + 16, y - 8), _RGB32(155, 177, 61)
  155. LINE (x - 10, y - 14)-(x + 10, y - 8), _RGB32(155, 177, 61), BF
  156. 'body
  157. LINE (x, y + 8)-(x, y + 30), _RGB32(128, 0, 166)
  158. 'arms
  159. LINE (x, y + 20)-(x - 12, y + 50), _RGB32(128, 0, 166)
  160. LINE (x, y + 20)-(x + 12, y + 50), _RGB32(128, 0, 166)
  161. 'legs
  162. LINE (x, y + 30)-(x - 12, y + 58), _RGB32(128, 0, 166)
  163. LINE (x, y + 30)-(x + 12, y + 58), _RGB32(128, 0, 166)
  164. frame6:
  165. 'erase first
  166. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  167. 'head
  168. FOR sz = .25 TO 8 STEP .25
  169.     CIRCLE (x, y), sz, _RGB32(255, 139, 6)
  170. NEXT sz
  171. GOSUB face:
  172. 'hat
  173. LINE (x - 16, y - 8)-(x + 16, y - 8), _RGB32(155, 177, 61)
  174. LINE (x - 10, y - 14)-(x + 10, y - 8), _RGB32(155, 177, 61), BF
  175. 'body
  176. LINE (x, y + 8)-(x, y + 30), _RGB32(128, 0, 166)
  177. 'arms
  178. LINE (x, y + 20)-(x, y + 50), _RGB32(128, 0, 166)
  179. LINE (x, y + 20)-(x, y + 50), _RGB32(128, 0, 166)
  180. 'legs
  181. LINE (x, y + 30)-(x, y + 58), _RGB32(128, 0, 166)
  182. LINE (x, y + 30)-(x, y + 58), _RGB32(128, 0, 166)
  183. 'Face
  184. face:
  185. IF d = 1 THEN
  186.     FOR sz = .25 TO 1 STEP .25
  187.         CIRCLE (x + 4, y - 1), sz, _RGB32(0, 0, 0)
  188.     NEXT sz
  189.     LINE (x + 3, y + 4)-(x + 6, y + 5), _RGB32(0, 0, 0), BF
  190. IF d = 2 THEN
  191.     FOR sz = .25 TO 1 STEP .25
  192.         CIRCLE (x - 4, y - 1), sz, _RGB32(0, 0, 0)
  193.     NEXT sz
  194.     LINE (x - 3, y + 4)-(x - 6, y + 5), _RGB32(0, 0, 0), BF
  195. jumpright:
  196. 'erase first
  197. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  198. seconds = 45
  199. xxx = x
  200. yyy = y
  201. t = 200
  202. one:
  203. t = t + 5
  204. IF seconds > 70 THEN GOTO nex1:
  205. SOUND t, .25
  206. nex1:
  207. _DELAY .05
  208. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  209. seconds = seconds + .5
  210. s = (60 - seconds) * 6 + 180
  211. x = INT(SIN(s / 180 * 3.141592) * 180) + xxx + 180
  212. y = INT(COS(s / 180 * 3.141592) * 180) + yyy
  213. IF x > 785 THEN x = 15
  214. 'head
  215. FOR sz = .25 TO 8 STEP .25
  216.     CIRCLE (x, y), sz, _RGB32(255, 139, 6)
  217. NEXT sz
  218. 'hat
  219. LINE (x - 16, y - 8)-(x + 16, y - 8), _RGB32(155, 177, 61)
  220. LINE (x - 10, y - 14)-(x + 10, y - 8), _RGB32(155, 177, 61), BF
  221. 'body
  222. LINE (x, y + 8)-(x, y + 30), _RGB32(128, 0, 166)
  223. 'arms
  224. LINE (x, y + 20)-(x - 36, y + 40), _RGB32(128, 0, 166)
  225. LINE (x, y + 20)-(x + 36, y + 40), _RGB32(128, 0, 166)
  226. 'legs
  227. LINE (x, y + 30)-(x - 36, y + 58), _RGB32(128, 0, 166)
  228. LINE (x, y + 30)-(x + 36, y + 58), _RGB32(128, 0, 166)
  229. 'face
  230. FOR sz = .25 TO 1 STEP .25
  231.     CIRCLE (x + 4, y - 1), sz, _RGB32(0, 0, 0)
  232. NEXT sz
  233. LINE (x + 3, y + 4)-(x + 6, y + 5), _RGB32(0, 0, 0), BF
  234. IF seconds = 75 THEN
  235.     y = 211
  236.     t = 0
  237.     LINE (0, 270)-(800, 600), _RGB32(127, 255, 127), BF
  238.     GOSUB frame1:
  239.     RETURN
  240. GOTO one:
  241. jumpleft:
  242. 'erase first
  243. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  244. seconds = 75
  245. xxx = x
  246. yyy = y
  247. t = 200
  248. one2:
  249. t = t + 5
  250. IF seconds < 50 THEN GOTO nex2:
  251. SOUND t, .25
  252. nex2:
  253. _DELAY .05
  254. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  255. seconds = seconds - .5
  256. s = (60 - seconds) * 6 + 180
  257. x = INT(SIN(s / 180 * 3.141592) * 180) + xxx - 180
  258. y = INT(COS(s / 180 * 3.141592) * 180) + yyy
  259. IF x < 15 THEN x = 785
  260. 'head
  261. FOR sz = .25 TO 8 STEP .25
  262.     CIRCLE (x, y), sz, _RGB32(255, 139, 6)
  263. NEXT sz
  264. 'hat
  265. LINE (x - 16, y - 8)-(x + 16, y - 8), _RGB32(155, 177, 61)
  266. LINE (x - 10, y - 14)-(x + 10, y - 8), _RGB32(155, 177, 61), BF
  267. 'body
  268. LINE (x, y + 8)-(x, y + 30), _RGB32(128, 0, 166)
  269. 'arms
  270. LINE (x, y + 20)-(x - 36, y + 40), _RGB32(128, 0, 166)
  271. LINE (x, y + 20)-(x + 36, y + 40), _RGB32(128, 0, 166)
  272. 'legs
  273. LINE (x, y + 30)-(x - 36, y + 58), _RGB32(128, 0, 166)
  274. LINE (x, y + 30)-(x + 36, y + 58), _RGB32(128, 0, 166)
  275. 'face
  276. FOR sz = .25 TO 1 STEP .25
  277.     CIRCLE (x - 4, y - 1), sz, _RGB32(0, 0, 0)
  278. NEXT sz
  279. LINE (x - 3, y + 4)-(x - 6, y + 5), _RGB32(0, 0, 0), BF
  280. IF seconds = 45 THEN
  281.     y = 211
  282.     t = 0
  283.     LINE (0, 270)-(800, 600), _RGB32(127, 255, 127), BF
  284.     GOSUB frame1:
  285.     RETURN
  286. GOTO one2:
  287.  

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Animated Walking Man
« Reply #8 on: October 24, 2019, 08:14:25 am »
Nicely done!
Logic is the beginning of wisdom.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Animated Walking Man
« Reply #9 on: October 24, 2019, 04:43:17 pm »
Here is what I got so far. 3 screens of little hills to jump over. If you land on a hill you get stuck and have to jump out of it. It will tell you that as well. I removed the jumping sound and made the jump shorter. I'm not sure what else to add to this since I haven't made gravity, ladders, or the ability to land on top of an object. All of those things can take a considerably amount of time to program so I'm not sure yet if I will add them. The sticking point on that is the way I made the jumping as an arch angle, so I'm not sure if I can stop that mid-flight. I tried to with the small hills but can't do it yet. And I don't want to tear apart the code I have already. So anyways, we'll see what makes of this later on if I think of something. Here is what I have now:

Code: QB64: [Select]
  1. _TITLE "Walking Man by Ken G. v.0.5 | Use Arrow Keys and Space Bar to Jump"
  2. SCREEN _NEWIMAGE(800, 600, 32)
  3. start:
  4. 'grass
  5. LINE (0, 270)-(800, 600), _RGB32(127, 255, 127), BF
  6. 'sky
  7. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  8. l = 1
  9. GOSUB objects:
  10. x = 100: y = 211
  11. m = 1
  12. d = 1
  13. 'head
  14. FOR sz = .25 TO 8 STEP .25
  15.     CIRCLE (x, y), sz, _RGB32(255, 139, 6)
  16. NEXT sz
  17. 'hat
  18. LINE (x - 16, y - 8)-(x + 16, y - 8), _RGB32(155, 177, 61)
  19. LINE (x - 10, y - 14)-(x + 10, y - 8), _RGB32(155, 177, 61), BF
  20. 'body
  21. LINE (x, y + 8)-(x, y + 30), _RGB32(128, 0, 166)
  22. 'arms
  23. LINE (x, y + 20)-(x - 36, y + 40), _RGB32(128, 0, 166)
  24. LINE (x, y + 20)-(x + 36, y + 40), _RGB32(128, 0, 166)
  25. 'legs
  26. LINE (x, y + 30)-(x - 36, y + 58), _RGB32(128, 0, 166)
  27. LINE (x, y + 30)-(x + 36, y + 58), _RGB32(128, 0, 166)
  28. 'face
  29. FOR sz = .25 TO 1 STEP .25
  30.     CIRCLE (x + 4, y - 1), sz, _RGB32(0, 0, 0)
  31. NEXT sz
  32. LINE (x + 3, y + 4)-(x + 6, y + 5), _RGB32(0, 0, 0), BF
  33.     _LIMIT 500
  34.     a$ = INKEY$
  35.     IF a$ = CHR$(27) THEN END
  36.     'Move Right
  37.     IF a$ = CHR$(0) + CHR$(77) THEN
  38.         oldx = x
  39.         m = m + 1: x = x + 5
  40.         IF x > 785 THEN x = 15: l = l + 1
  41.         d = 1
  42.         GOSUB check:
  43.     END IF
  44.     'Move Left
  45.     IF a$ = CHR$(0) + CHR$(75) THEN
  46.         oldx = x
  47.         m = m - 1: x = x - 5
  48.         IF x < 15 THEN x = 785: l = l - 1
  49.         d = 2
  50.         GOSUB check:
  51.     END IF
  52.     IF a$ = " " THEN
  53.         IF d = 1 THEN GOSUB jumpright:
  54.         IF d = 2 THEN GOSUB jumpleft:
  55.     END IF
  56. check:
  57. 'Assign animation frames to walking man.
  58. IF m = 11 THEN m = 1
  59. IF m = 0 THEN m = 10
  60. IF m = 1 THEN GOSUB frame1:
  61. IF m = 2 THEN GOSUB frame2:
  62. IF m = 3 THEN GOSUB frame3:
  63. IF m = 4 THEN GOSUB frame4:
  64. IF m = 5 THEN GOSUB frame5:
  65. IF m = 6 THEN GOSUB frame6:
  66. IF m = 7 THEN GOSUB frame5:
  67. IF m = 8 THEN GOSUB frame4:
  68. IF m = 9 THEN GOSUB frame3:
  69. IF m = 10 THEN GOSUB frame2:
  70. 'Check to see if you hit an object.
  71. IF POINT(x + 36, y + 30) = _RGB32(127, 255, 126) OR POINT(x - 36, y + 30) = _RGB32(127, 255, 126) THEN
  72.     x = oldx
  73. frame1:
  74. 'erase first
  75. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  76. GOSUB objects:
  77. 'head
  78. FOR sz = .25 TO 8 STEP .25
  79.     CIRCLE (x, y), sz, _RGB32(255, 139, 6)
  80. NEXT sz
  81. GOSUB face:
  82. 'hat
  83. LINE (x - 16, y - 8)-(x + 16, y - 8), _RGB32(155, 177, 61)
  84. LINE (x - 10, y - 14)-(x + 10, y - 8), _RGB32(155, 177, 61), BF
  85. 'body
  86. LINE (x, y + 8)-(x, y + 30), _RGB32(128, 0, 166)
  87. 'arms
  88. LINE (x, y + 20)-(x - 36, y + 40), _RGB32(128, 0, 166)
  89. LINE (x, y + 20)-(x + 36, y + 40), _RGB32(128, 0, 166)
  90. 'legs
  91. LINE (x, y + 30)-(x - 36, y + 58), _RGB32(128, 0, 166)
  92. LINE (x, y + 30)-(x + 36, y + 58), _RGB32(128, 0, 166)
  93. frame2:
  94. 'erase first
  95. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  96. GOSUB objects:
  97. 'head
  98. FOR sz = .25 TO 8 STEP .25
  99.     CIRCLE (x, y), sz, _RGB32(255, 139, 6)
  100. NEXT sz
  101. GOSUB face:
  102. 'hat
  103. LINE (x - 16, y - 8)-(x + 16, y - 8), _RGB32(155, 177, 61)
  104. LINE (x - 10, y - 14)-(x + 10, y - 8), _RGB32(155, 177, 61), BF
  105. 'body
  106. LINE (x, y + 8)-(x, y + 30), _RGB32(128, 0, 166)
  107. 'arms
  108. LINE (x, y + 20)-(x - 30, y + 40), _RGB32(128, 0, 166)
  109. LINE (x, y + 20)-(x + 30, y + 40), _RGB32(128, 0, 166)
  110. 'legs
  111. LINE (x, y + 30)-(x - 30, y + 58), _RGB32(128, 0, 166)
  112. LINE (x, y + 30)-(x + 30, y + 58), _RGB32(128, 0, 166)
  113. frame3:
  114. 'erase first
  115. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  116. GOSUB objects:
  117. 'head
  118. FOR sz = .25 TO 8 STEP .25
  119.     CIRCLE (x, y), sz, _RGB32(255, 139, 6)
  120. NEXT sz
  121. GOSUB face:
  122. 'hat
  123. LINE (x - 16, y - 8)-(x + 16, y - 8), _RGB32(155, 177, 61)
  124. LINE (x - 10, y - 14)-(x + 10, y - 8), _RGB32(155, 177, 61), BF
  125. 'body
  126. LINE (x, y + 8)-(x, y + 30), _RGB32(128, 0, 166)
  127. 'arms
  128. LINE (x, y + 20)-(x - 24, y + 40), _RGB32(128, 0, 166)
  129. LINE (x, y + 20)-(x + 24, y + 40), _RGB32(128, 0, 166)
  130. 'legs
  131. LINE (x, y + 30)-(x - 24, y + 58), _RGB32(128, 0, 166)
  132. LINE (x, y + 30)-(x + 24, y + 58), _RGB32(128, 0, 166)
  133. frame4:
  134. 'erase first
  135. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  136. GOSUB objects:
  137. 'head
  138. FOR sz = .25 TO 8 STEP .25
  139.     CIRCLE (x, y), sz, _RGB32(255, 139, 6)
  140. NEXT sz
  141. GOSUB face:
  142. 'hat
  143. LINE (x - 16, y - 8)-(x + 16, y - 8), _RGB32(155, 177, 61)
  144. LINE (x - 10, y - 14)-(x + 10, y - 8), _RGB32(155, 177, 61), BF
  145. 'body
  146. LINE (x, y + 8)-(x, y + 30), _RGB32(128, 0, 166)
  147. 'arms
  148. LINE (x, y + 20)-(x - 18, y + 40), _RGB32(128, 0, 166)
  149. LINE (x, y + 20)-(x + 18, y + 40), _RGB32(128, 0, 166)
  150. 'legs
  151. LINE (x, y + 30)-(x - 18, y + 58), _RGB32(128, 0, 166)
  152. LINE (x, y + 30)-(x + 18, y + 58), _RGB32(128, 0, 166)
  153. frame5:
  154. 'erase first
  155. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  156. GOSUB objects:
  157. 'head
  158. FOR sz = .25 TO 8 STEP .25
  159.     CIRCLE (x, y), sz, _RGB32(255, 139, 6)
  160. NEXT sz
  161. GOSUB face:
  162. 'hat
  163. LINE (x - 16, y - 8)-(x + 16, y - 8), _RGB32(155, 177, 61)
  164. LINE (x - 10, y - 14)-(x + 10, y - 8), _RGB32(155, 177, 61), BF
  165. 'body
  166. LINE (x, y + 8)-(x, y + 30), _RGB32(128, 0, 166)
  167. 'arms
  168. LINE (x, y + 20)-(x - 12, y + 50), _RGB32(128, 0, 166)
  169. LINE (x, y + 20)-(x + 12, y + 50), _RGB32(128, 0, 166)
  170. 'legs
  171. LINE (x, y + 30)-(x - 12, y + 58), _RGB32(128, 0, 166)
  172. LINE (x, y + 30)-(x + 12, y + 58), _RGB32(128, 0, 166)
  173. frame6:
  174. 'erase first
  175. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  176. GOSUB objects:
  177. 'head
  178. FOR sz = .25 TO 8 STEP .25
  179.     CIRCLE (x, y), sz, _RGB32(255, 139, 6)
  180. NEXT sz
  181. GOSUB face:
  182. 'hat
  183. LINE (x - 16, y - 8)-(x + 16, y - 8), _RGB32(155, 177, 61)
  184. LINE (x - 10, y - 14)-(x + 10, y - 8), _RGB32(155, 177, 61), BF
  185. 'body
  186. LINE (x, y + 8)-(x, y + 30), _RGB32(128, 0, 166)
  187. 'arms
  188. LINE (x, y + 20)-(x, y + 50), _RGB32(128, 0, 166)
  189. LINE (x, y + 20)-(x, y + 50), _RGB32(128, 0, 166)
  190. 'legs
  191. LINE (x, y + 30)-(x, y + 58), _RGB32(128, 0, 166)
  192. LINE (x, y + 30)-(x, y + 58), _RGB32(128, 0, 166)
  193. 'Face
  194. face:
  195. IF d = 1 THEN
  196.     FOR sz = .25 TO 1 STEP .25
  197.         CIRCLE (x + 4, y - 1), sz, _RGB32(0, 0, 0)
  198.     NEXT sz
  199.     LINE (x + 3, y + 4)-(x + 6, y + 5), _RGB32(0, 0, 0), BF
  200. IF d = 2 THEN
  201.     FOR sz = .25 TO 1 STEP .25
  202.         CIRCLE (x - 4, y - 1), sz, _RGB32(0, 0, 0)
  203.     NEXT sz
  204.     LINE (x - 3, y + 4)-(x - 6, y + 5), _RGB32(0, 0, 0), BF
  205. jumpright:
  206. 'erase first
  207. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  208. GOSUB objects:
  209. seconds = 45
  210. xxx = x
  211. yyy = y
  212. one:
  213. _DELAY .02
  214. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  215. GOSUB objects:
  216. seconds = seconds + .5
  217. s = (60 - seconds) * 6 + 180
  218. x = INT(SIN(s / 180 * 3.141592) * 90) + xxx + 90
  219. y = INT(COS(s / 180 * 3.141592) * 90) + yyy
  220. 'head
  221. FOR sz = .25 TO 8 STEP .25
  222.     CIRCLE (x, y), sz, _RGB32(255, 139, 6)
  223. NEXT sz
  224. 'hat
  225. LINE (x - 16, y - 8)-(x + 16, y - 8), _RGB32(155, 177, 61)
  226. LINE (x - 10, y - 14)-(x + 10, y - 8), _RGB32(155, 177, 61), BF
  227. 'body
  228. LINE (x, y + 8)-(x, y + 30), _RGB32(128, 0, 166)
  229. 'arms
  230. LINE (x, y + 20)-(x - 36, y + 40), _RGB32(128, 0, 166)
  231. LINE (x, y + 20)-(x + 36, y + 40), _RGB32(128, 0, 166)
  232. 'legs
  233. LINE (x, y + 30)-(x - 36, y + 58), _RGB32(128, 0, 166)
  234. LINE (x, y + 30)-(x + 36, y + 58), _RGB32(128, 0, 166)
  235. 'face
  236. FOR sz = .25 TO 1 STEP .25
  237.     CIRCLE (x + 4, y - 1), sz, _RGB32(0, 0, 0)
  238. NEXT sz
  239. LINE (x + 3, y + 4)-(x + 6, y + 5), _RGB32(0, 0, 0), BF
  240. IF seconds = 75 THEN
  241.     y = 211
  242.     t = 0
  243.     LINE (0, 270)-(800, 600), _RGB32(127, 255, 127), BF
  244.     'Check to see if you hit an object.
  245.     IF POINT(x + 36, y + 30) = _RGB32(127, 255, 126) OR POINT(x - 36, y + 30) = _RGB32(127, 255, 126) THEN
  246.         LOCATE 22, 5: COLOR _RGB32(0, 0, 0), _RGB32(127, 255, 127): PRINT "I'm stuck! Jump to get me out of this."
  247.     END IF
  248.     IF x > 785 THEN x = 15: l = l + 1: GOSUB objects:
  249.     GOSUB frame1:
  250.     RETURN
  251. GOTO one:
  252. jumpleft:
  253. 'erase first
  254. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  255. GOSUB objects:
  256. seconds = 75
  257. xxx = x
  258. yyy = y
  259. one2:
  260. _DELAY .02
  261. LINE (0, 0)-(800, 269), _RGB32(127, 127, 255), BF
  262. GOSUB objects:
  263. seconds = seconds - .5
  264. s = (60 - seconds) * 6 + 180
  265. x = INT(SIN(s / 180 * 3.141592) * 90) + xxx - 90
  266. y = INT(COS(s / 180 * 3.141592) * 90) + yyy
  267. 'head
  268. FOR sz = .25 TO 8 STEP .25
  269.     CIRCLE (x, y), sz, _RGB32(255, 139, 6)
  270. NEXT sz
  271. 'hat
  272. LINE (x - 16, y - 8)-(x + 16, y - 8), _RGB32(155, 177, 61)
  273. LINE (x - 10, y - 14)-(x + 10, y - 8), _RGB32(155, 177, 61), BF
  274. 'body
  275. LINE (x, y + 8)-(x, y + 30), _RGB32(128, 0, 166)
  276. 'arms
  277. LINE (x, y + 20)-(x - 36, y + 40), _RGB32(128, 0, 166)
  278. LINE (x, y + 20)-(x + 36, y + 40), _RGB32(128, 0, 166)
  279. 'legs
  280. LINE (x, y + 30)-(x - 36, y + 58), _RGB32(128, 0, 166)
  281. LINE (x, y + 30)-(x + 36, y + 58), _RGB32(128, 0, 166)
  282. 'face
  283. FOR sz = .25 TO 1 STEP .25
  284.     CIRCLE (x - 4, y - 1), sz, _RGB32(0, 0, 0)
  285. NEXT sz
  286. LINE (x - 3, y + 4)-(x - 6, y + 5), _RGB32(0, 0, 0), BF
  287. IF seconds = 45 THEN
  288.     y = 211
  289.     t = 0
  290.     LINE (0, 270)-(800, 600), _RGB32(127, 255, 127), BF
  291.     'Check to see if you hit an object.
  292.     IF POINT(x + 36, y + 30) = _RGB32(127, 255, 126) OR POINT(x - 36, y + 30) = _RGB32(127, 255, 126) THEN
  293.         LOCATE 22, 5: COLOR _RGB32(0, 0, 0), _RGB32(127, 255, 127): PRINT "I'm stuck! Jump to get me out of this."
  294.     END IF
  295.     IF x < 15 THEN x = 785: l = l - 1: GOSUB objects:
  296.     GOSUB frame1:
  297.     RETURN
  298. GOTO one2:
  299. objects:
  300. IF l = 1 THEN
  301.     CIRCLE (400, 270), 40, _RGB32(127, 255, 126)
  302.     PAINT (400, 265), _RGB32(127, 255, 126)
  303. IF l = 2 THEN
  304.     CIRCLE (200, 270), 30, _RGB32(127, 255, 126)
  305.     PAINT (200, 265), _RGB32(127, 255, 126)
  306.     CIRCLE (400, 270), 30, _RGB32(127, 255, 126)
  307.     PAINT (400, 265), _RGB32(127, 255, 126)
  308. IF l = 3 THEN
  309.     CIRCLE (200, 270), 30, _RGB32(127, 255, 126)
  310.     PAINT (200, 265), _RGB32(127, 255, 126)
  311.     CIRCLE (400, 270), 30, _RGB32(127, 255, 126)
  312.     PAINT (400, 265), _RGB32(127, 255, 126)
  313.     CIRCLE (600, 270), 30, _RGB32(127, 255, 126)
  314.     PAINT (600, 265), _RGB32(127, 255, 126)
  315.