From 938db122085d039d11c3b7ac628b00e13164797c Mon Sep 17 00:00:00 2001 From: SimonLarsen Date: Mon, 16 May 2011 22:38:16 +0200 Subject: [PATCH] Added coffee powerup inside some open trains --- gfx/sprites.png | Bin 792 -> 839 bytes gfx/trains.png | Bin 996 -> 996 bytes main.lua | 12 ++++++++++++ player.lua | 14 +++++++++++--- train.lua | 11 +++++++++++ 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/gfx/sprites.png b/gfx/sprites.png index 4f6d024fcbd8c4ffc7d3f71babbe830962fdf192..a860aab455c083e08e95ef5eb5c9183c831e90fd 100644 GIT binary patch delta 683 zcmV;c0#yB&2FC`FfCvy2AUhLuSc#E{EPsAUL_t(o!|j&6Y9lca$44OTwK7So(bswtoY>V}vwv7LBmGt@ z&1iNPKp6n5fmsA$A-mv$egJuv1`Q2rPy{8n0gR|;O29%xkAUP7P*qg`stqu=f`7uz zpzkodmjKJzsv;cK$z&_~gMqo?;?@d6CX25Ps5Dy%B6Y1Uf zhybWL;E<9vLKIUDYRf z4j?%&3Ji3~rl|#8n1C2bpj#jTm^=?SdO`$F%ejTEJ_m9(Tm3tkGvjO%8yy-O8s^_K zIst_vOHpllN4d4{?>VQ7RhnQ-#V#uBdk!k+)~Ok9@&s;0(5&xAm_Gv;8-H(j^_|;z zsPY|!@1Mn{0c`sbn0x0G@J!b)0=5y@CEyYB8umpKc*<)?0CP`!Hh$dE*dD~Ta)+>s z?Kk41ZeDlr<$z-NLi;pVuRgH7m;KeB=L860)+j?2ABqrfCvo@I1?3Kf0vPnEPqc)L_t(o!|j&AYU3~vhDRWIuL?wg^`);O zLweUi3M7|al0x$cd+Hrux!1M(8Gqnz zMeOI2vLA->J6*eB4D-Nb(p--So53 zOpEaYsas3#(bR4uKA4gmFNob1Bpx{prZTuKKrKm+uvufR#f+0$^5C|C_HObMyLoZD zF9D2W%@WHhf{j-ux6u$SJOM+P{C^mboLC4{~#%tJcf zf)SK^Uj}F%8nV#7h_@E7&Lgl4&MDv(*DnC;2y7DYtm`>!vo`Qj&mjTKzkh7m zEs6Eq@2XX-zk!dsdEd~Nofe}vtkYh-hrkZrwpV{%6ChBv%!cSy-Y!Pch@0ORc1C=( zyxdt~6n|Ft9~fau46)Vp^`u$N8kvC^tCMD@e;^(!S6Sh3as=ZD=vSrdge#nJHW>9z ziK^3Bh6ZJ>ZO?I61Vipqu4r)J@sJ@YhrGwQE~IP#{Ey)81V1PEW@v6$pRTFrtaJO* z8Aq}W=Zw+-B#x~#i{{j8@+JWLY3^GEwSd+-P6b05VNroj2cyf4PMtb+>eT62e*y2Z V96Wf;;`IOk002ovPDHLkV1hY{E(8Do diff --git a/gfx/trains.png b/gfx/trains.png index 9fe2c17abf886e31c86b121ed3462ccee3b1cd1a..11cba2d59e358ddcbd79ba7cf5f028326c7b978f 100644 GIT binary patch delta 36 scmaFD{)Byk887d4hBu#2GI6rVC2PH(=xoIyAgpLq_UHJ^jji#_0RBl11poj5 delta 36 scmaFD{)Byk8863nhBu#2GI6qme92!h(b 0 then scrn_shake = scrn_shake - dt @@ -161,10 +165,16 @@ function love.draw() love.graphics.setColor(0,0,0,255) love.graphics.print(math.floor(score),8,8) + -- Draw game over message if pl.alive == false then love.graphics.printf("you didn't make it to work\npress r to retry",0,45,WIDTH,"center") end + -- Draw pause message + if pause == true then + love.graphics.printf("paused",0,50,WIDTH,"center") + end + -- Draw coffee meter local cquad = love.graphics.newQuad(48+math.floor(coffee)*9,64,9,9,128,128) if coffee < 5 or pl.frame < 4 then @@ -193,6 +203,8 @@ function love.keypressed(key,unicode) return -- avoid unnecessary checks elseif key == 'r' or key == "return" then restart() + elseif key == 'p' then + pause = not pause elseif key == '1' then SCALE = 1 updateScale() diff --git a/player.lua b/player.lua index e847bfc..34da358 100644 --- a/player.lua +++ b/player.lua @@ -94,6 +94,10 @@ function Player:draw() end function Player:kill(status) + if self.invul == true then + return + end + scrn_shake = 0.25 if coffee >= 5 then @@ -119,8 +123,7 @@ function Player:collideWithTrain() if self.status == 0 then -- check collision with front of train if Player.collideWithPoint(self,train.x+4,train.y+10) or - Player.collideWithPoint(self,train.x+2,train.y+24) and - self.invul == false then + Player.collideWithPoint(self,train.x+2,train.y+24) then if train.type == 1 then -- hit by closed train self:kill(1) @@ -141,9 +144,14 @@ function Player:collideWithTrain() end end - if self.status == 3 then + if self.status == 3 then -- inside open train if self.x > train.x+135 then self.status = 0 + elseif train.hasCoffee == true and + self:collideWithPoint(train.x+57,train.y+20) then + train.hasCoffee = false + coffee = coffee + 1 + if coffee > 5 then coffee = 5 end end end end diff --git a/train.lua b/train.lua index ba744d9..63bf12b 100644 --- a/train.lua +++ b/train.lua @@ -5,6 +5,8 @@ normal_train_quad = love.graphics.newQuad(0,0,132,36,256,256) open_train_quad = love.graphics.newQuad(0,48,146,36,256,256) inside_train_quad = love.graphics.newQuad(0,96,146,36,256,256) +coffee_cup_quad = love.graphics.newQuad(96,0,26,23,128,128) + TRAIN_MIN_SPEED = 160 TRAIN_MAX_SPEED = 200 @@ -24,6 +26,12 @@ function Train.create(type) self.y = 56 self.type = type self.alive = true + self.hasCoffee = false + if self.type == 2 then + if math.random(2) == 1 then + self.hasCoffee = true + end + end return self end @@ -48,6 +56,9 @@ function Train:draw() elseif self.type == 2 then -- open train if pl.status == 3 then -- inside love.graphics.drawq(imgTrains,inside_train_quad,self.x-7,self.y) + if self.hasCoffee == true then + love.graphics.drawq(imgSprites,coffee_cup_quad,self.x+54,self.y+8) + end else -- outside love.graphics.drawq(imgTrains,open_train_quad,self.x-7,self.y) end