CrystalPlayer = Fill:extend{ fill = {255,0,0}, height = 32, width = 32, onStartFrame = function(self) if the.mouse:pressed() then print('hi') end local dx = love.mouse.getX() - the.app.width / 2 local dy = love.mouse.getY() - the.app.height / 2 self.acceleration.x = dx * 10 self.acceleration.y = dy * 10 --print(dx, dy) love.mouse.setPosition(the.app.width /2, the.app.height/2) end } local velLimit = 400 --local velLimit = 50 SpacePlayer = WrapTile:extend{ image = 'data/ship.png', maxVelocity = {x=velLimit,y=velLimit}, minVelocity = {x=-velLimit, y=-velLimit}, lastFired = 0, onNew = function(self) self.thrust = Tile:new{image = 'data/thrust.png'} end, onStartFrame = function(self) --- TAKE 2 local mouseVec = vector.new( love.mouse.getX() - the.app.width / 2, love.mouse.getY() - the.app.height / 2 ) self.rotation = math.atan2(mouseVec.y, mouseVec.x) if mouseVec:len2() > 64^2 then self.acceleration = vector.new(300, 0) self.acceleration:rotate_inplace(self.rotation) self.thrust.visible = true else self.acceleration = {x=0, y=0} self.thrust.visible = false if DEBUG and the.console.visible then self.velocity = {x=0, y=0} end end if the.mouse:pressed() and -- assumes left button love.timer.getTime() - self.lastFired > 0.25 and the.cursor:inTargetArea() then --print('pew') b = Bullet:new{ x = self.x + self.width / 2, y = self.y + self.height / 2, } self.lastFired = love.timer.getTime() end end, onUpdate = function(self) self.thrust.x = self.x - self.width self.thrust.y = self.y self.thrust.rotation = self.rotation end, onEndFrame = function(self) self:collide(the.rockColliders) end, onCollide = function(self, other) if other:instanceOf(RockCollider) then the.app.view:add( Boom:new { x = self.x, y = self.y, velocity = { rotation = 5 } }) self:die() self.thrust:die() the.over.visible = true the.instructions.visible = true the.app.view:updateScore() local score = love.timer.getTime() - the.app.view.gameStart if score > the.storage.data.highScore then the.storage.data.highScore = score the.storage:save() the.highScore.text = string.format( 'High Score: %d:%02d', score / 60, score % 60 ) end end end }