From f957d2f8bbfea87ad889570c455c991f2fb9dab1 Mon Sep 17 00:00:00 2001 From: SavanDev Date: Tue, 19 Oct 2021 00:45:43 -0300 Subject: [PATCH 1/3] Progress... --- Project.xml | 2 +- assets/data/levels/level7.json | 79 --------------------------------- assets/images/heart.png | Bin 435 -> 419 bytes misc/concepts/heart.aseprite | Bin 1516 -> 1460 bytes misc/concepts/mobile.aseprite | Bin 0 -> 926 bytes secret/images/mobile_left.png | Bin 0 -> 293 bytes secret/images/mobile_right.png | Bin 0 -> 297 bytes secret/images/mobile_up.png | Bin 0 -> 362 bytes source/Main.hx | 25 ++--------- source/SavanLogo.hx | 2 - source/misc/Input.hx | 22 +++++++++ source/mobile/AndroidPad.hx | 37 +++++++++++++++ source/states/MenuState.hx | 8 ++-- source/states/PlayState.hx | 35 ++++++--------- 14 files changed, 81 insertions(+), 129 deletions(-) delete mode 100644 assets/data/levels/level7.json create mode 100644 misc/concepts/mobile.aseprite create mode 100644 secret/images/mobile_left.png create mode 100644 secret/images/mobile_right.png create mode 100644 secret/images/mobile_up.png create mode 100644 source/mobile/AndroidPad.hx diff --git a/Project.xml b/Project.xml index b9c56b5..010c056 100644 --- a/Project.xml +++ b/Project.xml @@ -16,7 +16,7 @@ - + diff --git a/assets/data/levels/level7.json b/assets/data/levels/level7.json deleted file mode 100644 index 5b114a2..0000000 --- a/assets/data/levels/level7.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "ogmoVersion": "3.4.0", - "width": 192, - "height": 132, - "offsetX": 0, - "offsetY": 0, - "layers": [ - { - "name": "TutoLayer", - "_eid": "12402453", - "offsetX": 0, - "offsetY": 0, - "gridCellWidth": 12, - "gridCellHeight": 12, - "gridCellsX": 16, - "gridCellsY": 11, - "tileset": "Tuto", - "data": [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], - "exportMode": 0, - "arrayMode": 0 - }, - { - "name": "Default", - "_eid": "84201617", - "offsetX": 0, - "offsetY": 0, - "gridCellWidth": 12, - "gridCellHeight": 12, - "gridCellsX": 16, - "gridCellsY": 11, - "tileset": "DefaultTile", - "data": [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 4, 6, 5, -1, -1, -1, -1, 4, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2], - "exportMode": 0, - "arrayMode": 0 - }, - { - "name": "FakeFloor", - "_eid": "84953096", - "offsetX": 0, - "offsetY": 0, - "gridCellWidth": 12, - "gridCellHeight": 12, - "gridCellsX": 16, - "gridCellsY": 11, - "tileset": "DefaultTile", - "data": [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], - "exportMode": 0, - "arrayMode": 0 - }, - { - "name": "Entities", - "_eid": "84244893", - "offsetX": 0, - "offsetY": 0, - "gridCellWidth": 12, - "gridCellHeight": 12, - "gridCellsX": 16, - "gridCellsY": 11, - "entities": [ - {"name": "BPlayer", "id": 0, "_eid": "62286992", "x": 168, "y": 96, "originX": 0, "originY": 0}, - {"name": "Player", "id": 2, "_eid": "84246472", "x": 12, "y": 96, "originX": 0, "originY": 0} - ] - }, - { - "name": "Environment", - "_eid": "84269171", - "offsetX": 0, - "offsetY": 0, - "gridCellWidth": 12, - "gridCellHeight": 12, - "gridCellsX": 16, - "gridCellsY": 11, - "tileset": "BackTile", - "data": [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1], - "exportMode": 0, - "arrayMode": 0 - } - ] -} \ No newline at end of file diff --git a/assets/images/heart.png b/assets/images/heart.png index e3ef6d1894f572aa4bb7ca9a67ec87abf7330887..8220d476d0ca76e66d08fe3e1f0bbd56879decc6 100644 GIT binary patch delta 379 zcmV->0fhdu1ET|wF@If2L_t(oh3%N_5`rKQMep_&_5RP+^b~D>h*sJUP+`nCGmg4& zi_xP{z+^HI6348xX|+#)dC^Wpq}8?#a&jInY0m)gOj}d~KC&?pI639jBrMR*C;Jdx zPwU=n`OJv7a8jy#tko7@E?!<)Fr~K02r0dDE%)z|de=s)YkxD2%xJSuG$U=Du`X7F zCRl_fnAgwRhq*#hH={^eHOK*!V~NJ531o>QGcEPrn8J;sR?@P6bFNV|DQT~a6eto$ zX1w#GlZAT(9kuo~nLX$&X(>*NKyu$J^UGx6ZmXTgH|04FH4ptBnHH?I30L$n2l6iq;K^ii Za9(MP22Y4+Au|8~002ovPDHLkV1honvM~Sv delta 396 zcmV;70dxMN1G58=F@J4IL_t(oh3%N(u7e;9MvL$NoXeiV-amlY`?aM^jUk-GsHLBp z?VxT%XE-lj?HJ5>wZ(#nC^g$skfhX(fRHMslu%8cwDh!NsJ57oEw7n~XwQpRBRT}( zl!&tnN}cAoHk?aznv=F*J(uKBbh6>Thh@xV)^nT5{zVKfQg7d zM7)FLbNn@OdVjfRW;0{`Wr8xO-^yA2DA&_3b9dh1Ml-Vjr9-mSfFhkHo6Nmgo|237 zM?sVEj?9}mNoUDc1424aHkq46o+q#-@RgaTsnU@nTMabQEqUHU&!oR16G3}X<&GZp qLLx7~%zeMk7V{G}dEI#y9)AF#r6_!2i>v?u002ovP6b4+LSTZ?WyCfB diff --git a/misc/concepts/heart.aseprite b/misc/concepts/heart.aseprite index 4ed32841be056b7fcafd5855000fa6fe30247643..76ca1c96fedd9891a3771587ab9c0713b29c15ef 100644 GIT binary patch delta 461 zcmaFEy@i``%S6U{Mv0A$dl~Da7#J8>6&M&8f$%>QkOKzX4BQMAbCMGnn*V1=tiNHe z;Wq8KdYewWFVAcXGoQX&=`2@lor{h2zGl3VC|G%XQ6J;%Dw|gZSA+xF7s<`GVz`ku zJu(ky(yxz<3@JdG5s2e}7{jJ0phY07=3Y3+$zZ_YeDRI_isT#Lf+qN{32>b7gKv?F z?vys2^D`9IuXz{qtmwME8JqZyou98>jlXdD?xOc|KI^-`zr$wLCH_1H%{rgS@vPGI z$q5MwKl)iDK79DU&@1ujVFNR}T@qGmuDp7sJMQ%Q%CT+u+0MxAz%MSrz~G^OQUVkl z$d2}cI+~e*87X+!890D${{3H`QKI32z0{9(wU#sN8xw0%%#7qE7te0i>&vm@!>w<1(2DJyhDIlYejkbas&BDNfWHc)S8^mZPkkO1E_*XrVpB0p1x66{pgJC8= TLqS{Uipd9Aq&7#eOko575%7<5 delta 478 zcmdnO{f3+I%|ym}M%9gtdl~D~85kH?6@UZ~{AYsD3=F(LSTSd9|4v>80}ke!^#R8` zE(Od;nCIbGl>BajK;dTH*z)%i66Zdi&T4syRZjBS#_G^Ii(4ON{h3nPGX0cx#Vg() z4|pq|+kSX)(eg{#5}z8N$-h1_GNb@$Mj*}sVvx1-`k@}X1lw4l)M_GK({ z`*rvZ-}tfP%A(|=D@wa(PO$p2L178s?5dhq8(K~6N>9An*vZV$RnPJ|4$Wx4$>Pki zjz9w)fCg^(n8+aiUw)Mco4gvEuzOl^aC1-L&30e8yLWdyDg4PVen5?%f$#cSmoPL_ z+$P^;k=9C1NJ#j>&%)!uaO{6S%Y~mu8tMad|4-PWG`m@^FUQ`ju;lwe1_pcM(vHcA MtP-2$Sf()o00tqh>Hq)$ diff --git a/misc/concepts/mobile.aseprite b/misc/concepts/mobile.aseprite new file mode 100644 index 0000000000000000000000000000000000000000..d4b7bc40e0a9f541f3cc66704344b8d6ccc8459d GIT binary patch literal 926 zcmcJN-%C?r7{}jfbD@L6i_DTdM2Z?^yYOO5yRf>*lya3Z7g#tA^Flo<)6`XLO86rT zmm*q0xCo|HxDX@fg<5Lm@*+)eL(?Xu*1{jF>Dk-&U0VJFz1#WloaY_y^ZD+a`~HMX zm_)=ynh8flgb)p`e=CxRSd&Qc`5$W+=6imKeN)94unm`l^Nrjv&Wk#fi(KnOY}oOY zbe*&<6SZDOK#E0(yVnGk&;uaRvwl`f6RU|Aq~!+Cs8E1T+~Paa2M#rtgNEE_P%Tq~ zrd%1QF|jkNsvY1dWi{)Y*!fDO5;Pi(px4JbqwjpmcIls4l%0EXw98qWr*A z-!4sLeNpBskQgdJ>L9cfH=EeAS^EQ!l0~Ex;gAfmkckBAr}l5Jx`aLehG*5R$$6T(>S)6l}v%Km-UXTfdZ{WWf@ee_D_ zkw_tMWXrVED?jQABHgZ_)y-24pXc^>w+bi9{AxqnV@DP$?9wj{1pzm9)a{L^zi2tw zDlZv~?Fl1s*&Rt1TaNqcHPaAL+41`1A9!)2i0?1O}evKzvSPk`jj@HZacpc2E%vDD?Mom zDZ795eLs9Me_Cffqcuk93c5u}x4Y;y^MDY)NAG@90?^5$D! zrwTm!+SL`a!*)w2cl&qBJ#_ZCMxU|Mb8}pp&{#7OLUfZMKPSI6Xx}ab%u4vF7kSqo I)=%I24Fxt@UH||9 literal 0 HcmV?d00001 diff --git a/secret/images/mobile_left.png b/secret/images/mobile_left.png new file mode 100644 index 0000000000000000000000000000000000000000..a7217579e31685c68b4b576ebbf7207c6ce1c878 GIT binary patch literal 293 zcmV+=0owkFP)Px#-$_J4R9J=WnK2H7FbqW>Rd1LL&X;UCBV8IHN`f5;FSXx}hbPDW77MUr$iADF zH|GtIb2cfyZ5sfk6qEYvx&n|=GO1r{3z7lmkjZ zUgdy7kY_m{2=XomzB#DJNRA{;o2f=}Bx%}AHIgGq`^{9{4vNk>xCjb4XCf#HTm)I& zWeuyltnu_+*6pB>bTHgvIp^*?dP-g?r8|$Fl9y8I&ZAj*w=*a@Nin3oOHyqy&yv(@ r-m9dk9OO|_1Vw=mB(M;_eQx;xOD}6JM7AM>00000NkvXXu0mjf)kty} literal 0 HcmV?d00001 diff --git a/secret/images/mobile_right.png b/secret/images/mobile_right.png new file mode 100644 index 0000000000000000000000000000000000000000..250a6a06296fbc4918a4505404977582b7d32514 GIT binary patch literal 297 zcmV+^0oMMBP)Px#<4Ht8R9J=WnL7@|APfa3tK5(d&IcW5WGk8#8;6e@!z)p+be19j4HuH2mqv%RN{N@0dUT##LqeNQHg9w2aup{K(%eORNF>NIp?nLhbm|%NW(3* z3#2Iz+5ytENn3|>{~nAa971?KON}J#y?;GR^_pPx$BuPX;R9J=Wnb8fyAPhv0Dob?2uE82C*fr=^q$t5~CR`dR+)wfmpX?`!4GjP? zg!(GY0lc#`eJlVFMdoq$RQZ2Gkoc#Z@$v*j=!(6OoC^MQ2R3gTHly}Jc;!bq4xLeGqrDvfbLkZ zC&t^UYB2{ucmByRu|05Vu?v%gmDs42Fw(y?G+NM@0n;@oK2Z};LlaO#6Hr5sIBJwO zWA+B%(8Vk%PuW-a_g;xmfJV0AfB2ti^Clqg(B~~i?e9H@S+J- = SavanLogo; public function new() { super(); - addChild(new FlxGame(0, 0, _initialState, true)); + addChild(new FlxGame(_width, _height, _initialState, true)); Input.init(); - FlxG.game.setFilters([new ShaderFilter(new FlxShader())]); - FlxG.game.stage.quality = StageQuality.LOW; - FlxG.resizeWindow(_width, _height); - - // Center window on screen - var screenWidth = Capabilities.screenResolutionX; - var screenHeight = Capabilities.screenResolutionY; - trace('Width: $screenWidth - Height: $screenHeight'); - - Lib.application.window.x = Std.int((screenWidth / 2) - (_width / 2)); - Lib.application.window.y = Std.int((screenHeight / 2) - (_height / 2)); - - // FlxG.fullscreen = true; } } diff --git a/source/SavanLogo.hx b/source/SavanLogo.hx index d0413b2..f549499 100644 --- a/source/SavanLogo.hx +++ b/source/SavanLogo.hx @@ -1,9 +1,7 @@ import flixel.FlxG; import flixel.FlxSprite; -import flixel.FlxState; import flixel.text.FlxText; import flixel.util.FlxTimer; -import misc.FadeBoy; import misc.Paths; import states.MenuState; diff --git a/source/misc/Input.hx b/source/misc/Input.hx index fa0d273..011eab9 100644 --- a/source/misc/Input.hx +++ b/source/misc/Input.hx @@ -1,7 +1,11 @@ package misc; import flixel.FlxG; +#if mobile +import flixel.input.android.FlxAndroidKey; +#else import flixel.input.keyboard.FlxKey; +#end class Input { @@ -14,6 +18,7 @@ class Input public static var SELECT:Bool; public static var BACK:Bool; public static var SHOOT:Bool; + public static var PAUSE:Bool; // Controles alternos public static var UP_ALT:Bool; @@ -24,17 +29,31 @@ class Input public static var SELECT_ALT:Bool; public static var BACK_ALT:Bool; public static var SHOOT_ALT:Bool; + public static var PAUSE_ALT:Bool; // Detección de Gamepad public static var isGamepadConnected:Bool; public static function init() { + #if mobile + FlxG.android.preventDefaultKeys = [FlxAndroidKey.BACK]; + #else + FlxG.sound.volumeDownKeys = [NUMPADMINUS]; + FlxG.sound.volumeUpKeys = [NUMPADPLUS]; + FlxG.sound.muteKeys = [NUMPADZERO]; + #end trace("Input initialized!"); } public static function update() { + #if mobile + var firstTouch = FlxG.touches.getFirst(); + SELECT = firstTouch != null ? firstTouch.justPressed : false; + PAUSE = FlxG.android.justPressed.BACK; + BACK = FlxG.android.justPressed.BACK; + #else UP = FlxG.keys.justPressed.UP; DOWN = FlxG.keys.justPressed.DOWN; LEFT = FlxG.keys.pressed.LEFT; @@ -43,6 +62,8 @@ class Input SELECT = FlxG.keys.justPressed.ENTER; BACK = FlxG.keys.justPressed.ESCAPE; SHOOT = FlxG.keys.justPressed.Z; + PAUSE = FlxG.keys.justPressed.ENTER; + #end #if desktop // Solamente tengo un humilde joystick genérico, así que trataré mostrar lo mejor que pueda los controles. @@ -59,6 +80,7 @@ class Input SELECT_ALT = gamepad.justPressed.A; BACK_ALT = gamepad.justPressed.BACK; // Xbox -> Back | Play -> Select SHOOT_ALT = gamepad.justPressed.B; + PAUSE_ALT = gamepad.justPressed.START; } else isGamepadConnected = false; diff --git a/source/mobile/AndroidPad.hx b/source/mobile/AndroidPad.hx new file mode 100644 index 0000000..99fe671 --- /dev/null +++ b/source/mobile/AndroidPad.hx @@ -0,0 +1,37 @@ +package mobile; + +import flixel.group.FlxGroup.FlxTypedGroup; +import flixel.ui.FlxButton; +import misc.Input; +import misc.Paths; + +class AndroidPad extends FlxTypedGroup +{ + var btnLeft:FlxButton; + var btnRight:FlxButton; + var btnJump:FlxButton; + var btnPunch:FlxButton; + + public function new() + { + super(); + + btnLeft = new FlxButton(12, 120); + btnLeft.onDown.callback = () -> Input.LEFT = true; + btnLeft.onOut.callback = () -> Input.LEFT = false; + btnLeft.loadGraphic(Paths.getImage("mobile_left", true), true, 24, 24); + add(btnLeft); + + btnRight = new FlxButton(48, 120); + btnRight.onDown.callback = () -> Input.RIGHT = true; + btnRight.onOut.callback = () -> Input.RIGHT = false; + btnRight.loadGraphic(Paths.getImage("mobile_right", true), true, 24, 24); + add(btnRight); + + btnJump = new FlxButton(204, 120); + btnJump.onDown.callback = () -> Input.JUMP = true; + btnJump.onOut.callback = () -> Input.JUMP = false; + btnJump.loadGraphic(Paths.getImage("mobile_up", true), true, 24, 24); + add(btnJump); + } +} diff --git a/source/states/MenuState.hx b/source/states/MenuState.hx index 45cfc0f..7fcdde5 100644 --- a/source/states/MenuState.hx +++ b/source/states/MenuState.hx @@ -1,5 +1,6 @@ package states; +import flixel.FlxCamera; import flixel.FlxG; import flixel.FlxObject; import flixel.FlxSprite; @@ -34,10 +35,11 @@ class MenuState extends BaseState override public function create() { super.create(); - FlxG.camera.pixelPerfectRender = Game.PIXEL_PERFECT; - bgColor = 0xff0163c6; - FlxG.timeScale = 1.03; + var gameCamera = new FlxCamera(24, 0, Game.getGameWidth(), Game.getGameHeight()); + gameCamera.pixelPerfectRender = Game.PIXEL_PERFECT; + gameCamera.bgColor = 0xff0163c6; + FlxG.cameras.reset(gameCamera); var map = new FlxOgmo3Loader(Paths.getOgmoData(), 'assets/data/levels/level0.json'); diff --git a/source/states/PlayState.hx b/source/states/PlayState.hx index 5060618..d50fd80 100644 --- a/source/states/PlayState.hx +++ b/source/states/PlayState.hx @@ -19,6 +19,7 @@ import lime.system.System; import misc.Input; import misc.Paths; import misc.ScanLines; +import mobile.AndroidPad; import objects.Artefact; import objects.Bullet; import objects.Heart; @@ -123,13 +124,13 @@ class PlayState extends BaseState { super.create(); - if (LEVEL < 0 || LEVEL > 7) - LEVEL = 7; + if (LEVEL < 0 || LEVEL > 6) + LEVEL = 1; - FlxG.camera.pixelPerfectRender = Game.PIXEL_PERFECT; - bgColor = !BSIDE ? 0xff0163c6 : FlxColor.BLACK; - - persistentDraw = persistentUpdate = true; + var gameCamera = new FlxCamera(24, 0, Game.getGameWidth(), Game.getGameHeight()); + gameCamera.pixelPerfectRender = Game.PIXEL_PERFECT; + gameCamera.bgColor = !BSIDE ? 0xff0163c6 : FlxColor.BLACK; + FlxG.cameras.reset(gameCamera); var glitchedEffect = new FlxGlitchEffect(2); var uiCamera = new FlxCamera(0, 0, FlxG.width, FlxG.height); @@ -173,6 +174,7 @@ class PlayState extends BaseState add(messages); var screen = new ScanLines(); + screen.x = FlxG.camera.x; add(screen); var uiBorder = new FlxSprite(0, Game.getGameHeight()); @@ -267,6 +269,9 @@ class PlayState extends BaseState add(tutoLayer); }; + var pad = new AndroidPad(); + add(pad); + // HUD FlxG.cameras.add(uiCamera, false); uiBorder.cameras = [uiCamera]; @@ -275,21 +280,7 @@ class PlayState extends BaseState uiText.cameras = [uiCamera]; uiStrawCount.cameras = [uiCamera]; screen.cameras = [uiCamera]; - - // Hacker time? - if (LEVEL == 7) - { - FlxG.sound.music.stop(); - var spriteCursed = new FlxSprite().loadGraphic(Paths.getImage("cursedever")); - new FlxTimer().start(10, (_) -> - { - player.kill(); - add(spriteCursed); - uiText.text = "DIRTY HACKER"; - uiText.color = FlxColor.RED; - new FlxTimer().start(2, (_) -> System.exit(0)); - }); - } + pad.cameras = [uiCamera]; } function playerInteraction() @@ -432,7 +423,7 @@ class PlayState extends BaseState if (Player.HAS_GUN && (Input.SHOOT || Input.SHOOT_ALT)) bullet.shoot(); - #if debug + #if (debug && desktop) if (FlxG.keys.justPressed.L) { if (BSIDE) From 587160bd7facc3dc70604feddeb064a33c303bfd Mon Sep 17 00:00:00 2001 From: SavanDev Date: Wed, 3 Nov 2021 01:36:52 -0300 Subject: [PATCH 2/3] Android port! --- .gitattributes | 3 ++ Project.xml | 4 +-- assets/data/levels/level5.json | 2 +- misc/concepts/mobile.aseprite | Bin 926 -> 1205 bytes secret/images/mobile_shot.png | Bin 0 -> 448 bytes secret/images/mobile_up.png | Bin 362 -> 450 bytes source/Game.hx | 2 ++ source/misc/ScanLines.hx | 23 ++++++++++-- source/mobile/AndroidPad.hx | 21 ++++++++++- source/states/EndingState.hx | 12 ++++--- source/states/FinishState.hx | 14 ++++++-- source/states/MenuState.hx | 22 +++++++++--- source/states/PlayState.hx | 62 ++++++++++++++++++++++----------- 13 files changed, 126 insertions(+), 39 deletions(-) create mode 100644 .gitattributes create mode 100644 secret/images/mobile_shot.png diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..5dc46e6 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +* text=auto eol=lf +*.{cmd,[cC][mM][dD]} text eol=crlf +*.{bat,[bB][aA][tT]} text eol=crlf \ No newline at end of file diff --git a/Project.xml b/Project.xml index 010c056..f53031b 100644 --- a/Project.xml +++ b/Project.xml @@ -91,6 +91,6 @@ - - + + diff --git a/assets/data/levels/level5.json b/assets/data/levels/level5.json index ffea5eb..768972f 100644 --- a/assets/data/levels/level5.json +++ b/assets/data/levels/level5.json @@ -29,7 +29,7 @@ "gridCellsX": 16, "gridCellsY": 11, "tileset": "DefaultTile", - "data": [9, -1, -1, 7, 8, 10, 14, 14, 14, 14, 15, -1, -1, -1, 7, 8, 9, -1, -1, 7, 10, 15, -1, -1, -1, -1, -1, -1, -1, 1, 17, 8, 16, 2, 2, 17, 9, -1, -1, -1, -1, -1, -1, -1, -1, 7, 8, 8, 14, 14, 14, 11, 9, -1, -1, -1, 1, 2, 2, 3, -1, 7, 8, 8, -1, -1, -1, 7, 9, -1, -1, -1, 7, 8, 8, 9, -1, 7, 8, 8, -1, -1, -1, 13, 12, 5, -1, -1, 13, 14, 11, 9, -1, 7, 8, 8, 2, 3, -1, -1, -1, -1, -1, -1, -1, -1, 7, 9, -1, 7, 10, 14, 8, 9, -1, -1, -1, -1, -1, -1, -1, -1, 13, 15, -1, 13, 15, -1, 8, 16, 2, 2, 2, 3, -1, 1, 3, -1, -1, -1, -1, -1, -1, -1, 8, 8, 8, 8, 8, 16, -1, 17, 9, -1, -1, -1, -1, -1, -1, -1, 8, 8, 8, 8, 8, 8, -1, 8, 16, 2, 2, 2, 2, 2, 2, 2], + "data": [9, -1, -1, 7, 8, 10, 14, 14, 14, 14, 15, -1, -1, -1, 7, 8, 9, -1, -1, 7, 10, 15, -1, -1, -1, -1, -1, -1, -1, 1, 17, 8, 16, 2, 2, 17, 9, -1, -1, -1, -1, -1, -1, -1, -1, 7, 8, 8, 14, 14, 14, 11, 9, -1, -1, -1, -1, 1, 2, 3, -1, 7, 8, 8, -1, -1, -1, 7, 9, -1, -1, -1, 1, 17, 8, 9, -1, 7, 8, 8, -1, -1, -1, 13, 12, 5, -1, -1, 13, 14, 11, 9, -1, 7, 8, 8, 2, 3, -1, -1, -1, -1, -1, -1, -1, -1, 7, 9, -1, 7, 10, 14, 8, 9, -1, -1, -1, -1, -1, -1, -1, -1, 13, 15, -1, 13, 15, -1, 8, 16, 2, 2, 2, 3, -1, 1, 3, -1, -1, -1, -1, -1, -1, -1, 8, 8, 8, 8, 8, 16, -1, 17, 9, -1, -1, -1, -1, -1, -1, -1, 8, 8, 8, 8, 8, 8, -1, 8, 16, 2, 2, 2, 2, 2, 2, 2], "exportMode": 0, "arrayMode": 0 }, diff --git a/misc/concepts/mobile.aseprite b/misc/concepts/mobile.aseprite index d4b7bc40e0a9f541f3cc66704344b8d6ccc8459d..17c935df8b92457000903d3166fae25c3e201baf 100644 GIT binary patch delta 597 zcmbQozLk?{E6YTtIwn(=jZJ$Q>&uuJ7+4h;7282$s<5O9N`fuUl~+grDD?-&R; z1cpuD72|O0hSk&f$cTxHmOSKs&hUBrM9&mGq0@ey&1Y?-PTZ_Jv)1$1qBXzgowM?c zpHh1Na-{mp?oIEitzN6t241W6PoKL)|5Vi5hx0rC&C*o^N=@5cQ5`j>{^PT`3d_IR znaySU-Y8T1vfJXeq?t1@n&EzkxH{aghZ~BXAqM>#Df?HxXo9DN0b$x&P+s_&&wYzV!H+)d{ z3oYcou{!^CR{x+&zm!O z%f)|HJ(j8erSv#5dgn2}vW>rPGJl)8Q~Zr>{_8axKdVi9@p>uHA?3GzU7N9Q!O!1^ zFF*IaHvPYRk>m95pO>GXvqb;B`HmI0&+p%7d-->z*yHD?_2<5SRv8if`TOUcvT{4u zF97OZ_MYFn+9oT$@p)qI-T!}Yy?@?O%L?>u>EC~^PcC7rHI=vE&(9^GevXeCT>$5OM=AgS delta 371 zcmV-(0gV2&37!W6o&%8regYl?v4Xt;e_sIr00kfb01N^u_jh#mv|q|u0BWY(D$zWv-QC{VD1IsC0jQaFt7P=Nc5gLV?bnJv z@C!P8a;v0QW0hOaT5`~@&RhUBpWP~H)mgRAjaue;gY^TsS>jg7TdiRG9IYS7&G!4l zRy|E3`Ni);P;lgazEyLSD1LFjVF5~xz5jZv$^ASegZIme`kU+raq}&VUmN;?+zdULjo=pme&HAR;qI4n R%<~582Xf=OZ-1her~vdsQW}Yuf(f=^U~B&R3-t|NUae!SIzsLcr}ng8>s; z%iX9w9$6m89_ZYk^h36Jb4_;ACEL>v)Aujqrmwfmf|U$={6t{S%lA6dC# zzwPmkSu8oz`gWB3pZ2>~O|-D{R&6?`J(&J)U30FHF_DFbLpi}AVsk^frTE*U#s9j0 z72mk%yO-&+|Kap$jA8n^YS)9=dCuhBYKW|@ji{}SiZ#zGleM`1_=BD5`_h_gTht=to4y8eeCz1H0QQlf zfkICMW8z_!GYqHO8K?C>VmO_%pn-9U^gAnqa}lw%A>r3$)<8TDReEs8-WA;2#lJrM cw#aV(%3O!t>z*v{1V#yir>mdKI;Vst002YCaR2}S literal 0 HcmV?d00001 diff --git a/secret/images/mobile_up.png b/secret/images/mobile_up.png index 46d80581c33c309780fc75e43787840347449216..25366a24edfe192feeca300f20e91c38c92ca4aa 100644 GIT binary patch delta 411 zcmV;M0c8H_0>T53F@JnXL_t(oh3%QatpYI&L}$OKf;MR2pP&tTSjynn@ax#UPyubw zMmRtqVx7d}#3yzxNN62to`OAV1^@w`I$m6l5C6Ze=WhT2`?JsK^Xc(@CidH}s>3;x8&A8_VKx)PvHvm#I)@}fnQ!FR1l}MD=O5`c)N<;^!=a`q&am-6< z8S{BS?0Xmsi+v9xVX^OFIao_T)+8P4YM`u1I@VP{S(9|E`vjFw(kv+L4T=U?P|6z= z4YHv0Hz+DK?9qc#!wx+tHSE)aQhn(J1AqbR-#$g%0ThOzl3RUx#rgmM002ovPDHLk FV1m+4u~q;8 delta 322 zcmV-I0logh1L^{hF@GdUL_t(oh3%Qq4Z|P|M2{*r=0Qf1VreHy~01`jO1K#G@xj_ zkCNJd3&sP90#r(PWD#or5)c+r6HqPD5k;u|Yakd%RX|LFXMc)N`!fJq-d=0J#cEV3zLME*r=5-(!Vq`TF{sQ(={kQQ4>%@ z6Hr4FP(zP6YLqr(_6Fe4#VjdL*;n}YUWrhEMz-O9_@8O>CLr(7=PgF&cEu&66_V1mf*E_g9C=-xkMO@*(7U%^ var btnLeft:FlxButton; var btnRight:FlxButton; var btnJump:FlxButton; - var btnPunch:FlxButton; + var btnShot:FlxButton; public function new() { @@ -33,5 +34,23 @@ class AndroidPad extends FlxTypedGroup btnJump.onOut.callback = () -> Input.JUMP = false; btnJump.loadGraphic(Paths.getImage("mobile_up", true), true, 24, 24); add(btnJump); + + btnShot = new FlxButton(80, 16); + btnShot.onDown.callback = () -> Input.SHOOT = true; + btnShot.onOut.callback = () -> Input.SHOOT = false; + btnShot.loadGraphic(Paths.getImage("mobile_shot", true), true, 80, 32); + } + + public function enableShotButton() + { + add(btnShot); + } + + public function setCamera(_camera:FlxCamera) + { + btnLeft.cameras = [_camera]; + btnRight.cameras = [_camera]; + btnJump.cameras = [_camera]; + btnShot.cameras = [_camera]; } } diff --git a/source/states/EndingState.hx b/source/states/EndingState.hx index f432491..241de2b 100644 --- a/source/states/EndingState.hx +++ b/source/states/EndingState.hx @@ -32,9 +32,13 @@ class EndingState extends BaseState override public function create() { super.create(); + var gameCamera = new FlxCamera(Game.GAME_X, 0, Game.getGameWidth(), Game.getGameHeight()); + gameCamera.pixelPerfectRender = Game.PIXEL_PERFECT; + FlxG.cameras.reset(gameCamera); + var uiCamera = new FlxCamera(0, 0, FlxG.width, FlxG.height); uiCamera.bgColor = FlxColor.TRANSPARENT; - FlxG.camera.pixelPerfectRender = Game.PIXEL_PERFECT; + uiCamera.pixelPerfectRender = Game.PIXEL_PERFECT; if (ending == 0) { @@ -84,7 +88,8 @@ class EndingState extends BaseState } } - var screen = new ScanLines(false); + var screen = new ScanLines(); + screen.cameras = [uiCamera]; add(screen); uiText = new FlxText(5, 132 + 5, FlxG.width - 10); @@ -92,7 +97,6 @@ class EndingState extends BaseState add(uiText); FlxG.cameras.add(uiCamera, false); - screen.cameras = [uiCamera]; uiText.cameras = [uiCamera]; } @@ -102,7 +106,7 @@ class EndingState extends BaseState new FlxTimer().start(3, (_) -> { uiText.color = FlxColor.RED; - uiText.text = PlayState.POINTS < 6 ? "Maybe... collecting 6 strawberries?" : "Next time... SHOOT HIM!"; + uiText.text = PlayState.POINTS < 6 ? "Maybe... getting 6 of them?" : "Next time... SHOOT HIM!"; new FlxTimer().start(3, (_) -> System.exit(0)); }); animEnding.kill(); diff --git a/source/states/FinishState.hx b/source/states/FinishState.hx index b0b5119..3e4f206 100644 --- a/source/states/FinishState.hx +++ b/source/states/FinishState.hx @@ -1,5 +1,6 @@ package states; +import flixel.FlxCamera; import flixel.FlxG; import flixel.text.FlxText; import flixel.util.FlxColor; @@ -14,18 +15,23 @@ class FinishState extends BaseState "Game made by SavanDev", "Created in HaxeFlixel", "Music made by\nJoshua McLean", - "This game was made for\n#MejorandoAndo of May", - "Thanks for playing!\n\nPress ESCAPE to exit the game" + "Thanks for playing!\nSee you next time ;)" ]; var actualText:Int = 0; override public function create() { super.create(); - FlxG.camera.pixelPerfectRender = Game.PIXEL_PERFECT; + var gameCamera = new FlxCamera(Game.GAME_X, 0, Game.getGameWidth(), Game.getGameHeight()); + FlxG.cameras.reset(gameCamera); + + var uiCamera = new FlxCamera(0, 0, FlxG.width, FlxG.height); + uiCamera.bgColor = FlxColor.TRANSPARENT; + FlxG.cameras.add(uiCamera, false); var finishText = new FlxText(0, 0, 150, texts[actualText]); finishText.alignment = CENTER; + finishText.cameras = [uiCamera]; finishText.screenCenter(); add(finishText); @@ -38,6 +44,8 @@ class FinishState extends BaseState { if (actualText < texts.length - 1) new FlxTimer().start(3, (_) -> fade.fadeOut(FlxColor.BLACK)); + else + new FlxTimer().start(3, (_) -> System.exit(0)); }); fade.setCallbackOut(() -> { diff --git a/source/states/MenuState.hx b/source/states/MenuState.hx index 7fcdde5..1b68fb5 100644 --- a/source/states/MenuState.hx +++ b/source/states/MenuState.hx @@ -36,11 +36,16 @@ class MenuState extends BaseState { super.create(); - var gameCamera = new FlxCamera(24, 0, Game.getGameWidth(), Game.getGameHeight()); + var gameCamera = new FlxCamera(Game.GAME_X, 0, Game.getGameWidth(), Game.getGameHeight()); gameCamera.pixelPerfectRender = Game.PIXEL_PERFECT; gameCamera.bgColor = 0xff0163c6; FlxG.cameras.reset(gameCamera); + var hudCamera = new FlxCamera(0, 0, FlxG.width, FlxG.height); + hudCamera.pixelPerfectRender = Game.PIXEL_PERFECT; + hudCamera.bgColor = FlxColor.TRANSPARENT; + FlxG.cameras.add(hudCamera, false); + var map = new FlxOgmo3Loader(Paths.getOgmoData(), 'assets/data/levels/level0.json'); var backWalls = map.loadTilemap(Paths.getImage("environment"), "Environment"); @@ -76,17 +81,24 @@ class MenuState extends BaseState add(glitchSprite); uiName = new FlxText(0, 30, "COLORLESS", 16); + // uiName.cameras = [hudCamera]; uiName.screenCenter(X); + uiName.x -= gameCamera.x; add(uiName); var screen = new ScanLines(); + screen.cameras = [hudCamera]; add(screen); - var uiBorder = new FlxSprite(0, Game.getGameHeight()); - uiBorder.makeGraphic(FlxG.width, FlxG.height - Std.int(uiBorder.y), FlxColor.BLACK); - add(uiBorder); + var startTitle:String; + #if mobile + startTitle = "Touch to start!"; + #else + startTitle = "Press ENTER to start!"; + #end - uiText = new FlxText(5, Game.getGameHeight() + 5, FlxG.width - 10, "Press ENTER to start!"); + uiText = new FlxText(5, Game.getGameHeight() + 5, FlxG.width - 10, startTitle); + uiText.cameras = [hudCamera]; uiText.alignment = CENTER; add(uiText); diff --git a/source/states/PlayState.hx b/source/states/PlayState.hx index d50fd80..999cecf 100644 --- a/source/states/PlayState.hx +++ b/source/states/PlayState.hx @@ -127,15 +127,14 @@ class PlayState extends BaseState if (LEVEL < 0 || LEVEL > 6) LEVEL = 1; - var gameCamera = new FlxCamera(24, 0, Game.getGameWidth(), Game.getGameHeight()); - gameCamera.pixelPerfectRender = Game.PIXEL_PERFECT; + var gameCamera = new FlxCamera(Game.GAME_X, 0, Game.getGameWidth(), Game.getGameHeight()); gameCamera.bgColor = !BSIDE ? 0xff0163c6 : FlxColor.BLACK; FlxG.cameras.reset(gameCamera); - var glitchedEffect = new FlxGlitchEffect(2); var uiCamera = new FlxCamera(0, 0, FlxG.width, FlxG.height); uiCamera.bgColor = FlxColor.TRANSPARENT; - uiCamera.pixelPerfectRender = Game.PIXEL_PERFECT; + + persistentDraw = persistentUpdate = true; var map = new FlxOgmo3Loader(Paths.getOgmoData(), 'assets/data/levels/level$LEVEL.json'); initPos = new FlxPoint(); @@ -151,10 +150,12 @@ class PlayState extends BaseState walls.setTileProperties(1, FlxObject.ANY); add(walls); + #if !mobile var tutoLayer = map.loadTilemap(Paths.getImage("tuto", true), "TutoLayer"); FlxTween.num(tutoLayer.y, tutoLayer.y + 3, 1, {type: PINGPONG}, (v:Float) -> tutoLayer.y = v); if (!BSIDE) add(tutoLayer); + #end if (!BSIDE) { @@ -174,20 +175,20 @@ class PlayState extends BaseState add(messages); var screen = new ScanLines(); - screen.x = FlxG.camera.x; add(screen); - var uiBorder = new FlxSprite(0, Game.getGameHeight()); - uiBorder.makeGraphic(FlxG.width, FlxG.height - Std.int(uiBorder.y), FlxColor.BLACK); - add(uiBorder); - var uiStrawberry = new Heart(5, Game.getGameHeight() + 5); if (!BSIDE) add(uiStrawberry); else { - var uiStrawGlitched = new FlxEffectSprite(uiStrawberry, [glitchedEffect]); + var glitchedHeart = new FlxGlitchEffect(1); + var uiStrawGlitched = new FlxEffectSprite(uiStrawberry, [glitchedHeart]); + #if mobile + uiStrawGlitched.setPosition(6, 6); + #else uiStrawGlitched.setPosition(5, Game.getGameHeight() + 5); + #end uiStrawGlitched.cameras = [uiCamera]; add(uiStrawGlitched); } @@ -195,15 +196,25 @@ class PlayState extends BaseState uiStrawCount = new FlxText(17, Game.getGameHeight() + 5, 0, "x 0"); add(uiStrawCount); - var uiText = new FlxText(5, Game.getGameHeight() + 5, FlxG.width - 10, !BSIDE ? levelText[LEVEL] : bSideText[LEVEL]); + var uiText = new FlxText(Game.GAME_X, Game.getGameHeight() + 5, Game.getGameWidth(), !BSIDE ? levelText[LEVEL] : bSideText[LEVEL]); uiText.alignment = RIGHT; add(uiText); + #if mobile + uiStrawberry.setPosition(6, 6); + uiStrawCount.setPosition(2, 20); + uiText.alignment = CENTER; + uiText.screenCenter(X); + #end + if (BSIDE) { + var glitchedCursed = new FlxGlitchEffect(2); var spriteCursed = new FlxSprite().loadGraphic(Paths.getImage("cursed", true)); - var cursed = new FlxEffectSprite(spriteCursed, [glitchedEffect]); + var cursed = new FlxEffectSprite(spriteCursed, [glitchedCursed]); cursed.visible = false; + cursed.x = Game.GAME_X; + cursed.cameras = [uiCamera]; add(cursed); if (finishPlayer == null) @@ -222,6 +233,7 @@ class PlayState extends BaseState } else { + cursed.alpha = 0; cursed.visible = true; new FlxTimer().start(.1, (_) -> cursed.alpha = Math.max(0, .5 - (player.x / FlxG.width)), 0); } @@ -230,6 +242,14 @@ class PlayState extends BaseState bullet = new Bullet(player); add(bullet); + #if mobile + // Android controls! + var pad = new AndroidPad(); + pad.cameras = [uiCamera]; + pad.setCamera(uiCamera); + add(pad); + #end + // Music if (FlxG.sound.music == null || !FlxG.sound.music.playing) if (!BSIDE) @@ -266,27 +286,27 @@ class PlayState extends BaseState hasGun = () -> { Player.HAS_GUN = true; + #if !mobile add(tutoLayer); + #else + pad.enableShotButton(); + #end }; - var pad = new AndroidPad(); - add(pad); - // HUD FlxG.cameras.add(uiCamera, false); - uiBorder.cameras = [uiCamera]; uiCamera.cameras = [uiCamera]; uiStrawberry.cameras = [uiCamera]; uiText.cameras = [uiCamera]; uiStrawCount.cameras = [uiCamera]; + screen.cameras = [uiCamera]; - pad.cameras = [uiCamera]; } function playerInteraction() { // Pasar de nivel por derecha e izquierda - if ((player.x > FlxG.width) || (player.x < -player.width)) + if ((player.x > Game.getGameWidth()) || (player.x < -player.width)) { player.kill(); player.visible = false; @@ -303,8 +323,8 @@ class PlayState extends BaseState player.x = 0; // Pared mágica por derecha - if ((BSIDE || player.y <= 0) && player.x > (FlxG.width - player.width)) - player.x = FlxG.width - player.width; + if ((BSIDE || player.y <= 0) && player.x > (Game.getGameWidth() - player.width)) + player.x = Game.getGameWidth() - player.width; // Te caíste bro if (player.y > FlxG.height && !respawn) @@ -417,7 +437,7 @@ class PlayState extends BaseState if (player.alive) playerInteraction(); - if ((Input.BACK || Input.BACK_ALT) && LEVEL != 7) + if (Input.BACK || Input.BACK_ALT) System.exit(0); if (Player.HAS_GUN && (Input.SHOOT || Input.SHOOT_ALT)) From c98dc8c0bb1694f164151dac088cd0e05ea1a376 Mon Sep 17 00:00:00 2001 From: SavanDev Date: Wed, 17 Nov 2021 22:36:02 -0300 Subject: [PATCH 3/3] Small changes --- Project.xml | 6 ++-- source/Main.hx | 5 +++ source/SavanLogo.hx | 5 +++ source/misc/FPSMem.hx | 65 ++++++++++++++++++++++++++++++++++++++ source/states/PlayState.hx | 5 +-- 5 files changed, 81 insertions(+), 5 deletions(-) create mode 100644 source/misc/FPSMem.hx diff --git a/Project.xml b/Project.xml index f53031b..98f3e17 100644 --- a/Project.xml +++ b/Project.xml @@ -22,7 +22,7 @@ - + @@ -63,10 +63,10 @@ - + - + diff --git a/source/Main.hx b/source/Main.hx index 2f6b426..fa9550f 100644 --- a/source/Main.hx +++ b/source/Main.hx @@ -2,6 +2,7 @@ package; import flixel.FlxGame; import flixel.FlxState; +import misc.FPSMem; import misc.Input; import openfl.display.Sprite; @@ -16,5 +17,9 @@ class Main extends Sprite super(); addChild(new FlxGame(_width, _height, _initialState, true)); Input.init(); + + #if debug + addChild(new FPSMem(5, 5, 0xFFFFFF)); + #end } } diff --git a/source/SavanLogo.hx b/source/SavanLogo.hx index f549499..016f998 100644 --- a/source/SavanLogo.hx +++ b/source/SavanLogo.hx @@ -24,6 +24,11 @@ class SavanLogo extends BaseState logoText.y += 20; add(logoText); + #if desktop + FlxG.mouse.visible = false; + FlxG.mouse.enabled = false; + #end + new FlxTimer().start(3, (_) -> FlxG.switchState(new MenuState())); } } diff --git a/source/misc/FPSMem.hx b/source/misc/FPSMem.hx new file mode 100644 index 0000000..42631e2 --- /dev/null +++ b/source/misc/FPSMem.hx @@ -0,0 +1,65 @@ +package misc; + +import haxe.Timer; +import openfl.display.FPS; +import openfl.events.Event; +import openfl.system.System; +import openfl.text.TextField; +import openfl.text.TextFormat; + +/** + + * FPS class extension to display memory usage. + + * @author Kirill Poletaev + + */ +class FPSMem extends TextField +{ + private var times:Array; + + private var memPeak:Float = 0; + + public function new(inX:Float = 10.0, inY:Float = 10.0, inCol:Int = 0x000000) + { + super(); + + x = inX; + + y = inY; + + selectable = false; + + defaultTextFormat = new TextFormat("_sans", 12, inCol); + + text = "FPS: "; + + times = []; + + addEventListener(Event.ENTER_FRAME, onEnter); + + width = 150; + + height = 70; + } + + private function onEnter(_) + { + var now = Timer.stamp(); + + times.push(now); + + while (times[0] < now - 1) + times.shift(); + + var mem:Float = Math.round(System.totalMemory / 1024 / 1024 * 100) / 100; + + if (mem > memPeak) + memPeak = mem; + + if (visible) + { + text = "FPS: " + times.length + "\nMEM: " + mem + " MB\nMEM peak: " + memPeak + " MB"; + } + } +} diff --git a/source/states/PlayState.hx b/source/states/PlayState.hx index 999cecf..d692221 100644 --- a/source/states/PlayState.hx +++ b/source/states/PlayState.hx @@ -131,7 +131,7 @@ class PlayState extends BaseState gameCamera.bgColor = !BSIDE ? 0xff0163c6 : FlxColor.BLACK; FlxG.cameras.reset(gameCamera); - var uiCamera = new FlxCamera(0, 0, FlxG.width, FlxG.height); + var uiCamera = new FlxCamera(); uiCamera.bgColor = FlxColor.TRANSPARENT; persistentDraw = persistentUpdate = true; @@ -196,7 +196,8 @@ class PlayState extends BaseState uiStrawCount = new FlxText(17, Game.getGameHeight() + 5, 0, "x 0"); add(uiStrawCount); - var uiText = new FlxText(Game.GAME_X, Game.getGameHeight() + 5, Game.getGameWidth(), !BSIDE ? levelText[LEVEL] : bSideText[LEVEL]); + var uiXPos = uiStrawCount.x + uiStrawCount.width; + var uiText = new FlxText(uiXPos, Game.getGameHeight() + 5, FlxG.width - uiXPos - 5, !BSIDE ? levelText[LEVEL] : bSideText[LEVEL]); uiText.alignment = RIGHT; add(uiText);