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
| function shuffle(tbl) | |
| for i = #tbl, 2, -1 do | |
| local j = math.random(i) | |
| tbl[i], tbl[j] = tbl[j], tbl[i] | |
| end | |
| return tbl | |
| end |
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
| function Class (arg1, arg2, arg3) | |
| local obj = {} | |
| obj.var1 = arg1 | |
| obj.var2 = arg2 | |
| obj.var3 = arg3 | |
| function obj:out (arg) | |
| print(self[arg]) | |
| end | |
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
| For a short intro on vectors you can check out a set of 5 tutorials from Rodrigo Monteiro's blog, Higher-Order Fun: | |
| http://higherorderfun.com/blog/2009/06/07/math-for-game-programmers-01-introduction | |
| http://higherorderfun.com/blog/2009/06/07/math-for-game-programmers-02-vectors-101 | |
| http://higherorderfun.com/blog/2009/06/13/math-for-game-programmers-03-geometrical-representation-of-vectors | |
| http://higherorderfun.com/blog/2010/02/23/math-for-game-programmers-04-operations-on-vectors | |
| http://higherorderfun.com/blog/2012/06/03/math-for-game-programmers-05-vector-cheat-sheet | |
| After that the blog for Wolfire Games has a set of 4 tutorials going a bit further with vectors and getting into some linear algebra basics: | |
| http://blog.wolfire.com/2009/07/linear-algebra-for-game-developers-part-1 | |
| http://blog.wolfire.com/2009/07/linear-algebra-for-game-developers-part-2 |
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
| function love.load() | |
| local start_x = 0 | |
| local start_y = 0 | |
| local end_x = 10 | |
| local end_y = 5 | |
| dx = (end_x - start_x) | |
| dy = (end_y - start_y) | |
| local distance = math.sqrt(dx^2 + dy^2) |
NewerOlder