Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

map: add random placement of background tiles #26

Closed
jorgegv opened this issue Mar 29, 2021 · 1 comment
Closed

map: add random placement of background tiles #26

jorgegv opened this issue Mar 29, 2021 · 1 comment

Comments

@jorgegv
Copy link
Owner

jorgegv commented Mar 29, 2021

Currently there can be one BACKGROUND element in a given map screen, defined as a rectangle which is completely with one given tile of type DECORATION. These background tiles are currently statically generated by DATAGEN.

It would be nice to add a PROBABILITY setting, which applies the same filling algorithm to the given rectangle, but which finally puts the BG tile or not depending on its PROBABILITY. This can make for nice screens with randomly placed background elements (e.g. stars on the sky, grass on the floor, trees, etc.)

PROBABILITY can be a 0-255 setting specified in the BACKGROUND directive in GDATA file for the given map screen. When placing a background element, a random number 0-255 can be generated. If it is less or equal than PROBABILITY, then the tile is drawn. If it is greater, it is not. This way, 0-255 maps exactly to the regular probability interval (0,1), with 0 = never show and 1 = always show.

Finally, this code should be added to the engine and removed from DATAGEN. Memory wise, it's much cheaper to include a definition of a rectangle, btile and probability than several dozens of automatically generated static background tiles. For this, a "background" section should be added to the map_screen_s structure, and the relevant code to use it for drawing the map screen.

Also for this to work we need a pseudo random number generator.

@jorgegv
Copy link
Owner Author

jorgegv commented Mar 31, 2021

implemented in branch random_placement_of_background_tiles, merged in 5d09b68, documentation in 1f125c2

@jorgegv jorgegv closed this as completed Mar 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant