/traderous

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

« back to all changes in this revision

Viewing changes to main.lua

  • Committer: Josh C
  • Date: 2013-06-19 02:01:02 UTC
  • Revision ID: josh@9ix.org-20130619020102-gw53ss3mrq8gjiud
add enemy state switch

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
              the.interface = Group:new()
87
87
              the.planets = Group:new()
88
88
              the.indicators = Group:new()
 
89
              the.enemies = Group:new()
89
90
 
90
91
              the.bg = Tile:new{
91
92
                 image = 'data/stars3.png',
102
103
              self:add(the.player.thrust)
103
104
              self:add(the.player.shield)
104
105
 
105
 
              local e = Enemy:new{x=400, y=300}
106
 
              --local e = Enemy:new{x=the.bg.width / 2, y=the.bg.height / 2}
107
 
              self:add(e)
108
 
              self:add(e.thrust) -- why doesn't this work in Enemy.new?
 
106
              self:add(the.enemies)
 
107
 
 
108
              for _ = 1, 5 do
 
109
                 local e = Enemy:new{x = math.random(the.bg.width),
 
110
                                     y = math.random(the.bg.height)}
 
111
                 --local e = Enemy:new{x=the.bg.width / 2, y=the.bg.height / 2}
 
112
                 the.enemies:add(e)
 
113
                 self:add(e.thrust) -- why doesn't this work in Enemy.new?
 
114
                 self:add(e.shield)
 
115
              end
109
116
 
110
117
              self:add(the.bullets)
111
118
              self:add(the.indicators)
125
132
              the.cursor = Cursor:new()
126
133
              self:add(the.cursor)
127
134
 
 
135
              the.over = Text:new{
 
136
                 y = the.app.height / 2,
 
137
                 width = the.app.width,
 
138
                 align = 'center',
 
139
                 font = 25,
 
140
                 text = "Game Over",
 
141
                 visible = false
 
142
              }
 
143
              the.interface:add(the.over)
 
144
 
 
145
 
 
146
              the.instructions = Text:new{
 
147
                 y = the.app.height / 2 + 32,
 
148
                 width = the.app.width,
 
149
                 align = 'center',
 
150
                 font = 12,
 
151
                 text = "Press Enter to start a new game\nPress Q to quit",
 
152
                 visible = false
 
153
              }
 
154
              the.interface:add(the.instructions)
 
155
 
128
156
              love.mouse.setGrab(true)
129
157
              love.mouse.setVisible(false)
130
158
              love.mouse.setPosition(the.app.width / 2, the.app.height / 2)
134
162
   onUpdate = function(self, dt)
135
163
                 the.bullets:collide(the.planets)
136
164
                 the.bullets:collide(the.player)
 
165
                 the.bullets:collide(the.enemies)
137
166
              end,
138
167
   onEndFrame = function(self)
139
168
                   the.interface.translate.x = the.player.x - the.app.width / 2 + the.player.width / 2