1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
STRICT = true
DEBUG = true
require 'zoetrope'
--__ = require 'underscore'
require 'version'
require 'player'
require 'enemy'
util = {
signOf = function(value)
if value >= 0 then
return 1
else
return -1
end
end
}
GameView = View:extend {
onNew = function (self)
for x = 1,30 do
for y = 1,30 do
self:add(Fill:new{x=x*400, y=y*400,
width = 32, height = 32,
fill = {0,0,255}
})
end
end
--the.player = CrystalPlayer:new{x=400,y=300}
the.player = SpacePlayer:new{x=400,y=300}
self:add(the.player)
self:add(Enemy:new{x=400, y=300})
love.mouse.setGrab(true)
--love.mouse.setVisible(false)
--self:loadLayers('data/map.lua')
self.focus = the.player
--self:clampTo(self.map)
end,
draw = function (self, x, y)
View.draw(self, x, y)
love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
end
}
MenuScreen = View:extend {
title = Text:new{text = "Press a key to start", font = 48, wordWrap = false},
--title = Tile:new{image = 'data/title.png', x = 0, y = 0},
onNew = function(self)
self:add(self.title)
self.title:centerAround(400, 200)
end,
onUpdate = function(self, elapsed)
if the.keys:allJustPressed() then
the.app.view = GameView:new()
end
end
}
the.app = App:new {
onRun = function (self)
print('Version: ' .. VERSION)
self.view = GameView:new()
if DEBUG then
self.console:watch('VERSION', 'VERSION')
self.console:watch('updateTook', 'the.updateTook')
--self.console:watch('drawTook', 'the.drawTook')
end
end,
onUpdate = function (self, dt)
if the.keys:justPressed('escape') then
self.quit()
end
end,
update = function (self, dt)
the.updateStart = love.timer.getMicroTime()
App.update(self, dt)
if the.updateStart then
the.updateTook = love.timer.getMicroTime() - the.updateStart
end
end
}
|