Hey guys, sorry for not being too active but ive got a question about the CE TOOLCHAIN specifically the graphx library. In this new game im making, im trying to have a custom background be displayed but since its pretty large it makes the game really slow, I tried displaying it as a scaled image and then just decompressing it every turn but thoose were both really slow. From my understanding, I can create a sprite around a main sprite and set that as the background, and then draw over that, however everytime I try to do that, ie. have it set up like:

Code:

// old x and old y are declared up here
zx7_Decompress(gfx_vram, background_compressed);
gfx_GetSprite(background, x, y);
// a bunch of code for the rest of the game function here
gfx_Sprite(background, oldX, oldY);

    gfx_GetSprite(background, x, y);
// This is where I draw my sprites
    oldX = x;
    oldY = y;


I seem to run into a multitude of problems, such as the 84 crashing and also it not working, it blitting out of control ect.
I was wondering if anybody could point me in the direction of how I would be able to do this, as I want to have the cool background but also want it to remain fast.
How is background defined, and how are you generating background_compressed?
Well, background compressed was just the sprite made of convimg and it is compressed, but I'm not sure about background, i think that it was supposed to be defined when I used get sprite, but I'm really not sure, I was also looking into biting but that's a whole nother story cause it looks really smooth(it looks like snake). as long as I can just get the background to display behind all of the other stuff with out it lagging I would be fine.
Without seeing your whole code we have no idea how to help. Would recommend creating a GitHub project or similar Smile
This is a repo for the code, but A. It's outdated cause the work is on a laptop offline(on phone rn)(also it's not super outdated, but it doesn't have any of the graphics stuff I talked about in the first post) and B. It's in a zip https://github.com/linkjt/move
I know this kinda sounds stupid, but like is there a way to just really quickly display the background every cycle, cause i tried something similar with scaled sprites but is there a way to do something just really really fast?
What do you mean by really quickly display the background? And why does it need to be done every cycle?
linkjt9 wrote:
This is a repo for the code, but A. It's outdated cause the work is on a laptop offline(on phone rn)(also it's not super outdated, but it doesn't have any of the graphics stuff I talked about in the first post) and B. It's in a zip https://github.com/linkjt/move
I know this kinda sounds stupid, but like is there a way to just really quickly display the background every cycle, cause i tried something similar with scaled sprites but is there a way to do something just really really fast?


You could extract it and then upload any files you want.
It seems to me like you are looking for partial redrawing only around the two main sprites, right? If so, the CE toolchain provides good documentation for this here. You should be able to follow the documentation template pretty easily.

The general process is:
    1. Draw your background sprite
    2. (initiating) Use gfx_GetSprite to make a sprite of the background behind where the moving sprite
    3. (initiating) Display your sprite to the current location
    4. Every time your sprite moves, first draw your background copy sprite, then update coordinates, use GetSprite to get the new area, and then draw your sprite again

Since you mentioned wanting to blit, you can BlitRectangle just the sprite area. You'll need to include extra padding around it to make sure you "erase" all the pixels where the sprite previously was.

EDIT: Are you making sure to Malloc the partial background sprite?
Hey guys just to put this thread to rest, I would like to start by saying I'm really stupid.
I originally thought that using get sprite got the sprite not currently behind, but around (for example I thought that it would get the entire current screen except the one defined)
I realize I am sorry mistaken, get sprite doesn't do that, and my poor reading skills interpreted background the wrong way. Now I know it just gets the sprite in the area defined, which isn't that complicated, and made my game super quick.
I'll be releasing it soon and can't help but to thank all of the people who helped me realize the error in my ways. Smile
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement