Hi all.
I'm trying to make a simple game.
I created an image that contains all the sequences of sprites that I would like to display in the game.
What I need is to modify a color knowing the codes of the palettes used in my image. I would like to do this after loading the image (loadsprite), i.e. before issuing the command (displaysprite) which must display the image with the already modified colors. The sprites are soccer players and must have the colors of the shirts chosen in the game menu, therefore I would like to avoid creating many images to upload for each shirt color.
I'm trying to find a way to modify the image directly in memory (after the loadsprite command) and NOT by displaying the sprites on the screen and then modifying the pixels.
Please, does anyone have any examples or suggestions to show me?
Thank you. Greetings.
Sprite - direct pixel manipulation
Re: Sprite - direct pixel manipulation
That doesn't work anymore, palette support has been removed many PB versions ago.
You could copy the sprite and then use StartDrawing() and SpriteOutput() to replace the colors inside the copies.
You could copy the sprite and then use StartDrawing() and SpriteOutput() to replace the colors inside the copies.
Re: Sprite - direct pixel manipulation
You can do shirts seperate sprites then use
DisplayTransparentSprite(sprite,x,y,255,RGB(?,?,?))
/Micke
DisplayTransparentSprite(sprite,x,y,255,RGB(?,?,?))
/Micke
Re: Sprite - direct pixel manipulation
Thank you,
I used your suggestion
I had some problems with the pointers but finally I was able to change the shirts of the players.
If it may be useful, I attach an extract of my working procedure:
Code: Select all
StartDrawing(SpriteOutput(myimage_temp_P1))
*Buffer = DrawingBuffer() ; Get the start address of the screen buffer
Pitch = DrawingBufferPitch() ; Get the length (in byte) took by one horizontal line
For y = 0 To height - 1
*Pixel = *Buffer + Pitch * y
For x = 0 To width - 1
If *Pixel\_Red = 255 And *Pixel\_Green = 255 And *pixel\_Blue = 255
*pixel\_Red = col_player(colore_player_a,3)
*pixel\_Green = col_player(colore_player_a,2)
*pixel\_Blue = col_player(colore_player_a,1)
*pixel\_Alfa = 255
EndIf
*pixel +4
Next
Next
StopDrawing()
Re: Sprite - direct pixel manipulation
Thank you,Caronte3D wrote: ↑Wed May 03, 2023 11:25 am Take a look to:
viewtopic.php?p=590989&hilit=retro#p590989
I'll have to test it.