From 89bc084f433af0160bcbfda95e407c9e99dd3855 Mon Sep 17 00:00:00 2001 From: Aaron Mueller Date: Sun, 7 Dec 2014 17:52:10 +0100 Subject: [PATCH] solarpanel --- public/images/entities.png | Bin 3476 -> 820 bytes public/images/entitydetails.png | Bin 1621 -> 2031 bytes src/entities/solarpanel.coffee | 14 ++++++++++++++ src/game.coffee | 17 +++++++++++++---- src/hud.coffee | 3 +-- 5 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 src/entities/solarpanel.coffee diff --git a/public/images/entities.png b/public/images/entities.png index ce5715ee1c4b56837b4d39eabb7d201d1d34c237..6d018f743ff17932c32b2f79fb9d76cd2595f5c2 100644 GIT binary patch delta 777 zcmV+k1NQus8?*+HIDY^KbV*G`2i^<^5GXT3Y;KDH00PrVL_t(o!|j$&NEC4t$G^YX zX;)X-W{||#7IdKPkQ=V;>aB=w-m*)uUl+R!td~#&&=<=dGGt+2Y(_000KZZyNx=odMUpr zB3R8?Zi81-Pm$GBq*l{dPp{+gjTbP=D$X8+`^e|<|-j$jC&ItB^;(iM1SxL0*wTNq{uQQA`u#tq@og< z;1~%8p~x~4kq8DQsc`mQ3joM32&Bj|>6%8-P>6cn?n0kTaQFoQiY!CdG(o_I5fK<;G$=_}RaK1k^k8Ug z49}L93V-G_a$XSdP!!QIK5pd5a{w6ic)+63LW%cGARnZ}8$~8F!OOg5MqKHE0Z}YF z+$4vA!>rhTUbaFUj#-?s$LV-CrQ_XH+HW)bKnbi3FiQ3Vwn-mslfJ4R$n#|Xzi$pL zfu><%O~boE*9I6F1C;Jd-#>_o#&C0?3jpA1oqwn}hPC*C6Zk&`0KnND)OgN!q$OcQ zg!bp}DhB<0_ZqW00UiKuUXYHh1w3bWQ0JYYitzrGF48lqrB&daZC*SYxK$B`-iNKP zz*cOARrA1BZ02Y@@aFRQf9YyAcF+LX93n4rf10000f59&ghTmgWD z0l;*TI7e|ZE3OddDgXd@nX){&BsoQaTL>+22Uk}v9w^R9 z7b_GtVFF>AKrX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gP#2(>H^?qNB9TY{bLhH`Wmb?a(R6&n~gPvvzj&$nM@lWVH?=fBFT6@fcNADHIC- z+PntJb7HD$;cxdJp!ju4r6fWKN~Q9q+Ify3*wTm^tfi^*1f!V=3QLQ4R40XOdV6Z@ zJo9z_8;FgJ4+jRM;&ftvBodT!Ip#-3h()7Zj7I-+4nBGJU5RDk3x{zk3TkgJURCA( z$OxB%LHV|>i%sXjua6v&3!|f`!62rtqxk)lb2-YX6uX+6`Kw{@9j{kz>cM*-eZ(ol zAeYIYluESb^Gq5BH|OVBo}1&erZHD4Z5~3=viKkxr7n@+lS+ku6NLi1RTZmT=H>Qw zRt$rYSZs5GDk10z1UPl>9KNRp9TtX$n2bcIaX2=giB2IfEel^u3w8VU z;cjcg84lwOhY5y4*nn8qylV&)hlBZ4isI4|wryjXCJs%bYS%9EOG}uhi7Dmg1X;_% zl#+t3V;2e_C6vp5VB5F@0gO_Kylrou0|_ik$<)vg%}0;omlEM}0pLq3t0JwDNlDu~9+J+a-nKNhP;NYMz41-K2gQjVSt5>hev9U2CkqGtm_1wC3OKjD; z=g*&)`FtMJH0kZ_MfCUg%VaXi)YKF+Gc#g4{eS%Uaak-DX>V^w85$Zw(=>cO-?jzh lcDtz_R4Q1O^?xAee*(!BooM!9M{588002ovPDHLkV1n9z2pRwY diff --git a/src/entities/solarpanel.coffee b/src/entities/solarpanel.coffee new file mode 100644 index 0000000..f267cf8 --- /dev/null +++ b/src/entities/solarpanel.coffee @@ -0,0 +1,14 @@ +class Solarpanel + tick: (tile)-> + + sprite: -> + [0, 8*3, 8, 8] + + spritedetail: -> + [0, 16*3, 16, 16] + + isMoveable: -> + false + + spaceProvided: 0 + isDockable: true diff --git a/src/game.coffee b/src/game.coffee index 921da74..a8b4a0c 100644 --- a/src/game.coffee +++ b/src/game.coffee @@ -64,6 +64,7 @@ app.game = keyup: (event) -> switch event.key when "m" then @createMiner() + when "e" then @createSolarpanel() when "i" then app.game.hud.showBuildInfo() when "s" then @createSilo() when "c" then @cheatah() @@ -88,13 +89,21 @@ app.game = if @checkPosition(@currentSelectedTile) if @checkResource('stardust', 20, true) @currentSelectedTile.entity = new Silo - else - @speechbubble.say 'nores' + else + @speechbubble.say 'nores' else @speechbubble.say 'toofar' - else - @speechbubble.say 'nosel' +# TODO: OMG refactor this ... + createSolarpanel: -> + if @currentSelectedTile + if @checkPosition(@currentSelectedTile) + if @checkResource('notch', 10, true) + @currentSelectedTile.entity = new Solarpanel + else + @speechbubble.say 'nores' + else + @speechbubble.say 'toofar' checkResource: (type, amount, drain = false) -> if @resources[type] >= amount @resources[type] -= amount if drain diff --git a/src/hud.coffee b/src/hud.coffee index 5df8b50..1a7e96d 100644 --- a/src/hud.coffee +++ b/src/hud.coffee @@ -28,12 +28,11 @@ app.game.hud = if currentSelectedTile != null panelusage = 'tile' - if currentSelectedTile.entity panelusage = 'entity' app.layer.drawRegion app.images.entitydetails, currentSelectedTile.entity.spritedetail(), 12, 95 else - app.layer.drawRegion app.images.layerdetails, currentSelectedTile.getCurrentLayer().spritedetail, 12, 95 + app.layer.drawRegion app.images.layerdetails, currentSelectedTile.getCurrentLayer().spritedetail, 1, 95 # silo capacity usedSiloStoragePercent = Math.round((100 / app.game.availableSiloStorage()) * app.game.usedSiloStorage())