Canvas Light (WIP)

Talk about making games.

Canvas Light (WIP)

Postby Hblade » Thu Feb 19, 2015 1:29 am

So, I was bored and decided to try and make canvas light =D

So far... looks interesting.
light.png
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Canvas Light (WIP)

Postby schnellboot » Thu Feb 19, 2015 8:53 pm

i need the code :twisted:
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: Canvas Light (WIP)

Postby bat78 » Thu Feb 19, 2015 8:57 pm

If you are more bored you can also add smooth lightness and a blink.
and then it will be a decent lighting.

If you want to make it perfect.. you have to know that the light has a color. It doesn't just "take-off the darkness" xDD
You have to erase a specific color with specific transparancy.
When my project is done, you will be able to do color mapping in real time.. so you can obtain a specific color for each pixel in the background.

Note that this might happen in bitfox v2.
I will have to program a 3rd party program similar to animget that makes screenshots each frame.
On that way, you can have color of each pixel in your game.
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: Canvas Light (WIP)

Postby Hblade » Thu Feb 19, 2015 9:24 pm

already added it =D using putpixel too. is nice.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Canvas Light (WIP)

Postby bat78 » Thu Feb 19, 2015 9:28 pm

Good job!
At least you can do and release something that fast.. I still have to work on that.
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: Canvas Light (WIP)

Postby Hblade » Thu Feb 19, 2015 11:57 pm

Here ya go, man :D
soft_light.png


Code: Select all
void soft_light_inverted(int X, int Y, int R, int G, int B, double A, double rad, int smooth)
{
    double i, i2;
    moveto(X, Y);
    setpen(R, G, B, A, 5+smooth);
    for(i=0;i<pi*2;i+=pi/rad/(pi/5))
    {
        for(i2=0;i2<rad;i2+=4)
        {
            setpen(R, G-(i2/rad), B-(i2/rad), 1-min((A+(i2/rad)), .8), 4);
            putpixel(X+cos(i)*i2, Y+sin(i)*i2);
        }
    }
}


To use:
soft_light_inverted(player.xscreen, player.yscreen, 0, 0, 0, 0, 150, 0);
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Canvas Light (WIP)

Postby bat78 » Fri Feb 20, 2015 12:11 am

Okay now it looks regal. In a response of this, I created a jumping mechanism.
Tomorrow we'll make an entire game as it seems haha.
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: Canvas Light (WIP)

Postby Hblade » Fri Feb 20, 2015 12:20 am

seen it nice job dude =D hehe
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Canvas Light (WIP)

Postby bat78 » Fri Feb 20, 2015 12:31 am

Hblade wrote:seen it nice job dude =D hehe

haha thanks =D It is nothing much. But I was out of ideas and time so..

Can I use your light in my project. I can immediately make it compatible with bmps.
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: Canvas Light (WIP)

Postby Hblade » Fri Feb 20, 2015 12:33 am

Sure you can =D I'd like to see the results lol O:
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Canvas Light (WIP)

Postby bat78 » Fri Feb 20, 2015 1:57 am

Hblade wrote:Sure you can =D I'd like to see the results lol O:

I don't know why I am doing this.. but I will make a demo.

A quick question:
Why is there moveto?
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: Canvas Light (WIP)

Postby bat78 » Fri Feb 20, 2015 2:19 am

Done, but it looks wrong, unlikely because of the overloaded functions of my project but ..I guess it is that I have defined precision as:
#define pi 3.14159265

Put one x24 bit bmp named "lightme" in the local directory, open the application and press the button. It will put your light centered of the image.
lightme.exe
(1.71 MiB) Downloaded 150 times


Oups, I didn't notice that I -1ed translarancy twise. That because bitfox's setpen's transparancy of 0 means max transparancy.
i.e it is 0 instead of 1 ..the opposite way. Check the picture bellow for how should it looks like.
Last edited by bat78 on Fri Feb 20, 2015 2:40 am, edited 2 times in total.
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: Canvas Light (WIP)

Postby bat78 » Fri Feb 20, 2015 2:30 am

I mean it looks like the size of the pixel is being incorrect:
Image
The future of "Game-Editor" here
User avatar
bat78
 
Posts: 816
Joined: Sun Dec 14, 2008 9:13 pm
Location: Bulgaria, Sofia
Score: 88 Give a positive score

Re: Canvas Light (WIP)

Postby digiot » Fri Feb 20, 2015 1:58 pm

Hblade wrote:So, I was bored and decided to try and make canvas light =D

That looks great now, with the smoothing, well done !

But what I ask me, is using a png instead really too expensive on ressources ?


Cheers !
User avatar
digiot
 
Posts: 211
Joined: Sat Mar 17, 2012 2:29 pm
Score: 7 Give a positive score

Re: Canvas Light (WIP)

Postby Hblade » Fri Feb 20, 2015 3:54 pm

Hi, and no not really, this was mostly just me trying to see if it can be done using no images lol O:

IN fact, not using PNG's is probably more resource hungry haha :D

Upsides:
Unlimited sizing without pixelation, you can have any light size without there being a down grade in visual quality =D

Downsides:
Might take up loads of processing if using larger lights.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Next

Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest