English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 23 January 2019, 22:03   #1
madaxe
Registered User

madaxe's Avatar
 
Join Date: Jan 2019
Location: Coimbra / Portugal
Posts: 25
Should I use Shapes or Sprites?

Hi everybody;

I made a little shoot'n'up game for PC Windows and for ZX Spectrum and I'm trying to convert it to Amiga using Blitz Basic 2.
I'm making some experiences with the Display Library and my question is if is better to use only Shapes or use GetaSprite and then to use Sprites?
What method is faster? In what method can I use more colors? It is possible to have all the graphics in 256 colors like the PC version or I need to reduce the number of colors?

By the way you can check my little game here:
http://sardonic.planetaclix.pt/

Best regards,
José Mário aka MadAxe
madaxe is offline  
Old 24 January 2019, 00:01   #2
idrougge
Registered User
 
Join Date: Sep 2007
Location: Stockholm
Posts: 3,785
256 colours is mostly beyond what an Amiga can handle in an action game, especially if your only tool is Blitz.

Sprites are limited in their amount of colours as well as their size. Bobs (or Shapes in Blitz terminology) are slower since they have to be masked, drawn and then deleted from the screen, but have the same amount of colours as the screenmode in question.

Many Amiga shmups use a mix of both, for example making the enemies bobs and the player a sprite, or using sprites for shots.
idrougge is offline  
Old 24 January 2019, 00:08   #3
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 3,776
Nice, and welcome along!

Sprites are faster, in fact they're sort of free in a way because they don't require any blitter or CPU time to draw them. But they're also quite limited: you can only have 8 on screen at the one time (or 16 if you keep the first 8 to the top of the screen and the second 8 to the bottom. They're also limited to 16 pixels wide and 3 colours, though you can join them in pairs to get 15 colours but only 4 on screen. Their palette is also allocated from a fixed set of pens.

AGA allows 64 pixel wide sprites and the ability to assign different sets of pens to the sprites. AGA will also allow you to use 256 colours on the screen at once instead of OCS/ECS's 32 (which include the sprite colours), though going by the screenshots, it looks like most of the colours are used up on the gradient in the side panels. This could easily be done on the Amiga using a copper setup and just a single colour, perhaps giving a similar result even on OCS/ECS Amigas.

In reality though, the Amiga's blitter is probably fast enough to deal with the number of objects you have on screen, so that might be the way to go, blitting shapes as you need them.

Edit: Yes, the hybrid approach is useful too, using the sprites for some items (bullets, powerups and so on).
Daedalus is offline  
Old 24 January 2019, 10:46   #4
Steril707
OCS rocks!

 
Join Date: Sep 2016
Location: Amiga Island
Posts: 701
Those pc screenshots really look like you don't need 256 colours for a conversion.
more around 16.

You can achieve that gradient on the sidebar with changing one colour in a copperlist.
Steril707 is offline  
Old 25 January 2019, 16:28   #5
madaxe
Registered User

madaxe's Avatar
 
Join Date: Jan 2019
Location: Coimbra / Portugal
Posts: 25
Hi fellows;

Thank you very much for your great help and precious information about Blitz Basic, I found it very usefull
By the way, these are my main graphics. Which of them do you think should be bobs and which of them should be sprites?


Our ship: 16x16x3 colors
Our fire: 1x8x1

Enemy 1: 24x16x3 , Boss 1: 48x32x3
Enemy 2: 24x16x3 , Boss 2: 48x32x3
Enemy 3: 15x24x3 , Boss 3: 30x48x3
Enemy 4: 24x24x3 , Boss 4: 48x48x3
Enemy fire: 1x8x1 , Boss 5: 80x32x3

Powerups: 12x12x2

Thanks in advance,
José Mário

Last edited by madaxe; 25 January 2019 at 19:40.
madaxe is offline  
Old 25 January 2019, 16:47   #6
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 3,776
If you're aiming for OCS/ECS compatibility, sprites won't do for most of the enemies, but they'll work well for your own ship, and powerups and bullets so long as you don't try to have more than 8 displayed at a time. I would say all enemies should be bobs, and then you can see how the performance is.
Daedalus is offline  
Old 10 February 2019, 21:11   #7
madaxe
Registered User

madaxe's Avatar
 
Join Date: Jan 2019
Location: Coimbra / Portugal
Posts: 25
Thanks again

I have a question about Dual PlayField and Palette Assignment.

Background Bitmap: bit01.lbm - 8 colors, palette range: 0-7



Foreground Bitmap: bit02.lbm - 8 colors, palette range: 8-15



But the final result is something like this:



My code is:
Code:
BitMap 0,320,256,4
BitMap 1,320,256,4


LoadBitMap 0,"bit01.lbm"
LoadBitMap 1,"bit02.lbm"

InitPalette 0,32

LoadPalette 0,"bit02.lbm",8
LoadPalette 0,"bit01.lbm",0

InitCopList 0,44,256,$35,8,32,0

CreateDisplay 0
DisplayPalette 0,0

DisplayBitmap 0,0,xb,yb,1,0,xf,yf

What am I doing wrong?
Can I only use 16 color for both BitMaps?


Thanks,
José Mário

Last edited by madaxe; 26 February 2019 at 19:47. Reason: Change de images' link
madaxe is offline  
Old 11 February 2019, 11:32   #8
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 3,776
It has to be the same 16 colour palette to cover both sets of 8 colours. Are your bitmaps 3 or 4 bitplanes deep? when you load the palette from a bitmap, it will load all colours in the palette, not just the ones used. Try setting the bitmaps up as 3 bitplanes deep instead and see if that helps.

Also, I'm not sure if you are actually using the correct colours - the 2nd playfield uses pens 8-15, but they're mapped from pens 0-7 in the bitmap. So both bitmaps should use colours 0-7. I *think* you have that right, I'm just not sure...
Daedalus is offline  
Old 12 February 2019, 23:22   #9
E-Penguin
Banana

 
Join Date: Jul 2016
Location: Darmstadt
Posts: 759
Palettes are a pain in the arse.

Quote:
BitMap 0,320,256,4
BitMap 1,320,256,4
If you're doing dual play field, on ocs/ecs, you're limited to 8 colours per plane. You seem to be using 4 plane bitmaps though - I suspect this is the issue.
E-Penguin is offline  
Old 13 February 2019, 16:10   #10
madaxe
Registered User

madaxe's Avatar
 
Join Date: Jan 2019
Location: Coimbra / Portugal
Posts: 25
Well, I think I am doing something wrong.

I tried to change some things like to reduce the number of BitPlanes from 4 to 3, load a Palette from a previous one saved from Deluxe Paint and even set a Palette manualy with a For and Next cycle but the result is allways the same: the Foreground BitMap displays all the 8 colors pefectly but the Background BitMap only displays 4 colors.

Note: I am using a emulator and not the real machine. I tried both WinUAE and WinFellow but the result is the same.
madaxe is offline  
Old 13 February 2019, 17:41   #11
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 3,776
Ah, I was barking up the wrong tree there, thinking primarily about the palette. You gave me a hint when you say that there are only ever 4 colours on the rear display...

Your problem is here:
Code:
InitCopList 0,44,256,$35,8,32,0
The $35 is the type, or flags field. $20 for dual playfield and $10 for smooth scrolling makes $30, and then you add on the number of bitplanes you want to use. These are split between the two displays, which is why you're limited to 8 colours in each layer - 3 bitplanes each. Ordinarily you're limited to 5 bitplanes for OCS and ECS without using EHB mode, but for dual playfield displays you can use all 6. With only 5 bitplanes assigned, your front display gets 3 and your rear only 2, meaning only 4 colours, and a plane of information going unused.

Try $36 and see if it fixes the problem.
Daedalus is offline  
Old 13 February 2019, 21:28   #12
madaxe
Registered User

madaxe's Avatar
 
Join Date: Jan 2019
Location: Coimbra / Portugal
Posts: 25
Oh Yeah, It works perfectly Thank you very much Daedalus
Replacing $35 by $36 was the solution for the problem. All the colors are now displayed correctly.

In fact I just find out that information on the Amiga Hardware Reference Manual:
http://amigadev.elowar.com/read/ADCD.../node0079.html


By the way, to code a simple vertical star field scroll I need always to use a Dual Playfield or is there a simple way to do this using a Simple PlayField?

Thanks in advance,
José Mário

Thanks in advance,
José Mário
madaxe is offline  
Old 13 February 2019, 22:59   #13
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 3,776
Quote:
Originally Posted by madaxe View Post
Oh Yeah, It works perfectly Thank you very much Daedalus
Replacing $35 by $36 was the solution for the problem. All the colors are now displayed correctly.

In fact I just find out that information on the Amiga Hardware Reference Manual:
http://amigadev.elowar.com/read/ADCD.../node0079.html
Good stuff It's probably still a good idea to keep everything using the correct depth anyway (so both your bitmaps being 3 deep instead of 4), as it will save memory and might prevent strange behaviour later on.

Quote:
By the way, to code a simple vertical star field scroll I need always to use a Dual Playfield or is there a simple way to do this using a Simple PlayField?
It's probably simplest to have a scrolling background using dual playfields, since that's effectively for free, but it's not the only way. You can also use a single playfield and buffered blits to draw your shapes directly on the background and then automatically erase them and repair the background, but that's a bit slower than the simpler blit and erase you can do with dual playfield. Still, it's also more flexible, allowing all 32 colours to be used everywhere, and if you only have a few shapes to blit, it should still be plenty fast enough.
Daedalus is offline  
Old 15 February 2019, 17:13   #14
madaxe
Registered User

madaxe's Avatar
 
Join Date: Jan 2019
Location: Coimbra / Portugal
Posts: 25
Thanks

I have one last question... for now

If I use a Dual PlayField for my main game is it possible to have a main menu bitmap using 16 color with only one IniCopList or is necessary to create two IniCopList? How to switch beetween them?
madaxe is offline  
Old 15 February 2019, 23:38   #15
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 3,776
You'll need to create a new display for that. You can do it easily enough though, just create the CopLists for the different setups you want, and use a CreateDisplay command to go from one to the other.
Daedalus is offline  
Old 16 February 2019, 11:45   #16
madaxe
Registered User

madaxe's Avatar
 
Join Date: Jan 2019
Location: Coimbra / Portugal
Posts: 25
So, my code will be something like this:

Code:
InitCopList 0,$4 ; Menu
InitCopList 1,$36 ; Game

CreateDisplay 0
DisplayPalette 0,#MENUPAL
DisplayBitmap 0,#MENUBIT

While JoyB(1)<>1
   ; Press Fire to Start
Wend

CreateDisplay 1
DisplayPalette 1,#GAMEPAL,
DisplayBitmap 1,#FORE,0,xb,yb,#BACK,xf,yf
So, is it possible to call the same CreateDisplay command several times in the code?
madaxe is offline  
Old 20 February 2019, 22:55   #17
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 3,776
Yep, that shouldn't be a problem. When the game is won or lost, use CreateDisplay 0 etc. to switch to the menu screen.
Daedalus is offline  
Old 22 February 2019, 20:45   #18
madaxe
Registered User

madaxe's Avatar
 
Join Date: Jan 2019
Location: Coimbra / Portugal
Posts: 25
Thanks, I'll do my best to make a simple but enjoyable game... I hope

Do you know why when we use Queue Blit the space erased is bigger than the shape itself? If my shape is 16x16 the space erased in the background is about 32x16. Is there any way to avoid this?



Last edited by madaxe; 26 February 2019 at 19:48. Reason: Change the images' link
madaxe is offline  
Old 22 February 2019, 22:58   #19
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 3,776
I think it will always be a multiple of 16 pixels wide. Are you sure your shape isn't 17 pixels wide by any chance? Even if it's empty / transparent pixels...

If you're trying to keep the background undamaged, try using buffered blits instead. They're a bit slower, but they leave the background back as it was before the blit, instead of simply erasing it.
Daedalus is offline  
Old 23 February 2019, 00:12   #20
madaxe
Registered User

madaxe's Avatar
 
Join Date: Jan 2019
Location: Coimbra / Portugal
Posts: 25
Yeap, it makes sense, but my shape is 16 pixels wide.

I'm using buffer blits for the most of the shapes but I'm also using queue blits for a few shapes that don't have a background bellow them. The problem is when they move they damage with empty space some stuff like the score panel and sometimes they even mess with other shapes. I'll redesign them to avoid this or use buffer blits. Thanks.

Last edited by madaxe; 23 February 2019 at 23:56.
madaxe is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Get Shapes Retro1234 Coders. Blitz Basic 53 17 March 2017 12:41
Shapes creator for PC ? TurboCrash Coders. Blitz Basic 1 06 January 2016 20:45
Shapes (PD) Devlin HOL data problems 0 17 July 2015 20:03
Blitz Shapes Limit Havie Coders. Blitz Basic 4 03 April 2015 11:42
How to draw a (rubbish) zipstick with 10 shapes killergorilla Nostalgia & memories 54 30 March 2007 05:25

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:29.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Page generated in 0.08767 seconds with 13 queries