Graphics Drawing lightning in your game

Discussion in 'Tutorials' started by amusudan, Jun 20, 2016.

  1. amusudan

    amusudan Lousiest of Potatoes

    Joined:
    Jun 20, 2016
    Posts:
    183
    [​IMG]
    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".

    [​IMG]

    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: Jun 21, 2016
  2. Spacedog

    Spacedog Member

    Joined:
    Jun 21, 2016
    Posts:
    5
    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.
     
  3. Davemane42

    Davemane42 Member

    Joined:
    Jun 21, 2016
    Posts:
    8
    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.
     
  4. amusudan

    amusudan Lousiest of Potatoes

    Joined:
    Jun 20, 2016
    Posts:
    183
    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: Jun 21, 2016
  5. amusudan

    amusudan Lousiest of Potatoes

    Joined:
    Jun 20, 2016
    Posts:
    183
    I updated the download, I hope it works now!
     
  6. Spacedog

    Spacedog Member

    Joined:
    Jun 21, 2016
    Posts:
    5
    Working now and it's a really nice effect, well done!
     
  7. amusudan

    amusudan Lousiest of Potatoes

    Joined:
    Jun 20, 2016
    Posts:
    183
    Thanks! Glad the problem has been resolved.
     
  8. Kousenai

    Kousenai Furry Flaebae

    Joined:
    Jun 20, 2016
    Posts:
    72
    Looks neato. A useful resource for gamedevs I'm sure.
     
  9. Edoc'sil

    Edoc'sil Member

    Joined:
    Jun 20, 2016
    Posts:
    12
    This is pretty sweet! Thanks so much!
     
  10. amusudan

    amusudan Lousiest of Potatoes

    Joined:
    Jun 20, 2016
    Posts:
    183
    No problem!
     
  11. SoulTie

    SoulTie Visionary

    Joined:
    Jun 23, 2016
    Posts:
    69
    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 likes this.
  12. amusudan

    amusudan Lousiest of Potatoes

    Joined:
    Jun 20, 2016
    Posts:
    183
    Yes that does sound like a good idea, I'll update the file as soon as I can open GM:S :).
     
  13. jazzzar

    jazzzar Member

    Joined:
    Jun 29, 2016
    Posts:
    514
    very nice effect,i'm using this in my game,very good job
     
  14. amusudan

    amusudan Lousiest of Potatoes

    Joined:
    Jun 20, 2016
    Posts:
    183
    Thanks!
     
  15. GMSNormie

    GMSNormie Member

    Joined:
    Apr 3, 2017
    Posts:
    49
    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?
     
  16. amusudan

    amusudan Lousiest of Potatoes

    Joined:
    Jun 20, 2016
    Posts:
    183
    Sorry this was made in GMS1, and I do not own version 2 so I can't make an updated version for you :<
     
  17. rIKmAN

    rIKmAN Member

    Joined:
    Sep 6, 2016
    Posts:
    3,151
    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.
     
  18. amusudan

    amusudan Lousiest of Potatoes

    Joined:
    Jun 20, 2016
    Posts:
    183
    I'm working on a newer, better version of this at the moment! Will be released as a free extension when finished.
     
    Nocturne, Morne, jackquake and 3 others like this.
  19. Kombowz

    Kombowz Member

    Joined:
    Jun 1, 2017
    Posts:
    5
    Wow, that looks amazing. Looking forward to seeing it when it's done.
     
    amusudan likes this.
  20. amusudan

    amusudan Lousiest of Potatoes

    Joined:
    Jun 20, 2016
    Posts:
    183
    Thanks, it's not very high on my todo list but it's coming!
     
  21. tob11

    tob11 Member

    Joined:
    Feb 1, 2018
    Posts:
    7
    Thank you very much!
     
  22. Evandro Aguiar

    Evandro Aguiar Member

    Joined:
    Jun 23, 2016
    Posts:
    14
    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!
     
  23. EME

    EME Member

    Joined:
    Oct 8, 2017
    Posts:
    14
    I will try it soon... Looks nice!
     
  24. amusudan

    amusudan Lousiest of Potatoes

    Joined:
    Jun 20, 2016
    Posts:
    183
    The older version also stops drawing at whichever point you specify iirc
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice