Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Cheap, adjustable gradients.

Author
Message
Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 29th Sep 2012 04:16
Here's a cheap (small graphic) way to make adjustable background gradients. By varying the size, angle, and color of the two sprites, you can make all sorts of gradients.

Just something fun to play with



Attachments

Login to view attachments
Auger
12
Years of Service
User Offline
Joined: 21st Aug 2011
Location: Out There
Posted: 29th Sep 2012 07:51
Whoa that's pretty cool Rich. Plus the Png to display it all is so tiny. I added a couple lines of code to yours to make it generate random gradients. Good work!


Alien Menace
AGK Developer
19
Years of Service
User Offline
Joined: 11th Jan 2005
Location: Earth (just visiting)
Posted: 29th Sep 2012 10:16
Nice one!

Apps published: 3
BatVink
Moderator
20
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 29th Sep 2012 17:38
So simple...once somebody shows you how!
It is one of those moments when you say, "Why didn't I think of that?"

Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 1st Oct 2012 12:47
I've just returned from holiday, checked my email, found the TGC Newsletter and stumbled across this. Makes the return worthwhile after all.

For the "oldies" among you, here's a DBPro version of the same thing:



A wonderfully simple idea. Thank you!
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Oct 2012 13:42
Hi GG! Nice to see you around, I haven't been on the DBP boards much lately so I guess it's my own fault but great to see you on the AppGameKit boards none the less

Yes, as usual Rich has come up with something wonderfully simple and clever that makes you wish you'd thought of it... I quite fancy using this to turn some ordinary fonts into gradient fonts using a bit of sprite masking. It will surely be fun to experiment with.


this.mess = abs(sin(times#))
bjadams
AGK Backer
15
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 1st Oct 2012 15:24
Baxslash, I have a use for sprite masking. I remember there was a thread way back with some information but couldn't find it.

If you have any related links or info can you please post?

Thanks a lot.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Oct 2012 15:29
Here's a link to the documentation: http://www.appgamekit.com/documentation/Reference/Image/SetImageMask.htm

You can use one image as the mask for another using any of it's colour channels. For example if you create a texture image you can use the alpha channel from the font image as the alpha for the texture image and then save it out as a "png".

SetImageMask( textureImage, fontImage, 4, 4, 0, 0 )
saveImage( textureImage, "myNewFont.png" )


this.mess = abs(sin(times#))
Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 1st Oct 2012 17:25
@baxslash -
Quote: "
I quite fancy using this to turn some ordinary fonts into gradient fonts using a bit of sprite masking. It will surely be fun to experiment with."


I've just been doing that very thing! Of course I use photoshop for sweet hi-res, anti-aliased, hand-made font goodness, but for those who just want to say... snap a picture of some cool texture (beach, old wall, pavement, etc.) and turn the image into a font? It can happen with image masking!

@GG - very clever! I also seem to remember that the box command in DBPro has parameters for color at each corner, making gradients in DBPro very easy. Perhaps when AppGameKit gets drawing commands they will be just as easy!

@bj - this thread has some examples of using image masks.

A caveat about those bullet holes - they can't overlap. This might be a bug, or just a limitation of using an image mask. I'm still experimenting, but it looks like you can't just "cut a hole" like you might think.

xCept
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 2nd Oct 2012 02:00
So simple but practical Thanks.
bjadams
AGK Backer
15
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 3rd Oct 2012 16:19
thanks
Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 3rd Oct 2012 17:38 Edited at: 3rd Oct 2012 17:39
In playing around with the command, I've found that you actually CAN make the bullet holes overlap, but it's tricky.

What you do is make a blank white image. Then draw a bullet hole sprite in black, and grab the resulting image. Then you use that grabbed image to transfer one of the channels (R, G, or B) to the alpha of the front image. The next time you shoot, draw the grabbed image, add another black bullet hole, re-grab the image, etc. I'll post an example of what I mean later today.

This works great in Windows, but unfortunately I can't get it to work when broadcast to my iPad. There is some sort of feedback loop going on with grabbing rendered sprites before a sync. Might be a bug, or just the way iOS displays work. Time will tell.

bjadams
AGK Backer
15
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 3rd Oct 2012 17:52
sprite masking is slow. the docs advice not to use it per frame
image grabbing is slow and does not work on all hardware/os versions

so it's a deadly combination!
Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 3rd Oct 2012 20:43
Quote: "sprite masking is slow. the docs advice not to use it per frame
image grabbing is slow and does not work on all hardware/os versions

so it's a deadly combination! "


So true! Although using them on a "per event" basis instead of "per frame" is not too bad. I had to slow it down to check for input every OTHER frame, or the bullet holes incremented too quickly.

I wish it did work with iOS, it might make a neat game, shooting holes in a wall to get the moving target behind the wall.

bjadams
AGK Backer
15
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 3rd Oct 2012 20:47
Rich did you try it on an iPhone 3GS?
For me that is the speed test to check for a game.

My AppGameKit game project (which never gets finished!) still runs at 60fps on the 3GS! And I am not using spritesheets yet, so I guess sprites are not being drawn in batch! Just for this fact, AppGameKit is truly AMAZING!!!

Login to post a reply

Server time is: 2024-03-28 09:55:35
Your offset time is: 2024-03-28 09:55:35