diff options
| author | Miquel Sabaté Solà <mssola@mssola.com> | 2026-02-11 22:15:43 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mssola@mssola.com> | 2026-02-11 22:15:43 +0100 |
| commit | 731bc2e0855de04ec7f57d63e09105fa7f619a45 (patch) | |
| tree | d0f594330a45de46d9e56619bb38d0a2380f5c9a /bin/rand.rb | |
| parent | 97ad13291ba0162117df77b038f0c011a14a31c0 (diff) | |
| download | jetpac.nes-731bc2e0855de04ec7f57d63e09105fa7f619a45.tar.gz jetpac.nes-731bc2e0855de04ec7f57d63e09105fa7f619a45.zip | |
bin: improve the style and add more documentation
And also run rubocop on the CI for good measure.
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Diffstat (limited to 'bin/rand.rb')
| -rw-r--r-- | bin/rand.rb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/bin/rand.rb b/bin/rand.rb index f627748..b781b6e 100644 --- a/bin/rand.rb +++ b/bin/rand.rb @@ -1,5 +1,15 @@ # frozen_string_literal: true +## +# Generate a table of 256 bytes of pseudo-random values. These values are +# constrained with the upper and lower margins of the screen where enemies can +# appear, and discard certain positions like platforms that can be troublesome +# on enemy creation. All in all not exactly super pure randomness, but on the +# other hand this game just needs a bit of randomness. +# +# Whenever you update values on background.s, you are supposed to call this +# script again and replace the values on 'valid_y_rand_table' in prng.s. + # See values on background.s UPPER_MARGIN_Y_COORD = 0x1A GROUND_Y_COORD = 0xC8 - 32 # NOTE: As in background.s - twice the size of the enemy. @@ -10,7 +20,7 @@ available = (UPPER_MARGIN_Y_COORD..GROUND_Y_COORD).to_a - (0x58..0x69).to_a - (0 # With this produce the array containing a randomized sample from the # 'available' values. -random_byte_array = Array.new(256) { '$%02X' % available.sample } +random_byte_array = Array.new(256) { format('$%02X', available.sample) } # And now print it in the assembler format. random_byte_array.each_slice(16) do |row| |
