Hey, long time no see! Today, I want to introduce to you how to display object on screen with random position that isn't exceeding the screen.
Logic here is:
1. Use num_randint for pos_x and pos_y with min_x = 0 (0x00) and max_x = 191 - (dec)m (0xBF - (hex)m), store result to var_x; min_y = 1 (0x01) and max_y = 63 - (dec)n (0x3F - (hex)n), store result to var_y. Note than "m" and "n" are size_x and size_y of object respectively.
2. Use calc_func to calculate this formula: "256 × y + x" and store result to 0xD3A0. Of course result always be decimal.
3. Use a pair of gadgets/functions that can convert decimal result to hexadecimal, and store it at anywhere (e.g: 0xD730).
4. Draw object and render it using render_bitmap and render.ddd4 (read my older post about render_bitmap usage)
5. Loop with delay (to change position continuously after a few seconds)
Logic here is:
1. Use num_randint for pos_x and pos_y with min_x = 0 (0x00) and max_x = 191 - (dec)m (0xBF - (hex)m), store result to var_x; min_y = 1 (0x01) and max_y = 63 - (dec)n (0x3F - (hex)n), store result to var_y. Note than "m" and "n" are size_x and size_y of object respectively.
2. Use calc_func to calculate this formula: "256 × y + x" and store result to 0xD3A0. Of course result always be decimal.
3. Use a pair of gadgets/functions that can convert decimal result to hexadecimal, and store it at anywhere (e.g: 0xD730).
4. Draw object and render it using render_bitmap and render.ddd4 (read my older post about render_bitmap usage)
5. Loop with delay (to change position continuously after a few seconds)


