You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
1.8 KiB
73 lines
1.8 KiB
function love.load()
|
|
Object = require("classic")
|
|
require("player")
|
|
require("bullet")
|
|
WF = require("libs/windfield")
|
|
STI = require("libs/sti")
|
|
|
|
require("UpdateGame")
|
|
require("DrawGame")
|
|
require("KeyPressed")
|
|
|
|
--WindField
|
|
World = WF.newWorld(0, 0) --no gravity
|
|
World:setQueryDebugDrawing(true) -- Draws the area of a query for 10 frames
|
|
World:addCollisionClass("Player1")
|
|
World:addCollisionClass("Bullet1")
|
|
|
|
World:addCollisionClass("Player2")
|
|
World:addCollisionClass("Bullet2")
|
|
|
|
World:addCollisionClass("Wall")
|
|
World:addCollisionClass("New") -- Used to make sure the bullet doesn't collide with the player that shot it
|
|
|
|
--STI
|
|
GameMap = STI("maps/map.lua")
|
|
Walls = {}
|
|
if GameMap.layers["Walls"] then
|
|
for _, obj in ipairs(GameMap.layers["Walls"].objects) do
|
|
local wall = World:newRectangleCollider(obj.x, obj.y, obj.width, obj.height)
|
|
wall:setType("static")
|
|
table.insert(Walls, wall)
|
|
Walls[#Walls]:setCollisionClass("Wall")
|
|
end
|
|
end
|
|
|
|
--Fonts used in the game
|
|
GameFont = love.graphics.newFont("assets/Daydream.ttf", 60)
|
|
DebugFont = love.graphics.newFont("assets/Daydream.ttf", 12)
|
|
love.graphics.setFont(GameFont)
|
|
|
|
HEALTH = 3
|
|
DELAY = 0.5
|
|
DebugFlag = false
|
|
EnableKeyPress1 = true
|
|
KeyPressTime1 = 0
|
|
KeyDelay1 = DELAY
|
|
EnableKeyPress2 = true
|
|
KeyPressTime2 = 0
|
|
KeyDelay2 = DELAY
|
|
|
|
local playerSpeed = 12000
|
|
UserPlayer1 = Player(1, 1000, 100, HEALTH, "assets/player1.png", playerSpeed)
|
|
UserPlayer2 = Player(2, 200, 300, HEALTH, "assets/player2.png", playerSpeed)
|
|
Bullets1 = {}
|
|
Bullets2 = {}
|
|
end
|
|
|
|
function love.keypressed(key)
|
|
KeyPressed(key)
|
|
end
|
|
|
|
function love.update(dt)
|
|
UpdateGame(dt)
|
|
end
|
|
|
|
function love.draw()
|
|
DrawGame()
|
|
if DebugFlag then
|
|
love.graphics.setFont(DebugFont)
|
|
love.graphics.print("Debug Mode", 1200, 850)
|
|
--love.graphics.print(love.report or "Please wait...")
|
|
end
|
|
end
|
|
|