Created
July 16, 2015 17:21
-
-
Save sonic2kk/ddc4302a250d52c911e1 to your computer and use it in GitHub Desktop.
A Gist showing the basics of how to write a system which lets you create players and optionally store them in variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Enemies = {} | |
| function Enemies.new(x, y, w, h, name, health) | |
| local e = { x = x, y = y, w = w, h = h, name = name, health = health } | |
| table.insert(Enemies, e) | |
| return e | |
| end | |
| function Enemies.update(dt) | |
| for i,v in ipairs(Enemies) do | |
| -- Update your enemies here | |
| end | |
| end | |
| function Enemies.draw() | |
| for i,v in ipairs(Enemies) do | |
| -- Draw your enemies here | |
| end | |
| end | |
| -- any other function for the enemies should follow a similar format, | |
| -- such that they all begin with "Enemies." and contain a "for i,v in ipairs(Enemies)" loop |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'enemy' | |
| local enemy | |
| function love.load() | |
| enemy = Enemies.new(10, 10, 50, 50, 'Jacques von Hämsterviel', 9001) | |
| end | |
| function love.update(dt) | |
| Enemies.update(dt) | |
| end | |
| function love.draw() | |
| Enemies.draw() | |
| end | |
| function love.quit() | |
| love.event.quit() | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment