Hey guys, i'm studying allegro library, and i'm trying to create a game. i want to put in my game, a light effect, and i got, but i also want a light points arround the map like this:
https://www.youtube.com/watch?v=_YVTOaUKO0Q
but when i come to the light point, happens it:
https://postimg.org/image/op1hpw6dd/
i'm doing that with blends, but i dont know how to proceed, anyone can help me? AHAH
part of code:
darkarea = al_create_bitmap(SCREEN_W, SCREEN_H);
al_set_target_bitmap(darkarea);
al_set_blender(ALLEGRO_ADD , ALLEGRO_ONE , ALLEGRO_ZERO);
al_clear_to_color(al_map_rgba_f(0, 0, 0,0.9));
al_draw_bitmap(light2, 1000-camera_x, 1000-camera_y , 0); // light point
al_draw_bitmap(light, 275, 170 , 0); //light that follow player
al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA);
al_set_target_backbuffer(display);
al_draw_bitmap(darkarea, 0, 0, NULL);
al_destroy_bitmap(darkarea);
I'm completely clueless about any of the GL language stuff and shaders and the like, but the obvious thing occurs to me: are you drawing things in an appropriate order? I'm not sure how your lighting is being handled, but I could imagine that the bitmap that is not lighted was drawn over top of the rest.
I would do it like this:
This object has a very simple API:
LightMask(int w, int h) - create a new lightmask.
void add_point(int x, int y) - adds a light point to your mask.
void clear_points() - removes all the light points from the mask.
void draw() - draws the mask.
Here is the light mask being drawn on a green background. It has two static points, and another point that follows the mouse (click for gif):
{"name":"610432","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/6\/4685ce30f58324f61f7186f933af907d.gif","w":656,"h":392,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/4\/6\/4685ce30f58324f61f7186f933af907d"}
can you send me the gradient.jpg please?
You bet! It's actually attached in my previous post. (paper-clip icon)
thanxx man, its work, my problem was the picture. i replaced my picture by your and worked perfectly =D, sorry for my english, i'm a brazilian student and i'm still improving my english AHAHAH