5
--__ = require 'underscore'
6
vector = require 'vector'
19
signOf = function(value)
28
GameView = View:extend {
32
onNew = function (self)
35
-- self:add(Fill:new{x=x*400, y=y*400,
36
-- width = 32, height = 32,
43
image = 'data/stars3.png',
50
--the.player = CrystalPlayer:new{x=400,y=300}
51
the.player = SpacePlayer:new{x=1366,y=768}
54
self:add(Enemy:new{x=400, y=300})
56
the.cursor = Cursor:new()
59
love.mouse.setGrab(true)
60
love.mouse.setVisible(false)
62
--self:loadLayers('data/map.lua')
63
self.focus = the.player
64
--self:clampTo(self.map)
66
self.gameStart = love.timer.getTime()
68
onUpdate = function(self, dt)
69
if love.timer.getTime() > self.lastRock + self.rockInterval then
70
local rock = Rock:new{
71
x = math.random(the.bg.width),
72
y = math.random(the.bg.height),
74
x = math.random(-300, 300),
75
y = math.random(-300, 300),
76
rotation = math.random(-7, 7)
78
scale = math.random() + 0.5
82
self.lastRock = love.timer.getTime()
85
draw = function (self, x, y)
87
love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
91
MenuScreen = View:extend {
92
title = Text:new{text = "Press a key to start", font = 48, wordWrap = false},
93
--title = Tile:new{image = 'data/title.png', x = 0, y = 0},
94
onNew = function(self)
96
self.title:centerAround(400, 200)
98
onUpdate = function(self, elapsed)
99
if the.keys:allJustPressed() then
100
the.app.view = GameView:new()
106
onRun = function (self)
107
print('Version: ' .. VERSION)
109
math.randomseed(os.time())
111
self.view = GameView:new()
113
self.console:watch('VERSION', 'VERSION')
114
self.console:watch('updateTook', 'the.updateTook')
115
self.console:watch('the.player.x', 'the.player.x')
116
self.console:watch('the.player.y', 'the.player.y')
117
self.console:watch('the.app.width', 'the.app.width')
118
self.console:watch('the.app.height', 'the.app.height')
119
--self.console:watch('drawTook', 'the.drawTook')
121
-- back off that dark overlay a bit
122
self.console.fill.fill[4] = 75
125
onUpdate = function (self, dt)
126
if the.keys:justPressed('escape') then
130
update = function (self, dt)
131
the.updateStart = love.timer.getMicroTime()
133
if the.updateStart then
134
the.updateTook = love.timer.getMicroTime() - the.updateStart