## Basic Lightning Theory

# Introduction

Every good game needs good visual effects. Here is how to do basic lightning. This only covers 2D lightning, but you could easily extend this to 3D.

# The Good Stuff

Define 2 points, A and B.

Draw a line to link the 2 points up.

Find the middle of the line AB, and mark it (M).

Add a displacement to the coordinates of M (should be random), then link AM and MB together. In this case, M is displaced (-18, -13) to create M'.

# Are You Done?

Congratulations! You've got the basics! Now, just rinse and repeat with your new lines AM' and M'B! Recursion works wonders, doesn't it! Here is an implementation of this basic lightning thingy in Python and pygame!

This little thing has the lightning originate from the middle of the window and arc out to attack your cursor if you click on the screen. I made this to test the lightning concept for a tower defense game that I was inspired to create.