MMBasic: Knightmare Game


Author Message
LeoNicolas

Guru

Joined: 07/10/2020
Location: Canada
Posts: 479
Posted: 05:06pm 11 Dec 2023      

  matherp said  If you load the complete image as a sprite does that show as expected? How are you breaking up the image into individual sprites?


I'm doing something wrong for sure

I'm also having artifacts sometimes when I'm hiding and showing sprites. The following image shows an example of when I'm hiding the sprite over the block that shows the block content (the gray block is the background and is overlayed by a sprite showing the question mark or the block content). This problem happens when the shield is over the block, and I'm hiding the block sprite. I will probably need to create a simpler code reproducing the artifacts problem to help you.



These are the steps I'm using for creating sprites:

1) I'm loading the PNGs into different pages when the game starts using:


page write MAP_TILES_BUFFER: load png "MAP_TILESET_IMG"
page write OBJ_TILES_BUFFER: load png "OBJ_TILESET_IMG"
...


Where:


const SCREEN_BUFFER=2                     ' Screen buffer number
const MAP_TILES_BUFFER=3                  ' Map tileset buffer number
const OBJ_TILES_BUFFER=4                  ' Objects tileset buffer number
const BOSSES_TILES_BUFFER=5               ' Bosses tileset buffer number
const GENERAL_USE_BUFFER=6                ' General use buffer number


2) In the main loop, I'm drawing the map tiles in the SCREEN_BUFFER and also scrolling the background

3) I'm spawning new sprites when necessary in the SCREEN_BUFFER using:


sprite read sprite_id%, OBJ_TILE%(obj_id%,0)+offset_x%, OBJ_TILE%(obj_id%,1)+offset_y%, OBJ_TILE%(obj_id%,2), OBJ_TILE%(obj_id%,3), OBJ_TILES_BUFFER
sprite show safe sprite_id%, g_obj(i%,1),g_obj(i%,2), layer%


Where OBJ_TILE contains the coordinates of the image in the PNG to be used by the sprite.

4) I'm moving the sprites using sprite next and sprite move

5) I'm copying the SCREEN_BUFFER page to the page 0 using:


page write 0
blit 0,TILE_SIZEx2, SCREEN_OFFSET,0, SCREEN_WIDTH,SCREEN_HEIGHT, SCREEN_BUFFER
page write SCREEN_BUFFER

Edited 2023-12-12 03:11 by LeoNicolas