Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Vincent on Mon 23/06/2014 11:45:06

Title: Taschenlampe
Post by: Vincent on Mon 23/06/2014 11:45:06
Good morning to all Agser!
I have a gGui2 with his graphic that match with a DynamicSprite to get the screen totally black..
Secondly, i draw a circle at the foot of the character to fill a part of the black screen..
just like in the picture :

(http://imageshack.com/a/img840/6863/kfz.png)

Thirdly, i draw a rectangle to improvise a stream of light that follow the circle distance..
like this :

(http://imageshack.com/a/img849/5260/u7hw.png)

I'm here to ask for an opinion from all of you,
now my intention are as follow : how can I tilt the rectangle when the mouse goes above or below ?
I edited the picture for you to notice what I would do :

(http://imageshack.com/a/img853/6971/6ldm.png)

Could someone help me with this ?
For all eventualities, I will post the code here

Code (ags) Select

DynamicSprite *dark;

int lightx[220],
    lighty[220],
    radius[220];

int count;
export count;

void Light(int i, int x, int y, int r)
{
  lightx[i] = x;
  lighty[i] = y;
  radius[i] = r;
}

function Darkness()
{
dark = DynamicSprite.Create(System.ViewportWidth, System.ViewportHeight);

DrawingSurface *surface = dark.GetDrawingSurface();
DrawingSurface *surface2 = dark.GetDrawingSurface();

surface.Clear(0);
surface.DrawingColor = COLOR_TRANSPARENT;

surface2.Clear(0);
surface2.DrawingColor = COLOR_TRANSPARENT;

int x1 = GetViewportX();
int y2 = GetViewportY();

int i = 0;
while (i < count) {
    if (right) surface.DrawCircle(lightx[i] - x1, lighty[i] - y2, radius[i]);
    i++;
  }

if (right) surface.DrawCircle(mouse.x+3, mouse.y - y2 - 40, 90);

else if (left)  surface.DrawCircle(mouse.x-3, mouse.y - y2 -40, 90);

surface2.DrawRectangle(mouse.x, player.y-70, player.x+5, 70- player.BlockingWidth+150);
 
surface.Release();
surface2.Release();

gGui2.BackgroundGraphic = dark.Graphic;
}


Thanks to all of you who are reading the message
Title: Re: Taschenlampe
Post by: Joe on Mon 23/06/2014 12:49:57
Try with a dummy line with a big thickness:

surface.DrawLine(x1,y1,x2,y2,thickness);

By the way, unless i'm missing something I dont see the need of using 2 different surfaces.
Title: Re: Taschenlampe
Post by: Vincent on Mon 23/06/2014 14:04:50
Thanks Joe for answering

Quote
Try with a dummy line with a big thickness:
Code (ags) Select

surface.DrawLine(x1,y1,x2,y2,thickness);


Well, I have tried many methods but it does not seem that this could help my request..
i guess it must be the same rectangle that do the stream of light, not a different line again
Title: Re: Taschenlampe
Post by: Joe on Mon 23/06/2014 15:04:37
Just compiled a test game with this code in the room script and it works...


DynamicSprite* dark;
function room_RepExec()
{
dark = DynamicSprite.Create(System.ViewportWidth, System.ViewportHeight);
DrawingSurface *surface = dark.GetDrawingSurface();

surface.Clear(0);
surface.DrawingColor = COLOR_TRANSPARENT;

int x1 = GetViewportX();
int y2 = GetViewportY();

surface.DrawCircle(mouse.x, mouse.y - y2, 40);
surface.DrawLine(mouse.x, mouse.y, player.x, player.y-20, 20);
surface.Release();

gGui2.BackgroundGraphic = dark.Graphic;
}
Title: Re: Taschenlampe
Post by: Vincent on Mon 23/06/2014 15:15:46
Aaaaahh ! This is Fantastic ! ;-D

Congratulations Joe ! :)
I'm Sorry i misunderstood your intentions !

Cheers from Italy and thank you again :P