baylej / tmx

C tmx map loader
http://libtmx.rtfd.io/
BSD 2-Clause "Simplified" License
241 stars 54 forks source link

Documentation: Fix raylib code samples (draw_tile) #62

Closed nawarian closed 2 years ago

nawarian commented 3 years ago

This PR refers to the page Creating a map renderer from scratch. The draw_tile() implementation there is faulty and leads to a black screen.

Here are my proposed fixes:

  1. Fixed DrawTextureRec() call by derefing image as the function requires a Texture2D variable instead of a Texture2D* pointer
  2. Fixed the Alpha issue: raylib's Color struct works with 4 uint fields (r, g, b, a). Passing opacity directly will result in a rgba(1,1,1,1) color (black). Adopted WHITE as default and applied opacity as its alpha

The above was tested with most recent Raylib's version: 3.7.0

RobLoach commented 3 years ago

Hey @nawarian, I abstracted the raylib sample into its own wrapper library to help integration: https://github.com/robloach/raylib-tmx

The other change that was helpful is over at https://github.com/baylej/tmx/pull/58

baylej commented 2 years ago

Thank you for this fix, the raylib example needs to be fixed as well before I merge this PR. I will do it if you don't have the time, or have lost interest.

nawarian commented 2 years ago

Hello @baylej ; Please go ahead, it would take me another few weeks to find time for it.

Thanks!