/ld28

To get this branch, use:
bzr branch http://9ix.org/bzr/ld28

« back to all changes in this revision

Viewing changes to main.lua

  • Committer: Josh C
  • Date: 2013-12-14 04:19:19 UTC
  • Revision ID: josh@9ix.org-20131214041919-p4awvb0gf7axmzc1
add a couple other clones that move randomly

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
require 'zoetrope'
5
5
deque = require 'deque'
6
 
--inspect = require 'inspect'
7
 
require 'sprite'
8
6
 
9
 
require 'util'
10
7
require 'version'
11
8
require 'player'
12
 
require 'clone'
 
9
require 'notplayer'
13
10
 
14
11
GameView = View:extend {
15
12
   onNew = function (self)
16
 
              self:loadLayers('data/map.lua')
 
13
              --self:loadLayers('data/map.lua')
 
14
              --self.focus = the.player
 
15
              --self:clampTo(self.bg)
17
16
 
18
17
              the.player = Player:new{
19
18
                 x = math.random(the.app.width),
21
20
              }
22
21
              self:add(the.player)
23
22
 
24
 
              the.clones = Group:new()
25
 
              self:add(the.clones)
26
 
              for _ = 1, 14 do
27
 
                 the.clones:add(Clone:new {
28
 
                                       x = math.random(16, the.app.width-32),
29
 
                                       y = math.random(16, the.app.height-32),
 
23
              the.notplayers = Group:new()
 
24
              self:add(the.notplayers)
 
25
              for _ = 1, math.random(1,2) do
 
26
                 the.notplayers:add(NotPlayer:new {
 
27
                                       x = math.random(the.app.width),
 
28
                                       y = math.random(the.app.height),
30
29
                                    })
31
30
              end
32
31
           end,
33
32
   onUpdate = function(self, dt)
34
33
                 if the.player.moved then
35
34
                    -- this should encapsulate
36
 
                    for _, np in ipairs(the.clones.sprites) do
 
35
                    for _, np in ipairs(the.notplayers.sprites) do
37
36
                       np:doMove()
38
37
                    end
39
38
 
40
 
                    the.clones:collide(self.map)
41
 
                    the.player:collide(self.map)
42
 
 
43
 
                    the.clones:collide()
44
 
                    the.clones:collide(the.player)
45
 
 
46
39
                    the.player.moved = false
47
40
                 end
48
41
 
66
59
                 self.console.fill.fill[4] = 75
67
60
              end
68
61
           end,
69
 
   onUpdate = function (self, dt)
70
 
                 if the.keys:justPressed('f1') then
71
 
                    local ss = love.graphics.newScreenshot()
72
 
                    ss:encode('screenshot-' ..love.timer.getTime()..'.png')
73
 
                 end
74
 
              end
75
62
}