Skip to content

Commit

Permalink
New sound and spark for swarmer (#150)
Browse files Browse the repository at this point in the history
Fix transparent sprites blitting black, due to
still having rgb values despite 0 alpha
  • Loading branch information
cxong committed Jun 22, 2014
1 parent a01491c commit 3921d89
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 10 deletions.
Binary file added graphics/boom_16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions particles.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
"Name": "spark",
"OldPic": 111
},
{
"Name": "boom",
"Sprites": "boom",
"OldPic": 111,
"Range": 7,
"TicksPerFrame": 1
},
{
"Name": "muzzle_flash_default",
"Sprites": "muzzle_flash",
Expand Down
4 changes: 2 additions & 2 deletions sounds/boom.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Derived from Boom Pack 1 by dklon
http://opengameart.org/content/boom-pack-1
Derived from Synthesized_Explosion_01.wav by RSilveira_88
http://freesound.org/people/RSilveira_88/sounds/216278/

http://creativecommons.org/licenses/by/3.0/
Binary file modified sounds/boom.wav
Binary file not shown.
7 changes: 5 additions & 2 deletions src/cdogs/bullet_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,8 @@ void BulletInitialize(CArray *bullets)
b.RangeLow = b.RangeHigh = 60;
b.Power = 20;
b.Size = Vec2iNew(3, 3);
b.Spark = ParticleClassGet(&gParticleClasses, "boom");
b.WallHitSound = StrSound("boom");
b.SeekFactor = 20;
CArrayPushBack(bullets, &b);

Expand Down Expand Up @@ -745,10 +747,11 @@ void BulletInitialize(CArray *bullets)
b.Beam.Sprites = PicManagerGetSprites(&gPicManager, "swarmer");
b.SpeedLow = b.SpeedHigh = 700;
b.RangeLow = b.RangeHigh = 70;
b.Power = 10;
b.Power = 12;
b.Size = Vec2iNew(3, 3);
b.Spark = ParticleClassGet(&gParticleClasses, "boom");
b.WallHitSound = StrSound("boom");
b.SeekFactor = 18;
b.SeekFactor = 30;
CArrayPushBack(bullets, &b);


Expand Down
21 changes: 15 additions & 6 deletions src/cdogs/pic_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,22 @@ static void AddPic(PicManager *pm, const char *name, const char *path)
int srcI = offset.y*image->w + offset.x;
for (int i = 0; i < size.x * size.y; i++, srcI++)
{
Uint32 pixel = ((Uint32 *)s->pixels)[srcI];
Uint32 alpha =
const Uint32 alpha =
((Uint32 *)image->pixels)[srcI] >> image->format->Ashift;
Uint32 rgbMask =
s->format->Rmask | s->format->Gmask | s->format->Bmask;
pic->Data[i] =
(pixel & rgbMask) | (alpha << gGraphicsDevice.Ashift);
// If completely transparent, replace rgb with black (0) too
// This is because transparency blitting checks entire pixel
if (alpha == 0)
{
pic->Data[i] = 0;
}
else
{
const Uint32 pixel = ((Uint32 *)s->pixels)[srcI];
const Uint32 rgbMask =
s->format->Rmask | s->format->Gmask | s->format->Bmask;
pic->Data[i] =
(pixel & rgbMask) | (alpha << gGraphicsDevice.Ashift);
}
if ((i + 1) % size.x == 0)
{
srcI += image->w - size.x;
Expand Down

0 comments on commit 3921d89

Please sign in to comment.