RealTime LIghting Demo!

Post here your demos and examples with the source files.
Forum rules
Always post the games with a screenshot.
The file must have the ged and data files (complete game source)
Use the forum attachment to post the files.
It is always better to use the first post to put the game files

RealTime LIghting Demo!

Postby Hblade » Tue Mar 20, 2012 7:17 pm

I hope someone can explain how to make this into a circle :P That'd be cool! :D
s.png


Lighting.zip
(424.46 KiB) Downloaded 680 times


HOW IT WORKS:
It uses a canvas, set the canvas to your color, then use the command "SetLight(x, y, width, height);"

But because of an unknown bug, when setting the y, make sure you set +half of height, like this:
Code: Select all
SetLight(xmouse, ymouse+32, 64, 64);

Otherwise, your light is gonna end up above the Y position you told it to.
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: RealTime LIghting Demo!

Postby skydereign » Tue Mar 20, 2012 7:36 pm

I wouldn't use a canvas to make circles (at least how I think you are going about it). To do that you need to use putpixel, and it is slow. Nothing realtime about it. Anyway, take a look at the new ged (note you made it rather hard to use with the + and - adjustments based off of width). Also, just to teach you something, you were wasting a lot of loops doing the lineto method. The pen (from setpen) is a square. So you set its width or height, and just put the pixel at the position X, Y.
Attachments
Lighting.zip
(439.61 KiB) Downloaded 472 times
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: RealTime LIghting Demo!

Postby Hblade » Tue Mar 20, 2012 7:40 pm

Oh wow :oops: tahnks sky.

This is fantastic!
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: RealTime LIghting Demo!

Postby bat78 » Sun Jul 08, 2012 9:21 pm

I make the circle decently for flashlight and add sequence.
Do u allow me to add the lighting into the one of my games hblade?
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: RealTime LIghting Demo!

Postby Hblade » Sat Jul 14, 2012 11:56 pm

Thats up to you lol :)
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: RealTime LIghting Demo!

Postby 247wkman » Wed Sep 26, 2012 1:50 am

I MADE A BETTER LIGHT BASE ON THE PREVIOUS EXAMPLE ABOVE! I ATTACHED THE RE-TWEEKED GED BELOW

Still messing around with geds to figure the what-can-do's of g.e (and still finding it sainer to navigate than game maker..)
I just got a reply from lclMetal on youtube when i mentioned how to use draw functions to make a filled circle to create canvas lamp circles that can intersect each other and it helped me re-aprouch using images instead of pen funtions agian. And this time i got it right!

Basically use a non alpherd image of a filled circle- g.e will ignore the border color leaving you with just the circle.
However, even if you set the transparency to nothing, canvas erase won't draw over it.
So what you get is a clean circle image that can rub out the blackness of your dark room and merge with other instances of itself drawn around other actors.
The only remaining problem is how do you control draw order to overide how it was originally written in the script, so that dimmer lights or lights that are dimming (like if the battery was running low) will be drawn over by any brighter lights you approuch.

(canvas light circle/ lantern circle / tourch light tourchlight / draw circle)
Attachments
RealAdventureTimeLightDemo.zip
(966.21 KiB) Downloaded 322 times
247wkman
 
Posts: 67
Joined: Mon Dec 13, 2010 3:55 pm
Score: 3 Give a positive score

Re: RealTime LIghting Demo!

Postby ZeldaFan » Sun Jun 17, 2018 2:03 am

it is possible to do for actors that will be created?
ZeldaFan
 
Posts: 31
Joined: Sat Jul 04, 2015 5:38 pm
Score: 12 Give a positive score

Re: RealTime LIghting Demo!

Postby lcl » Sun Jun 17, 2018 5:12 am

ZeldaFan wrote:it is possible to do for actors that will be created?

Hello ZeldaFan. I don't quite understand your question, could you explain it a bit more precisely. I would like to help you.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: RealTime LIghting Demo!

Postby ZeldaFan » Sun Jun 17, 2018 8:40 pm

ZeldaFan
 
Posts: 31
Joined: Sat Jul 04, 2015 5:38 pm
Score: 12 Give a positive score

Re: RealTime LIghting Demo!

Postby lcl » Mon Jun 18, 2018 8:34 pm

ZeldaFan wrote:https://youtu.be/vVP74TJsEvY

Ah, I understand. Yes, it is possible to add the light to actors created during the runtime of the game. All you have to do is to use getclone() and a for-loop to iterate through the actors, and call the SetLight() function for each of them.
I would advise you to not use the original function by Hblade, but instead use the version skydereign made, because, as skydereign pointed out, Hblade's version can easily cause performance problems. If you want the light to be a rectangle instead of a circle, just change the animation of the "white" actor to a rectangle.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: RealTime LIghting Demo!

Postby ZeldaFan » Mon Jun 18, 2018 10:00 pm

can you give me an example?
I've never used getclone!
SetLight is used by the canvas, not by the actor. Even so, will it work?
ZeldaFan
 
Posts: 31
Joined: Sat Jul 04, 2015 5:38 pm
Score: 12 Give a positive score

Re: RealTime LIghting Demo!

Postby lcl » Tue Jun 19, 2018 12:23 pm

Here's what the GE Script Reference says about getclone().

http://game-editor.com/docs/script_refe ... m#getclone
GE Script Reference wrote:getclone: Get Actor with name cloneName.
Actor *getclone(char *cloneName)

cloneName: nameactor.cloneindex
(Example: ship.1, ship.2, ...)
Return Actor if successful, invalid Actor (with cloneindex = -1 and name = "") on error.


So, it is a function that returns an Actor pointer (Actor *) to the given actor.

Here's an example code that makes all the clones of the actor "myActor" red by setting their g (=green) and b (=blue) attributes to 0. For this code to work, there has to be a global integer variable called "highestCloneindex" that contains the cloneindex of the newest clone of "myActor" i.e. the clone that has the highest cloneindex.
Code: Select all
int i; // Iterator variable
char tempName[50]; // Temporary string for the name of the clone to be handled
Actor *actorPointer = NULL; // Pointer to the clone to be handled

for (i = 0; i <= highestCloneindex; i ++) // Iterate through all the clones of the actor
{
    sprintf(tempName, "myActor.%i", i); // Build the clonename for the clone of cloneindex i
                                        // Example: if i is 3, tempName will be: "myActor.3"

    actorPointer = getclone(tempName); // Get a pointer to the clone

    actorPointer->g = 0; // Set the green value of the clone to 0 via the pointer
    actorPointer->b = 0; // Set the blue value of the clone to 0 via the pointer
}

You can use a similar code to add lights to the positions of the clones.

ZeldaFan wrote:SetLight is used by the canvas, not by the actor. Even so, will it work?

Yes, what I meant is that in the code of the canvas actor, you call the function for drawing lights to the positions of the clones. As SetLight() is a drawing function it can only be used on a canvas actor.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: RealTime LIghting Demo!

Postby ZeldaFan » Thu Jun 21, 2018 11:28 pm

https://youtu.be/TIMOpNaaNyY

done is done!
:lol:

thaks guys!
ZeldaFan
 
Posts: 31
Joined: Sat Jul 04, 2015 5:38 pm
Score: 12 Give a positive score

Re: RealTime LIghting Demo!

Postby lcl » Fri Jun 22, 2018 1:13 pm

Nice!

Remember, if your game starts slowing down because of the lights, I'd advise you to use skydereign's version instead of Hblade's. His version also supports having lights of other shapes than a square.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: RealTime LIghting Demo!

Postby ZeldaFan » Sat Jun 23, 2018 9:25 pm

in my fan game, I used a drawfrom code!
allows you to animate the light.

:D
https://youtu.be/8g1hddIcoS0
ZeldaFan
 
Posts: 31
Joined: Sat Jul 04, 2015 5:38 pm
Score: 12 Give a positive score

Next

Return to Game Demos

Who is online

Users browsing this forum: No registered users and 1 guest