Such as this:
Code: Select all
require"game_object"
require"map_object"
function love.load()
--CREATE NEW OBJECTS
gameRisk = Game:new()
mapNewMap = Map:new()
-- SET INITIAL OBJECT VARIABLES
gameRisk:setPlayers(4)
mapNewMap:assignTerritories(gameRisk)
end
function love.draw()
if gameRisk.players > 0 then
love.graphics.print("Hello World".." "..gameRisk.players, 400, 300)
end
end
Code: Select all
-- GAME CLASS PROTOTYPE
Game = {players=0,time_elapsed=0,numPlayersSet=false}
function Game:new (o)
o = o or {}
setmetatable(o, self)
self.__index = self
return o
end
function Game:setPlayers (numPlayers)
self.players = numPlayers
if self.players == numPlayers then
numPlayersSet = true
return true
end
return false
end
-- MAP OBJECT CLASS PROTOTYPE
Code: Select all
Map = {territories = 42}
function Map:new (o)
o = o or {}
setmetatable(o, self)
self.__index = self
return o
end
function Game:assignTerritories (curGameInstance)
if curGameInstance.numPlayersSet== true then
return true
end
return false
end
I believe this is the block in map_object.lua that is producing the issue:
Code: Select all
if curGameInstance.numPlayersSet == true then
return true
end