/spacey

To get this branch, use:
bzr branch http://9ix.org/bzr/spacey
3 by Josh C
basecode main.lua
1
STRICT = true
2
DEBUG = true
3
4
require 'zoetrope'
4 by Josh C
trying some movement styles. derivatives on crystal quest movement.
5
--__ = require 'underscore'
13 by Josh C
constant velocity for bullets. using hump.vector e9b86ef
6
vector = require 'vector'
3 by Josh C
basecode main.lua
7
24 by Josh C
monkey patch group to add onRemove hook. remove mirrors on remove.
8
require 'group'
9
3 by Josh C
basecode main.lua
10
require 'version'
21 by Josh C
extract wrapping behavior, wrap bullets
11
require 'wrap_tile'
4 by Josh C
trying some movement styles. derivatives on crystal quest movement.
12
require 'player'
7 by Josh C
enemy
13
require 'enemy'
8 by Josh C
targeting cursor (manual switch to start)
14
require 'cursor'
11 by Josh C
pew pew!
15
require 'bullet'
7 by Josh C
enemy
16
17
util = {
18
   signOf = function(value)
19
               if value >= 0 then
20
                  return 1
21
               else
22
                  return -1
23
               end
24
            end
25
}
3 by Josh C
basecode main.lua
26
27
GameView = View:extend {
28
   onNew = function (self)
18 by Josh C
starry background
29
              -- for x = 1,30 do
30
              --    for y = 1,30 do
31
              --       self:add(Fill:new{x=x*400, y=y*400,
32
              --                         width = 32, height = 32,
33
              --                         fill = {0,0,255}
34
              --                      })
35
              --    end
36
              -- end
37
19 by Josh C
move player around looping world
38
              the.bg = Tile:new{
39
                 image = 'data/stars3.png',
40
                 -- 1366x768 * 3
41
                 width = 4098,
42
                 height = 2304
18 by Josh C
starry background
43
              }
19 by Josh C
move player around looping world
44
              self:add(the.bg)
4 by Josh C
trying some movement styles. derivatives on crystal quest movement.
45
46
              --the.player = CrystalPlayer:new{x=400,y=300}
19 by Josh C
move player around looping world
47
              the.player = SpacePlayer:new{x=1366,y=768}
4 by Josh C
trying some movement styles. derivatives on crystal quest movement.
48
              self:add(the.player)
49
7 by Josh C
enemy
50
              self:add(Enemy:new{x=400, y=300})
51
14 by Josh C
only fire if cursor is in target area. change cursor to reflect this.
52
              the.cursor = Cursor:new()
53
              self:add(the.cursor)
8 by Josh C
targeting cursor (manual switch to start)
54
4 by Josh C
trying some movement styles. derivatives on crystal quest movement.
55
              love.mouse.setGrab(true)
8 by Josh C
targeting cursor (manual switch to start)
56
              love.mouse.setVisible(false)
3 by Josh C
basecode main.lua
57
58
              --self:loadLayers('data/map.lua')
4 by Josh C
trying some movement styles. derivatives on crystal quest movement.
59
              self.focus = the.player
3 by Josh C
basecode main.lua
60
              --self:clampTo(self.map)
61
           end,
62
   draw = function (self, x, y)
63
             View.draw(self, x, y)
64
             love.graphics.print('FPS:' .. love.timer.getFPS(), 20, 20)
65
          end
66
}
67
68
MenuScreen = View:extend {
69
   title = Text:new{text = "Press a key to start", font = 48, wordWrap = false},
70
   --title = Tile:new{image = 'data/title.png', x = 0, y = 0},
71
   onNew = function(self)
72
              self:add(self.title)
73
              self.title:centerAround(400, 200)
74
           end,
75
   onUpdate = function(self, elapsed)
76
                 if the.keys:allJustPressed() then
77
                    the.app.view = GameView:new()
78
                 end
79
              end
80
}
81
82
the.app = App:new {
83
   onRun = function (self)
84
              print('Version: ' .. VERSION)
85
              self.view = GameView:new()
86
              if DEBUG then
87
                 self.console:watch('VERSION', 'VERSION')
88
                 self.console:watch('updateTook', 'the.updateTook')
19 by Josh C
move player around looping world
89
                 self.console:watch('the.player.x', 'the.player.x')
90
                 self.console:watch('the.player.y', 'the.player.y')
91
                 self.console:watch('the.app.width', 'the.app.width')
92
                 self.console:watch('the.app.height', 'the.app.height')
3 by Josh C
basecode main.lua
93
                 --self.console:watch('drawTook', 'the.drawTook')
22 by Josh C
mirror (contains a bug where things in the corner aren't getting mirrored?
94
95
                 -- back off that dark overlay a bit
96
                 self.console.fill.fill[4] = 75
3 by Josh C
basecode main.lua
97
              end
98
           end,
99
   onUpdate = function (self, dt)
100
                 if the.keys:justPressed('escape') then
101
                    self.quit()
102
                 end
103
              end,
104
   update = function (self, dt)
105
               the.updateStart = love.timer.getMicroTime()
106
               App.update(self, dt)
107
               if the.updateStart then
108
                  the.updateTook = love.timer.getMicroTime() - the.updateStart
109
               end
110
            end
111
}