Author Topic: Turkey Day is around the corner  (Read 4676 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Turkey Day is around the corner
« on: November 24, 2021, 09:41:19 pm »
Code: QB64: [Select]
  1. _Title "Turkey Run" ' b+ mod 2021-11-24
  2. 'test if can get end of landscape level to start for big looping background
  3. '2019-03-27 a more gentle adjustment back to Mountain starting height for
  4. 'more seamless connect of back end to front
  5. '2019-03-27 start this file with parallax drawing test
  6.  
  7. Screen _NewImage(800, 600, 32)
  8. _ScreenMove 100, 20
  9.  
  10. Type parallaxType
  11.     handle As Long
  12.     rate As Single 'number of pixels per frame added to le (leading edge)
  13.     le As Single
  14. nLevels = 6
  15. Dim Shared para(1 To nLevels) As parallaxType
  16.  
  17. Dim Shared scape&
  18. LoadLandscape
  19. scapeWidth = _Width(para(1).handle)
  20. scapeHeight = _Height(para(1).handle)
  21. tr = _LoadImage("turkey run.jpg")
  22. _ClearColor Point(10, 10), tr
  23. dir = 1.25
  24. While _KeyDown(27) = 0 't < 6000
  25.     Cls
  26.     For i = 1 To nLevels
  27.         If para(i).le + 800 > scapeWidth Then
  28.             te = scapeWidth - para(i).le
  29.             _PutImage (0, 0)-(te, scapeHeight), para(i).handle, 0, (scapeWidth - te, 0)-(scapeWidth, scapeHeight)
  30.             _PutImage (te, 0)-(800, scapeHeight), para(i).handle, 0, (0, 0)-(800 - te, scapeHeight)
  31.  
  32.         Else
  33.             _PutImage (0, 0)-(800, scapeHeight), para(i).handle, 0, (para(i).le, 0)-(para(i).le + 800, scapeHeight)
  34.         End If
  35.  
  36.         para(i).le = para(i).le - para(i).rate
  37.         If para(i).le < 0 Then para(i).le = scapeWidth
  38.     Next
  39.     _PutImage (350, 500 + down)-Step(111, 93), tr, 0, (0, 0)-(_Width(tr), _Height(tr) - 30)
  40.     t = t + 1
  41.     down = down + dir
  42.     If down > 37 Then down = 37: dir = -dir
  43.     If down < 13 Then down = 13: dir = -dir
  44.     _Display
  45.     _Limit 120
  46.  
  47. Sub LoadLandscape
  48.     cur& = _Dest
  49.     xmax = 800 * 3.25: ymax = 600
  50.     hdl& = 1
  51.     para(hdl&).handle = _NewImage(xmax, ymax, 32)
  52.     _Dest para(hdl&).handle
  53.  
  54.     For i = 0 To ymax
  55.         midInk 0, 0, 128, 128, 128, 200, i / ymax
  56.         Line (0, i)-(xmax, i)
  57.     Next
  58.     'the land
  59.     startH = ymax - 250
  60.     rr = 70: gg = 70: bb = 90
  61.     For mountain = 1 To nLevels
  62.         If mountain > 1 Then
  63.             para(mountain).handle = _NewImage(xmax, ymax, 32)
  64.             _Dest para(mountain).handle
  65.         End If
  66.         Xright = 0
  67.         y = startH
  68.         Color _RGB(rr, gg, bb)
  69.         While Xright < xmax - 50
  70.             ' upDown = local up / down over range, change along Y
  71.             ' range = how far up / down, along X
  72.             upDown = (Rnd * .8 - .4) * (mountain * .5)
  73.             range = Xright + rand%(15, 25) * 2.5 / mountain
  74.             If range > xmax - 50 Then range = xmax - 50
  75.             lastx = Xright - 1
  76.             For x = Xright To range 'need less flat tops
  77.                 test = y + upDown
  78.                 test2 = y - upDown
  79.                 If Abs(test - startH) < .13 * startH Then y = test Else y = test2: upDown = -upDown
  80.                 Line (lastx, y)-(x, ymax), , BF 'just lines weren't filling right
  81.                 lastx = x
  82.             Next
  83.             Xright = range
  84.         Wend
  85.         x = lastx + 1
  86.         dy = (startH - y) / 50 'more gentle adjustment back to start of screen
  87.         While x <= xmax
  88.             y = y + dy
  89.             Line (lastx, y)-(x, ymax), , BF 'just lines weren't filling right
  90.             lastx = x
  91.             x = x + 1
  92.         Wend
  93.         rr = rand%(rr + 50, rr + 30): gg = rand%(gg + 50, gg + 30): bb = rand%(bb + 50, bb + 30)
  94.         If rr < 0 Then rr = 0
  95.         If gg < 0 Then gg = 0
  96.         If bb < 0 Then bb = 0
  97.         startH = startH + mountain * rand%(2, 10)
  98.         para(mountain).le = xmax - 800
  99.         para(mountain).rate = mountain * .5
  100.     Next
  101.     _Dest cur&
  102.  
  103. Function rand% (lo%, hi%)
  104.     rand% = Int(Rnd * (hi% - lo% + 1)) + lo%
  105.  
  106. Sub midInk (r1%, g1%, b1%, r2%, g2%, b2%, fr##)
  107.     Color _RGB(r1% + (r2% - r1%) * fr##, g1% + (g2% - g1%) * fr##, b1% + (b2% - b1%) * fr##)
  108.  
  109.  

You will need the image in the zip:
* Turkey Day.zip (Filesize: 772.08 KB, Downloads: 185)

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Turkey Day is around the corner
« Reply #1 on: November 25, 2021, 04:01:03 am »
Not for this little black duck.... Do not like turkey and Thanksgiving is not an Australian holiday...
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Turkey Day is around the corner
« Reply #2 on: November 25, 2021, 08:23:47 am »
Not for this little black duck.... Do not like turkey and Thanksgiving is not an Australian holiday...

Too bad!

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Turkey Day is around the corner
« Reply #3 on: November 25, 2021, 12:41:02 pm »
Hey is there a challenge to do a game with Turkey day theme?
What is the end of time of challange?
Are there some aspects fixed or is it all free except theme?
Programming isn't difficult, only it's  consuming time and coffee

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Turkey Day is around the corner
« Reply #4 on: November 25, 2021, 01:20:55 pm »
Hey is there a challenge to do a game with Turkey day theme?
What is the end of time of challange?
Are there some aspects fixed or is it all free except theme?

No Turkey-day challenge, but it's time for the Xmas theme challenge again!
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Turkey Day is around the corner
« Reply #5 on: November 25, 2021, 01:24:18 pm »
Hi @TempodiBasic,

Thanksgiving is today in USA, traditionally turkey is served for dinner. If Ben Franklin had his way, turkey would have been the national bird! ;-))

There are jokes that come up around this time about turkeys escaping to Australia or Antarctica. :)

FellippeHeitor

  • Guest
Re: Turkey Day is around the corner
« Reply #6 on: November 25, 2021, 03:04:42 pm »
No Turkey-day challenge, but it's time for the Xmas theme challenge again!

Hear hear!
🎄

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Turkey Day is around the corner
« Reply #7 on: November 25, 2021, 08:18:37 pm »
LOL too late to put on a Turkey! Well the next year it will be possible!

Christmas challange?
Oh oh oh I have something in the box. I can modernize it to this year!
Programming isn't difficult, only it's  consuming time and coffee