Skip to content

Commit 275d4f6

Browse files
bigger FlxLightPuzzle (#328)
1 parent eb88bde commit 275d4f6

7 files changed

Lines changed: 50 additions & 39 deletions

File tree

Arcade/FlxLightPuzzle/Project.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<!-- ____________________________ Window Settings ___________________________ -->
1717

1818
<!--These window settings apply to all targets-->
19-
<window width="512" height="288" fps="60" background="#000000" hardware="true" vsync="false" />
19+
<window width="1024" height="576" fps="60" background="#000000" hardware="true" vsync="false" />
2020

2121
<!--HTML5-specific-->
2222
<window if="html5" resizable="false" />

Arcade/FlxLightPuzzle/source/Main.hx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package;
22

3+
import lime.app.Application;
34
import flixel.FlxGame;
45
import openfl.display.Sprite;
56

@@ -8,6 +9,7 @@ class Main extends Sprite
89
public function new()
910
{
1011
super();
12+
1113
addChild(new FlxGame(0, 0, PlayState));
1214
}
1315
}

Arcade/FlxLightPuzzle/source/MenuState.hx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,30 @@ class MenuState extends FlxSubState
2020

2121
override public function create():Void
2222
{
23-
title = new FlxText(50, 10, 512 - 50, "FlxLightPuzzle", 20);
23+
title = new FlxText(50 * 2, 10 * 2, (512 - 50) * 2, "FlxLightPuzzle", 20 * 2);
2424
title.color = FlxColor.WHITE;
2525
title.alignment = "center";
2626
add(title);
2727

2828
// barsHorizontal.png from Kenney.nl were colored to make them more appropriate for this game
2929

30-
playRYB = new FlxSprite(300, 72 - 25, AssetPaths.ryb__png);
30+
playRYB = new FlxSprite(300 * 2, (72 - 25) * 2, AssetPaths.ryb__png);
31+
playRYB.setGraphicSize(Std.int(playRYB.width * 2));
32+
playRYB.updateHitbox();
3133
FlxMouseEvent.add(playRYB, null, onSelect, onMOver, onMOut, false, true, false);
3234
FlxMouseEvent.setMouseClickCallback(playRYB, onSelect);
3335
add(playRYB);
3436

35-
playRGB = new FlxSprite(300, 144 - 25, AssetPaths.rgb__png);
37+
playRGB = new FlxSprite(300 * 2, (144 - 25) * 2, AssetPaths.rgb__png);
38+
playRGB.setGraphicSize(Std.int(playRGB.width * 2));
39+
playRGB.updateHitbox();
3640
FlxMouseEvent.add(playRGB, null, onSelect, onMOver, onMOut, false, true, false);
3741
FlxMouseEvent.setMouseClickCallback(playRGB, onSelect);
3842
add(playRGB);
3943

40-
playCMY = new FlxSprite(300, 216 - 25, AssetPaths.cmy__png);
44+
playCMY = new FlxSprite(300 * 2, (216 - 25) * 2, AssetPaths.cmy__png);
45+
playCMY.setGraphicSize(Std.int(playCMY.width * 2));
46+
playCMY.updateHitbox();
4147
FlxMouseEvent.add(playCMY, null, onSelect, onMOver, onMOut, false, true, false);
4248
FlxMouseEvent.setMouseClickCallback(playCMY, onSelect);
4349
add(playCMY);
@@ -84,13 +90,11 @@ class MenuState extends FlxSubState
8490
function onMOver(target:FlxSprite):Void
8591
{
8692
// make the buttons more noticeable by expanding them on mouse over
87-
target.scale.x = 1.25;
88-
target.scale.y = 1.25;
93+
target.setGraphicSize(Std.int(target.width * 1.25));
8994
}
9095

9196
function onMOut(target:FlxSprite):Void
9297
{
93-
target.scale.x = 1;
94-
target.scale.y = 1;
98+
target.setGraphicSize(Std.int(target.width));
9599
}
96100
}

Arcade/FlxLightPuzzle/source/PlayState.hx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ class PlayState extends FlxState
4646
ui = new UILayer(resetLevel);
4747

4848
// the player is a high-tech triangle
49-
player = new FlxSprite(75, 144);
50-
player.makeGraphic(26, 26, FlxColor.TRANSPARENT, true);
51-
FlxSpriteUtil.drawTriangle(player, 0, 0, 26, FlxColor.WHITE);
52-
player.offset.set(13, 13);
49+
player = new FlxSprite(75 * 2, 144 * 2);
50+
player.makeGraphic(26 * 2, 26 * 2, FlxColor.TRANSPARENT, true);
51+
FlxSpriteUtil.drawTriangle(player, 0, 0, 26 * 2, FlxColor.WHITE);
52+
player.offset.set(13 * 2, 13 * 2);
5353
player.pixelPerfectRender = false;
54-
player.antialiasing = true;
54+
player.antialiasing = false;
5555

56-
playerPosition = FlxPoint.get(75, 144);
56+
playerPosition = FlxPoint.get(75 * 2, 144 * 2);
5757

5858
currLevelIndex = -1;
5959
blockLevelReset = false;
@@ -172,7 +172,7 @@ class PlayState extends FlxState
172172
if (currLevelIndex >= numLevels)
173173
{
174174
// win the game
175-
var endCircle = new Circle(FlxPoint.get(300, 144), 350, Color.WHITE);
175+
var endCircle = new Circle(FlxPoint.get(300 * 2, 144 * 2), 350 * 2, Color.WHITE);
176176
game.drawCircle(endCircle, 1, 4.32);
177177

178178
openSubState(new WinState());

Arcade/FlxLightPuzzle/source/Template.hx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class Template
5454
for (targetData in targetsData)
5555
{
5656
var params = targetData.split(" ");
57-
targetsDefault.push(new Circle(FlxPoint.get(Std.parseFloat(params[0]), Std.parseFloat(params[1])), Std.parseFloat(params[2]),
57+
targetsDefault.push(new Circle(FlxPoint.get(Std.parseFloat(params[0]) * 2, Std.parseFloat(params[1]) * 2), Std.parseFloat(params[2]) * 2,
5858
getColorFromData(params[3])));
5959
}
6060

@@ -70,7 +70,7 @@ class Template
7070

7171
for (i in 0...numVerts)
7272
{
73-
verts.push(FlxPoint.get(Std.parseFloat(params[2 * i]), Std.parseFloat(params[2 * i + 1])));
73+
verts.push(FlxPoint.get(Std.parseFloat(params[2 * i]) * 2, Std.parseFloat(params[2 * i + 1]) * 2));
7474
}
7575

7676
if (numVerts == 2)

Arcade/FlxLightPuzzle/source/UILayer.hx

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,25 @@ class UILayer extends FlxSpriteGroup
3434

3535
// a black background helps the UI buttons stand out
3636
bg = new FlxSprite();
37-
bg.makeGraphic(250, FlxG.height, FlxColor.BLACK); // should this change based on the selected color palette?
37+
bg.makeGraphic(250 * 2, FlxG.height, FlxColor.BLACK); // should this change based on the selected color palette?
3838

3939
FlxMouseEvent.add(bg, null, null, onPanelOver, onPanelOut, true, true,
4040
true); // pixel-perfect because we will be using a clipRect and need the extra checks
4141

4242
add(bg);
4343

44-
ammo = new FlxSprite(5, 223);
45-
ammo.makeGraphic(40, 60, 0x0, true);
44+
ammo = new FlxSprite(5 * 2, 223 * 2);
45+
ammo.makeGraphic(40 * 2, 60 * 2, 0x0, true);
4646

4747
add(ammo);
4848

4949
// the original art files from Kenney.nl are in multiple pngs: I combined several using an image editor to make a spritesheet that I can easily load as an animation
5050
// tools like TexturePacker do all that for you plus more: check out the TexturePackerDemo too!
5151

52-
var mute = new FlxSprite(0, 69);
52+
var mute = new FlxSprite(0, 69 * 2);
5353
mute.loadGraphic(AssetPaths.music__png, true, 50, 50);
54+
mute.setGraphicSize(Std.int(mute.width * 2));
55+
mute.updateHitbox();
5456
mute.animation.add("unmuted", [0], 0, false);
5557
mute.animation.add("muted", [1], 0, false);
5658
mute.animation.play("unmuted");
@@ -73,22 +75,27 @@ class UILayer extends FlxSpriteGroup
7375
add(fullscreen);
7476
*/
7577

76-
var restart = new FlxSprite(0, 69 + 100);
78+
var restart = new FlxSprite(0, (69 + 100) * 2);
7779
restart.loadGraphic(AssetPaths.return__png, false);
80+
restart.setGraphicSize(Std.int(restart.width * 2));
81+
restart.updateHitbox();
7882

7983
FlxMouseEvent.add(restart, null, onRestart, onMOver, onMOut, true, true, false);
8084

8185
add(restart);
8286

83-
source = new FlxText(100, 50, 150, "Click for the source code", 14);
87+
source = new FlxText(100 * 2, 50 * 2, 150 * 2, "Click for the source code", 14 * 2);
8488
FlxMouseEvent.add(source, null, onSource, onMOver, onMOut, true, true, false);
8589
add(source);
8690

87-
patreon = new FlxSprite(125, 125, AssetPaths.haxeflixel__png); // "click to learn more"?
91+
patreon = new FlxSprite(125 * 2, 125 * 2, AssetPaths.haxeflixel__png); // "click to learn more"?
92+
patreon.antialiasing = true;
93+
patreon.setGraphicSize(Std.int(patreon.width * 2));
94+
patreon.updateHitbox();
8895
FlxMouseEvent.add(patreon, null, onPatreon, onMOver, onMOut, true, true, false);
8996
add(patreon);
9097

91-
credits = new FlxText(60, 216, 180, "Made by MSGhero for HaxeFlixel\nArt from Kenney.nl\nWaltz in G minor by Strimlarn87", 8);
98+
credits = new FlxText(60 * 2, 216 * 2, 180 * 2, "Made by MSGhero for HaxeFlixel\nArt from Kenney.nl\nWaltz in G minor by Strimlarn87", 8 * 2);
9299
credits.alignment = "center";
93100
FlxMouseEvent.add(credits, null, onCredits, onMOver, onMOut, true, true, false);
94101
add(credits);
@@ -97,8 +104,8 @@ class UILayer extends FlxSpriteGroup
97104

98105
// the UI panel will expand when moused over, and that will be controlled by a clipRect
99106
// which will hide the right side of the panel until the left is moused over
100-
clipRect = new FlxRect(0, 0, 50, FlxG.height);
101-
bg.width = 50;
107+
clipRect = new FlxRect(0, 0, 50 * 2, FlxG.height);
108+
bg.width = 50 * 2;
102109
}
103110

104111
public function setAmmo(remainingAmmo:Array<Color>):Void
@@ -107,7 +114,7 @@ class UILayer extends FlxSpriteGroup
107114
// you could also manage separate sprites, each being one unit of ammo (photons?)
108115

109116
var color:FlxColor = 0x0;
110-
var rect = new Rectangle(0, 0, 40, 20);
117+
var rect = new Rectangle(0, 0, 40 * 2, 20 * 2);
111118

112119
for (i in 0...3)
113120
{
@@ -116,7 +123,7 @@ class UILayer extends FlxSpriteGroup
116123
else
117124
color = FlxColor.BLACK;
118125

119-
rect.y = 40 - i * 20;
126+
rect.y = 80 - i * 40;
120127

121128
ammo.pixels.fillRect(rect, color);
122129
}
@@ -176,15 +183,15 @@ class UILayer extends FlxSpriteGroup
176183

177184
function onPanelOver(target:FlxSprite):Void
178185
{
179-
clipRect.width = bg.width = 250;
186+
clipRect.width = bg.width = 250 * 2;
180187
clipRect = clipRect; // you have to set the clipRect for it to update, just changing a property doesn't do anything
181188

182189
source.visible = patreon.visible = credits.visible = true; // we don't want these responding to mouse clicks when covered up, so we have to manually set their visibility
183190
}
184191

185192
function onPanelOut(target:FlxSprite):Void
186193
{
187-
clipRect.width = bg.width = 50;
194+
clipRect.width = bg.width = 50 * 2;
188195
clipRect = clipRect;
189196

190197
source.visible = patreon.visible = credits.visible = false;
@@ -218,14 +225,12 @@ class UILayer extends FlxSpriteGroup
218225

219226
function onMOver(target:FlxSprite):Void
220227
{
221-
target.scale.x = 1.25;
222-
target.scale.y = 1.25;
228+
target.setGraphicSize(Std.int(target.width * 1.25));
223229
}
224230

225231
function onMOut(target:FlxSprite):Void
226232
{
227-
target.scale.x = 1;
228-
target.scale.y = 1;
233+
target.setGraphicSize(Std.int(target.width));
229234
}
230235

231236
override function get_width():Float

Arcade/FlxLightPuzzle/source/WinState.hx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ class WinState extends FlxSubState
1717
{
1818
var bg = ColorMaps.defaultColorMap[Color.WHITE] == FlxColor.BLACK ? FlxColor.WHITE : FlxColor.BLACK; // if the background is black, we want white text, and vice-versa
1919

20-
winMessage = new FlxText(256, 40, 250,
20+
winMessage = new FlxText(256 * 2, 40 * 2, 250 * 2,
2121
"Want more?\n\nYou can copy the code to make more levels or change it however you want.\n\n" +
2222
"This project is open source and released under MIT license thanks to HaxeFlixel supporters.\n\n" +
2323
"Grab the code and become a HaxeFlixel supporter to help make more cool open-source demos like this.",
24-
14);
25-
winMessage.setFormat(null, 12, bg);
24+
14 * 2);
25+
winMessage.setFormat(null, 12 * 2, bg);
2626
winMessage.alignment = "center";
2727

2828
// delay to match up with the expanding circle background

0 commit comments

Comments
 (0)