Themabewertung:
  • 0 Bewertung(en) - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
I have problem blitting sprites
#1
Hello,

I have one other problem I need your help with. One I want my game in AGA mode using 64 colors. This is the code I have written so far:

LoadShape 0, "Work:robotstrip.iff",0

Blitz
AutoCookie On
InitCopList 0, 44, 256, $80, 125, $10000,0
DisplayPalette 0,0
DisplayBitMap 0,0
CreateDisplay 0
BitMapOutPut 0
GetaShape 0,0,0,32,32
BlitMode CookieMode

Blit 0,12,12

In the robotstrip.iff there are 14 different sprites put together in a row beside each and saved as robotstrip.iff. I want to blit from this strip into the screen. For example, robotstrip.iff have the following images in one file

ABCDEFGHIJK

Each letter represent a different image or sprite and each size of them are 32 X 32 and each use 64 colors sharing the same palette, stored in one file called robotstrip.iff. What I want is blit image A in coordinate 12, 12. This is where I am using GetaShape 0,0,0, 32, 32 is coming from. The X, Y is 0 and the size of the image is 32 by 32.

When I do blit 0,12,12 nothing shows.

Another problem I have with InitCopList 0, 44, 256, $80, 125, $10000,0. You see that number 125? If I change it's value it is either SUPER white background or purple coloring or blue. But I cannot get it to be black color for some reason. Also I want to initcopList in #AGAColor mode and I am not sure if this is working.

Can you help me on this please?

Oh one other thing....when I attempted to change the code to blit the entire strip in one shot they come out wrong colored, inverted etc, eventually as I played with the code the system crashed.
Zitieren
#2
GetaShape reads from the current bitmap, not from the current Shape. You load your spritesheet "robotstrip.iff" into a shape, not a bitmap.

The reason why you see false color might be because your screen is 256 colors while your shapes are 64 colors? You need to set the parameter "excess" to "on".

Blit 0,12,12,on

You will still probably dont see anything because you blit in CookieMode, and your shape will not have a Cookie. You need to either set "AutoCookie On" or create the Cookies manually with MakeCookie. It seems like you dont have the Debugger on, hmm..? You should switch it always on unless you are building the final release.

What is wrong with the CopperList I dont know. I have never used this.
Zitieren
#3
If you read the previous message apology to it. I used the LoadBitMap method and I get something like this below. First the colors do come off completely wrong in every regard. I will display the code below in how I have written it so you can get the general idea:

Code:
Wbstartup:Nocli
  Bitmap 0, 320+64, 200+64, 8: bitmap 1, 320+64, 200+64, 8: Bitmap 2, 320+64, 200+64, 8
  LoadBitmap 0, "work:robotstrip.iff",0

  .....
  Blitz
  AutoCookie On

  Buffer 0, 2*16384: Buffer 1, 2*16384
  InitCopList 0, 44, 256, $10038, 8, 64, 0
  DisplayPalette 0,0
  CreateDisplay 0

  Repeat
     VWait
     DisplayBitMap 0,0
     GetaShape 0,0, 32, 32
     BlitMode CookieMode
     MakeCookie 0
     db=1-db
     UnBuffer db
     Use BitMap db
     BBlit db, 0,0,0
Until Joyb(0)=1
Free DisplayBitMap 0
Free DisplayPalette 0
Free BitMap 0

Also I noticed it displayed all the strip image in one shot instead of a single sprite from the sprite sheet. Say for example that magnetic object on the left corner of the strip. I want to display this only from the strip and be able to plot it anywhere in the area. Where did I go wrong in this regard?
Zitieren
#4
I have overlooked that you do AutoCookie, sorry. But the main problem was using a Shape Object and not a Bitmap. "GetAShape" means getting a shape out of (a part of) a bitmap. Bitmaps and Shapes are different Blitz Objects and not interchangeable.

Quick "linting" on your code:
- you don't do actually double buffering. DisplayBitmap must use "db" too, otherwise you are showing always Bitmap 0
- you should assign human readable constants (or even variables) to your BlitzBasic objects, otherwise your code will get quickly unreadable. It is already hard to understand "DisplayPalette 0,0".
Example
#BITMAP_DISPLAY0 = 0
#BITMAP_DISPLAY1 = 1
#BITMAP_SPRITESHEET = 2

Compare this two lines:
GetaShape 0,0,0,32,32
vs.
GetaShape #SHAPE_HERO, 0,0, 32,32
Prefixing the constants with the type of object gives you some "type" hint, even though BlitzBasic is untyped here.
- no need to allocate a bitmap prior to loading, since LoadBitmap will free the previous one and allocate a new for the file's dimensions.
- GetaShape takes 5 parameters, you probably mean
GetaShape #SHARE_HERO,0,0,32,32
This might be the reason for the gfx trash
- you should always use the debugger to avoid crashes. Since you use Blit and BBlit, it is very easy to crash when you move out of the bitmap (see ClipBlit).
- Palette: I don't know what goes wrong here, but you should check if the color depth of Display, Bitmap and Palette in robotstrip.iff match. If not, you will get gfx trash and/or crashes. Your Shape may have less bitplanes than the bitmap, but you need to specify the "excess" parameter in Blit/BBlit then.
- in usual BlitzBasic style you dont free the Objects explicitly. You do this only if you are going to do something else then ending the program and want to save or reuse memory.

hope this helps.
Zitieren
#5
Thank you! Those are actually helpful tips you have given me. I just have one more question to ask. Right now I have a strip of images plotted at the same time...how do I get one sprite from the sprite sheet to plot in any coordination of the map instead of plotting the entire strip? Because right now, I do not want to plot the entire strip.

I will of course continue grinding and working hard to resolving this issue and I will spend one week straight figuring out how to get the colors displaying correctly. If that fails I will post again for help but I want to try it out first. However, I am stuck in one problem now and the problem how do I plot one sprite from the sprite sheet instead of plotting the entire sprite sheet.
Zitieren
#6
GetaShape should cut out only the dimensions you tell it. You probably want to move GetaShape outside the loop and prepare you a set of Shapes. It should not blit out the entire Bitmap. If it still does, something is quite wrong. But from the code snippet it seems to be fine.
Zitieren
#7
I am frustrated to no avail. I guess it is very hard to use sprite sheet to plot into the game so I am going to back to my computer and split each sprite as a sprite file one by one then plot them as LoadShape instead of loadbitmap. Because I am unable to get the colors working correctly and on top of that I am unable to plot a single sprite from the sprite sheet.

I am no expert in blitz basic to figure out how to plot a single sprite from the sprite sheet and in 2014 there is no demo or sourcecode that does it. Amazing.

So I am giving up in this approach and doing something else...it is really frustrating and time consuming figuring out how to plot a single sprite in a screen instead of focusing already on the engine of the game and developing it.

But that also means another wasted CD to get the file transferred from PC to Amiga and this I will do as I have no other choice on this matter I guess.

Will getashape is doing nothing. Not only is it blitting the entire sprite sheet it is still jibberish and the colors are wrong and everything on the screen is wrong like the screenshot I send you. I will send you the robotstrip.iff myself and will write the entire code for you here. This way you can run the code from your end and see what I am facing:

Code:
WbStartup:NoCli
   BitMap 0, 320, 200, 8
   BitMap 1, 320, 200, 8
   BitMap 2, 320, 200, 8

   LoadBitMap 0
   LoadPalette 0

   Blitz
   AutoCookie On

   Buffer 0, 2*16384: Buffer 1,2*16384
   InitCopList 0, $10038
   DisplayPalette 0,0
   CreateDisplay 0

   Repeat
     Vwait
     DisplayBitMap 0,0
     GetaShape 0,0,0,32,32
     BlitMode CookieMode
  
     MakeCookie 0

     db=1-db
     UnBuffer db
     Use BitMap db
     BBlit db, 0,0,0, On
Until Joyb(0)=1
Free DisplayBitMap 0
Free DisplayPalette 0
Free BitMap 0

I have attached the image file..check it out in your end...please Sad I am so sorry! It would not allow me to attach the file. It refuses to attach .iff at all and if I rename it, it is smart enough to figure out that it is an iff.

But I managed to compress it as .rar. Please download the file and check it out for me!? Please try the code for me!!
Zitieren
#8
Don't cut the shapes manually. You will regret this step! It has worked for me in the past in many projects, so it should work for you as well. It is not hard at all. There is probably something very simple you oversee.

I will check your code and see what's the problem.

PS: I have never used the DisplayLib. Maybe you will consider using Slices. This is OCS, but you still can benefit form AGA chipset because it allows you to have more/bigger/colorful sprites.
Zitieren
#9
I really do not want to split them manually only because I want to share using the same palette and save on memory and other benefits and control and graphical tricks I could achieve with a single sprite sheet. I prefer it as a single sprite sheet myself Smile

Thank you so much for trying the code out for me. The graphics are AGA by the way. The robotstrip.iff is 64 colors so I want my game to be 100% AGA anyways.

By the way are you saying I am using OCS code to display AGA graphics is that why I am facing the problem?

I thought Bitmap, initCopList, getashape, bblit are not chipset specific and will display correctly regardless of the amount of the colors in a sprite sheet.

ANYWAYS, thank you soooo much for trying the code out for me and helping me out...you will get a full credit before me when the game is completed.
Zitieren
#10
Any update? Smile
Zitieren


Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 4 Gast/Gäste