/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 01:44:47 UTC
  • Revision ID: josh@9ix.org-20130619014447-mtpps0g4w7aeckpg
enemy "patrol path" (pick random destination)

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'
21
22
 
22
23
util = {
23
24
   signOf = function(value)
85
86
              the.interface = Group:new()
86
87
              the.planets = Group:new()
87
88
              the.indicators = Group:new()
 
89
              the.enemies = Group:new()
88
90
 
89
91
              the.bg = Tile:new{
90
92
                 image = 'data/stars3.png',
99
101
              the.player = SpacePlayer:new{x=the.bg.width / 2, y=the.bg.height / 2}
100
102
              self:add(the.player)
101
103
              self:add(the.player.thrust)
102
 
 
103
 
              self:add(Enemy:new{x=400, y=300})
 
104
              self:add(the.player.shield)
 
105
 
 
106
              self:add(the.enemies)
 
107
 
 
108
              --local e = Enemy:new{x=400, y=300}
 
109
              local e = Enemy:new{x=the.bg.width / 2, y=the.bg.height / 2}
 
110
              the.enemies:add(e)
 
111
              self:add(e.thrust) -- why doesn't this work in Enemy.new?
 
112
              self:add(e.shield)
104
113
 
105
114
              self:add(the.bullets)
106
115
              self:add(the.indicators)
120
129
              the.cursor = Cursor:new()
121
130
              self:add(the.cursor)
122
131
 
 
132
              the.over = Text:new{
 
133
                 y = the.app.height / 2,
 
134
                 width = the.app.width,
 
135
                 align = 'center',
 
136
                 font = 25,
 
137
                 text = "Game Over",
 
138
                 visible = false
 
139
              }
 
140
              the.interface:add(the.over)
 
141
 
 
142
 
 
143
              the.instructions = Text:new{
 
144
                 y = the.app.height / 2 + 32,
 
145
                 width = the.app.width,
 
146
                 align = 'center',
 
147
                 font = 12,
 
148
                 text = "Press Enter to start a new game\nPress Q to quit",
 
149
                 visible = false
 
150
              }
 
151
              the.interface:add(the.instructions)
 
152
 
123
153
              love.mouse.setGrab(true)
124
154
              love.mouse.setVisible(false)
125
155
              love.mouse.setPosition(the.app.width / 2, the.app.height / 2)
128
158
           end,
129
159
   onUpdate = function(self, dt)
130
160
                 the.bullets:collide(the.planets)
 
161
                 the.bullets:collide(the.player)
 
162
                 the.bullets:collide(the.enemies)
131
163
              end,
132
164
   onEndFrame = function(self)
133
165
                   the.interface.translate.x = the.player.x - the.app.width / 2 + the.player.width / 2