Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > clipping sprites
2010-06-01 11:06
Iapetus/Algarbi/Wood

Registered: Dec 2004
Posts: 71
clipping sprites

Hi

I am coding a game with a screen of 24 columns horizontaly, and one of the sprites might leave that window and I need to to clip it, I thought of using a black sprite to cover the other one, but unfortunately can't waste a sprite for that. Also I thought of creating new frames for the sprite to simulate that but that would inflate the number of frames a lot. Is there another way?

Thanx
 
... 5 posts hidden. Click here to view all posts....
 
2010-06-01 13:55
Iapetus/Algarbi/Wood

Registered: Dec 2004
Posts: 71
Quote: How many colors do you need in your char gfx?

There's another way if you use multicolor mode. If you set your sprites behind char gfx in multicolor mode, the sprite ONLY goes behind %11 and %10 colors, but stays in front of %00 and %01 colors.

So if you make your border from %11 or %10 colors and the graphics using only %00 or %01 colors, then you're set. It *does* greatly limit the colors in your gfx area though (basically it leaves you with singlecolor gfx in 2x1 resolution..). Btw, that also works with bitmap graphics.

You can also make your sprite the same color as the borders, then you will not see it ;) (this limits your sprite color, or forces you to pick another border color..)


Thx WVL

That is too much restrictive, I will use the AND method to clip sprite. :)
2010-06-01 14:01
WVL

Registered: Mar 2002
Posts: 902
Darnit.. I typed a whole lotta extra text and then was refused to edit my previous post ;)

What I wanted to say is that in the interference part in Pearls for Pigs I used the 2nd option : make the sprites-to-be-clipped the same color as the border.. Which is the reason for the lousy purple-colored border :D

I could have made the border any color, but I couldnt since I'm storing sprite images in those border areas. (so there were all color combos in the bitmap data).

May I ask if you use multicolor or singlecolor chars? and how many colors?

Ooh! and this is a nice excuse for the SAX command :D
ldx #andvalue_for_left_column
lda fromsprite+0
sax tosprite+0
lda fromsprite+3
sax tosprite+3
lda fromsprite+6
sax tosprite+6
...

ldx #andvalue_for_middle_column
lda fromsprite+1
sax tosprite+1
lda fromsprite+4
sax tosprite+4
lda fromsprite+7
sax tosprite+7
...

ldx #andvalue_for_right_column
lda fromsprite+2
sax tosprite+2
lda fromsprite+5
sax tosprite+5
lda fromsprite+8
sax tosprite+8
...

which is about 510 cycles ~ 9 rasterlines. Unrolling and SAX will save you +- 5 rasterlines.. maybe that's worthwhile to you! You can save even more if you're OK with storing the clipped sprite in the 0page, in which case you can get down to 447 cycles, about 8 rasterlines..
2010-06-01 17:10
doynax
Account closed

Registered: Oct 2004
Posts: 212
Quoting WVL
which is about 510 cycles ~ 9 rasterlines. Unrolling and SAX will save you +- 5 rasterlines.. maybe that's worthwhile to you! You can save even more if you're OK with storing the clipped sprite in the 0page, in which case you can get down to 447 cycles, about 8 rasterlines..
You can also save a fair bit by only bit-masking the one column which needs it.
2010-06-02 06:57
WVL

Registered: Mar 2002
Posts: 902
True, but then you need also some if-then-else to copy back columns that dont need to be masked anymore. Basically an if-then-else per column, deciding if the column is already ok, needs to be restored to original or needs to be clipped. (restoring and clipping is just the same code except the ldx #bla, if you use the SAX routine)

Also that doesnt work if your sprite is animated ofcourse :)
2010-06-02 08:14
enthusi

Registered: May 2004
Posts: 677
I would go for a 'dumb' routine as well.
But check for dx and dy optionally.
2010-06-02 12:17
Oswald

Registered: Apr 2002
Posts: 5094
24 columns horizontally, now aint that fullscreen minus last row ? where on raster irq solves the problem: change sprite pointer to an empty sprite.
2010-06-02 12:20
JackAsser

Registered: Jun 2002
Posts: 2014
Quote: 24 columns horizontally, now aint that fullscreen minus last row ? where on raster irq solves the problem: change sprite pointer to an empty sprite.

"24 columns horizontally" is like WTF! Either u have columns or rows, period.
2010-06-03 08:31
WVL

Registered: Mar 2002
Posts: 902
As a sidenote..

Are diagonal kefrens the same as horizontal columns or more like vertical rows?
2010-06-03 08:39
Steppe

Registered: Jan 2002
Posts: 1510
That depends on the angle. ;-)
2010-06-03 08:56
enthusi

Registered: May 2004
Posts: 677
Quote: That depends on the angle. ;-)

That's probably what makes proper roto-zooms so tough ;-)
Previous - 1 | 2 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
ΛΛdZ
Acidchild/Padua
Guests online: 106
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top Diskmag Editors
1 Magic  (9.8)
2 hedning  (9.6)
3 Jazzcat  (9.5)
4 Elwix  (9.1)
5 Remix  (9.1)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.048 sec.