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
| { | |
| "mods": | |
| [ | |
| { | |
| "name": "base", | |
| "enabled": true | |
| }, | |
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
| { | |
| "version": "0.2.0", | |
| "configurations": [ | |
| { | |
| "type": "lua-local", | |
| "request": "launch", | |
| "name": "Debug", | |
| "program": { | |
| "command": "love" | |
| }, |
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.update(dt) | |
| accumulator = accumulator+dt | |
| if joystick then | |
| handle_joystick(joystick) | |
| end | |
| if accumulator >= tickPeriod then | |
| -- do update stuff | |
| end | |
| 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 love.draw() | |
| local width, height = love.graphics.getDimensions() | |
| local gameScale = canvasWidth / canvasHeight | |
| local windowScale = width / height | |
| local sw, sh = width/canvasWidth, height/canvasHeight | |
| if windowScale > gameScale then | |
| drawScale = sh | |
| else | |
| drawScale = sw |
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
| if btnp(4) then | |
| local index = cursor.y*10+cursor.x | |
| -- placing something will have to consider if it is an empty spot | |
| -- and if we still have something to place (in hand is > 0 in id) | |
| if (space_map[index] == vacant) and (in_hand_object != 0) then | |
| -- if so place it | |
| space_map[cursor.y*10+cursor.x] = in_hand_object | |
| -- set our hand to "empty" | |
| in_hand_object = 0 | |
| -- only add objecst to hand if we still have them in pool |
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
| -- borders around play area | |
| line(8,7,87,7,1) | |
| line(7,8,7,88,1) | |
| line(88,8,88,88,1) | |
| line(8,89,87,89,1) | |
| -- fill pattern for grid | |
| for i=1,10 do | |
| fillp(▒) | |
| --line((i*8)-1,8,(i*8),88,1) | |
| local xpos = (i*8)-1 |
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
| -- Insertion Sort by @impbox | |
| -- this will sort our closed list by the A* F value. | |
| function sort(array) | |
| for i=1,#array do | |
| local j = i | |
| while j > 1 and array[j-1].f < array[j].f do | |
| array[j],array[j-1] = array[j-1],array[j] | |
| j = j - 1 | |
| end | |
| 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
| -- a little helper function to print centered text | |
| function print_center(text, x, y, color) | |
| -- get the lenght of the text | |
| -- if you did not know, print returns the position of the last character | |
| -- so fi you print offscreen, starting from 0 you will get the exact lenght of the text | |
| local len = print(text, 0, 400, color) | |
| print(text, x-(len/2), y, color) | |
| 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
| -- state machines might sound complicated, but when it comes down | |
| -- they are just if statements that control how our code behaves. | |
| -- based on certain conditions you can jump between "states" | |
| -- and this can help you also organize stuff better, animate more freely, or | |
| -- for example, let's use state machines to create a menu system for our game | |
| function _init() | |
| -- we will start on the game logo scene | |
| -- and we will have the following: | |
| -- menu: to show a nice menu if you want | |
| -- gameplay: where the actual game code runs |
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 _init() | |
| -- create collection for players | |
| players = {} | |
| -- p1 | |
| player1 = { | |
| x = 0, | |
| y = 2, | |
| clr = 12, | |
| health = 10 | |
| } |
NewerOlder