• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!

Graphics Drawing lightning in your game

amusudan

Lousiest of Potatoes

Screenshot from my game.

GM Version
: GameMaker: Studio
Target Platform: All
Download: New download here, fixed one error with a non-existant script.
Links: N/A

Summary:
Ever wanted to draw kick-ass lightning in your game but aren't the artsy type? Generate it! With this simple script you can draw wicked lightning, wickedly easy!

Tutorial:
Download the script and import it into your project by right clicking on the "scripts" folder and clicking on "add existing script".



Then call the script like this:
draw_lightning(x, y, x2, y2, branches, colour)
Where x + y make up the first point of your lightning and x2 + y2 make up the final point of your lightning.
Branches is wether the lighting splits up into smaller branches of lightning and colour is the colour of the glow around the lightning.

If you have any problems just comment it down below, I hope this helped you in making your game a little bit awesomer :).
 
Last edited:

Spacedog

Member
I tried this but the script references another script called scr_lightning which is not included so it won't work. Would like to try it though, been looking for something like this.
 
D

Davemane42

Guest
I have a small problem with your script. At line 61 it refer to scr_lightning who is none existant and the script is unusable. thank for awsering me.
 

amusudan

Lousiest of Potatoes
Oh, sorry about that! Just change scr_lightning to draw_lightning (and add the colour variable to it), I'll update the file too!

Terribly sorry for this!
 
Last edited:
S

SoulTie

Guest
This looks pretty good. I have added an argument to the script for the "size" variable; I think that it looks better with a thicker line. Maybe you could add this to the download? Good job
 

amusudan

Lousiest of Potatoes
This looks pretty good. I have added an argument to the script for the "size" variable; I think that it looks better with a thicker line. Maybe you could add this to the download? Good job
Yes that does sound like a good idea, I'll update the file as soon as I can open GM:S :).
 
G

GMSNormie

Guest

Screenshot from my game.

GM Version
: GameMaker: Studio
Target Platform: All
Download: New download here, fixed one error with a non-existant script.
Links: N/A

Summary:
Ever wanted to draw kick-ass lightning in your game but aren't the artsy type? Generate it! With this simple script you can draw wicked lightning, wickedly easy!

Tutorial:
Download the script and import it into your project by right clicking on the "scripts" folder and clicking on "add existing script".



Then call the script like this:
draw_lightning(x, y, x2, y2, branches, colour)
Where x + y make up the first point of your lightning and x2 + y2 make up the final point of your lightning.
Branches is wether the lighting splits up into smaller branches of lightning and colour is the colour of the glow around the lightning.

If you have any problems just comment it down below, I hope this helped you in making your game a little bit awesomer :).
Super late, but I can't open the GML file in GMS, it says it has to be in .yy format? Is this because I'm using GMS2?
 

amusudan

Lousiest of Potatoes
Super late, but I can't open the GML file in GMS, it says it has to be in .yy format? Is this because I'm using GMS2?
Sorry this was made in GMS1, and I do not own version 2 so I can't make an updated version for you :<
 

rIKmAN

Member
Super late, but I can't open the GML file in GMS, it says it has to be in .yy format? Is this because I'm using GMS2?
Try opening the script with a text editor and copying the code.
Then create a new script in GMS2 and paste the code into script editor.

There may be a few changes you need to make (or maybe not), but it shouldn't be too hard to make it work as most functions are the same between versions.
 
Great effect. But, is there a way to make it stop drawing when the bolt reaches de x2 (max distance), like in your new example? Thanks!
 
Top