/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-16 20:20:20 UTC
  • Revision ID: josh@9ix.org-20130616202020-dcra09dhl5bdx8lc
rotate enemy ship slower

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
require 'boom'
19
19
require 'planet'
20
20
require 'trade_view'
21
 
require 'shield'
22
21
 
23
22
util = {
24
23
   signOf = function(value)
86
85
              the.interface = Group:new()
87
86
              the.planets = Group:new()
88
87
              the.indicators = Group:new()
89
 
              the.enemies = Group:new()
90
88
 
91
89
              the.bg = Tile:new{
92
90
                 image = 'data/stars3.png',
101
99
              the.player = SpacePlayer:new{x=the.bg.width / 2, y=the.bg.height / 2}
102
100
              self:add(the.player)
103
101
              self:add(the.player.thrust)
104
 
              self:add(the.player.shield)
105
 
 
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
 
102
 
 
103
              local e = Enemy:new{x=400, y=300}
 
104
              --local e = Enemy:new{x=the.bg.width / 2, y=the.bg.height / 2}
 
105
              self:add(e)
 
106
              self:add(e.thrust) -- why doesn't this work in Enemy.new?
116
107
 
117
108
              self:add(the.bullets)
118
109
              self:add(the.indicators)
119
110
              self:add(the.interface)
120
111
 
121
 
              for _ = 1, math.random(3, 6) do
 
112
              for _ = 1, math.random(6) do
122
113
                 local planet = Planet:new{
123
114
                    x = math.random(the.app.width / 2,
124
115
                                    the.bg.width - the.app.width / 2),
132
123
              the.cursor = Cursor:new()
133
124
              self:add(the.cursor)
134
125
 
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
 
 
156
126
              love.mouse.setGrab(true)
157
127
              love.mouse.setVisible(false)
158
128
              love.mouse.setPosition(the.app.width / 2, the.app.height / 2)
161
131
           end,
162
132
   onUpdate = function(self, dt)
163
133
                 the.bullets:collide(the.planets)
164
 
                 the.bullets:collide(the.player)
165
 
                 the.bullets:collide(the.enemies)
166
134
              end,
167
135
   onEndFrame = function(self)
168
136
                   the.interface.translate.x = the.player.x - the.app.width / 2 + the.player.width / 2