Skip to content

Commit 1bd4639

Browse files
committed
things done at library
1 parent 8e3ca3b commit 1bd4639

12 files changed

Lines changed: 233 additions & 52 deletions

File tree

Project.xml

Lines changed: 60 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<project xmlns="http://lime.software/project/1.0.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
<project xmlns="http://lime.software/project/1.0.2"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
34
xsi:schemaLocation="http://lime.software/project/1.0.2 http://lime.software/xsd/project-1.0.2.xsd">
45

56
<!-- _________________________ Application Settings _________________________ -->
67

7-
<app title="game-jam-template" file="game-jam-template" main="Main" version="0.0.1" company="HaxeFlixel" />
8+
<app title="game-jam-template" file="game-jam-template" main="Main" version="0.0.1"
9+
company="HaxeFlixel" />
810

9-
<!--The flixel preloader is not accurate in Chrome. You can use it regularly if you embed the swf into a html file
11+
<!--The
12+
flixel preloader is not accurate in Chrome. You can use it regularly if you embed the swf into a
13+
html file
1014
or you can set the actual size of your file manually at "FlxPreloaderBase-onUpdate-bytesTotal"-->
1115
<app preloader="flixel.system.FlxPreloader" />
1216

13-
<!--Minimum without FLX_NO_GAMEPAD: 11.8, without FLX_NO_NATIVE_CURSOR: 11.2-->
17+
<!--Minimum
18+
without FLX_NO_GAMEPAD: 11.8, without FLX_NO_NATIVE_CURSOR: 11.2-->
1419
<set name="SWF_VERSION" value="11.8" />
1520

1621
<!-- ____________________________ Window Settings ___________________________ -->
1722

18-
<!--These window settings apply to all targets-->
23+
<!--These
24+
window settings apply to all targets-->
1925
<window width="1280" height="960" fps="60" background="#000000" hardware="true" vsync="false" />
2026

2127
<!--HTML5-specific-->
@@ -37,48 +43,70 @@
3743

3844
<haxelib name="flixel" />
3945

40-
<!--In case you want to use the addons package-->
46+
<!--In
47+
case you want to use the addons package-->
4148
<haxelib name="flixel-addons" />
4249

43-
<!--In case you want to use the ui package-->
44-
<!--<haxelib name="flixel-ui" />-->
50+
<!--In
51+
case you want to use the ui package-->
52+
<!--<haxelib
53+
name="flixel-ui" />-->
4554

46-
<!--In case you want to use nape with flixel-->
47-
<!--<haxelib name="nape-haxe4" />-->
55+
<!--In
56+
case you want to use nape with flixel-->
57+
<!--<haxelib
58+
name="nape-haxe4" />-->
4859

4960
<!-- ______________________________ Haxedefines _____________________________ -->
5061

51-
<!--Enable the Flixel core recording system-->
52-
<!--<haxedef name="FLX_RECORD" />-->
62+
<!--Enable
63+
the Flixel core recording system-->
64+
<!--<haxedef
65+
name="FLX_RECORD" />-->
5366

54-
<!--Disable the right and middle mouse buttons-->
55-
<!--<haxedef name="FLX_NO_MOUSE_ADVANCED" />-->
67+
<!--Disable
68+
the right and middle mouse buttons-->
69+
<!--<haxedef
70+
name="FLX_NO_MOUSE_ADVANCED" />-->
5671

57-
<!--Disable the native cursor API on Flash-->
58-
<!--<haxedef name="FLX_NO_NATIVE_CURSOR" />-->
72+
<!--Disable
73+
the native cursor API on Flash-->
74+
<!--<haxedef
75+
name="FLX_NO_NATIVE_CURSOR" />-->
5976

60-
<!--Optimise inputs, be careful you will get null errors if you don't use conditionals in your game-->
77+
<!--Optimise
78+
inputs, be careful you will get null errors if you don't use conditionals in your game-->
6179
<haxedef name="FLX_NO_MOUSE" if="mobile" />
6280
<haxedef name="FLX_NO_KEYBOARD" if="mobile" />
6381
<haxedef name="FLX_NO_TOUCH" if="desktop" />
64-
<!--<haxedef name="FLX_NO_GAMEPAD" />-->
65-
66-
<!--Disable the Flixel core sound tray-->
67-
<!--<haxedef name="FLX_NO_SOUND_TRAY" />-->
68-
69-
<!--Disable the Flixel sound management code-->
70-
<!--<haxedef name="FLX_NO_SOUND_SYSTEM" />-->
71-
72-
<!--Disable the Flixel core focus lost screen-->
73-
<!--<haxedef name="FLX_NO_FOCUS_LOST_SCREEN" />-->
74-
75-
<!--Disable the Flixel core debugger. Automatically gets set whenever you compile in release mode!-->
82+
<!--<haxedef
83+
name="FLX_NO_GAMEPAD" />-->
84+
85+
<!--Disable
86+
the Flixel core sound tray-->
87+
<!--<haxedef
88+
name="FLX_NO_SOUND_TRAY" />-->
89+
90+
<!--Disable
91+
the Flixel sound management code-->
92+
<!--<haxedef
93+
name="FLX_NO_SOUND_SYSTEM" />-->
94+
95+
<!--Disable
96+
the Flixel core focus lost screen-->
97+
<!--<haxedef
98+
name="FLX_NO_FOCUS_LOST_SCREEN" />-->
99+
100+
<!--Disable
101+
the Flixel core debugger. Automatically gets set whenever you compile in release mode!-->
76102
<haxedef name="FLX_NO_DEBUG" unless="debug" />
77103

78-
<!--Enable this for Nape release builds for a serious peformance improvement-->
104+
<!--Enable
105+
this for Nape release builds for a serious peformance improvement-->
79106
<haxedef name="NAPE_RELEASE_BUILD" unless="debug" />
80107

81108
<!-- _________________________________ Custom _______________________________ -->
82109

83-
<!--Place custom nodes like icons here (higher priority to override the HaxeFlixel icon)-->
84-
</project>
110+
<!--Place
111+
custom nodes like icons here (higher priority to override the HaxeFlixel icon)-->
112+
</project>

RAW/sprites/001a.png

443 Bytes
Loading

RAW/sprites/001b.png

431 Bytes
Loading

RAW/sprites/002a.png

284 Bytes
Loading

RAW/sprites/002b.png

283 Bytes
Loading

README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,31 @@
44

55
This is a HaxeFlixel template that is particularly helpful for game jams. It consists of:
66

7-
- An empty HaxeFlixel project generated with the `flixel template` command (with config files for Visual Studio Code).
8-
- Automated HTML5 builds after each commit using GitHub Actions with deployment to GitHub Pages, so the playable game shows up on `http://<user-name>.github.io/<repo-name>/`. In this case the URL is http://haxeflixel.github.io/game-jam-template/. Very handy if you want feedback from others mid-jam!
97

108
This is a [template repository](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-from-a-template), simply click "Use this template" to create a copy of it on your own GitHub account!
119

12-
![](https://help.github.com/assets/images/help/repository/use-this-template-button.png)
1310

11+
## Packing sprites at build time
12+
13+
You can pack raw sprite PNGs into a spritesheet automatically during the Haxe compile using the supplied macro and batch helper.
14+
15+
1. Put raw enemy frames in `RAW/sprites/*.png`.
16+
2. Configure a packer by setting one of these environment variables:
17+
- `TP_PATH` -> path to TexturePacker executable
18+
- `SHOEBOX_PATH` -> path to Shoebox executable
19+
3. Run the batch script locally to produce `assets/images/enemies.png` and `assets/images/enemies.json`:
20+
21+
```
22+
tools\pack_enemies.bat
23+
```
24+
25+
4. To run the packer automatically at compile time, add the following line to your `.hxml` before compilation steps:
26+
27+
```
28+
--macro "macros.ShoeboxMacro.run('tools/pack_enemies.bat')"
29+
```
30+
31+
This will call the batch script during macro execution; if it fails, the macro will abort compilation with an error.
1432
**Notes:**
1533
- For the first GitHub pages deployment, it can take around 10 minutes for the page to show up. Also, the repository needs to be public.
1634
- The HTML5 builds are made [with the `-final` flag](https://github.com/HaxeFlixel/game-jam-template/blob/105be8f21d3880736ab056da22cb9e4d04d5536c/.github/workflows/main.yml#L19), which means [Dead Code Elimination](https://haxe.org/manual/cr-dce.html) and Minification are active to create smaller `.js` files. However, your code needs to be DCE-safe (avoid reflection or use `@:keep`).

assets/images/reticle.png

322 Bytes
Loading

source/Actions.hx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import flixel.input.actions.FlxActionInput.FlxInputDevice;
77
import flixel.input.actions.FlxActionInput.FlxInputDeviceID;
88
import flixel.input.actions.FlxActionManager;
99
import flixel.input.actions.FlxActionSet;
10-
// (no platform sensors used)
1110

11+
// (no platform sensors used)
1212
class Actions
1313
{
1414
public static var actions:FlxActionManager;
@@ -146,6 +146,8 @@ class Actions
146146

147147
Actions.leftStick.addGamepad(LEFT_ANALOG_STICK, MOVED, EITHER);
148148
Actions.rightStick.addGamepad(RIGHT_ANALOG_STICK, MOVED, EITHER);
149+
// Do not add mouse motion to rightStick: mouse will be handled as absolute
150+
// cursor position inside Reticle (preferred for keyboard+mouse players).
149151

150152
Actions.upUI.addGamepad(LEFT_STICK_DIGITAL_UP, JUST_RELEASED);
151153
Actions.downUI.addGamepad(LEFT_STICK_DIGITAL_DOWN, JUST_RELEASED);

source/GameObject.hx

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

33
import flixel.FlxSprite;
44

5-
/**
6-
* Minimal GameObject base used by Player and enemies.
7-
* Only provides velocity-based movement (move/stop).
8-
*/
95
class GameObject extends FlxSprite
106
{
11-
// public max speed in pixels/second (simple field — easy to change)
127
public var speed:Float = 80;
8+
public var moveAngle:Float = 0;
139

1410
public function new(X:Float = 0, Y:Float = 0)
1511
{
1612
super(X, Y);
17-
this.maxVelocity.set(speed, speed);
13+
maxVelocity.set(speed, speed);
1814
}
1915

20-
// immediate velocity set in heading (degrees)
2116
public function move(angleDegrees:Float):Void
2217
{
18+
moveAngle = angleDegrees;
2319
var rad:Float = angleDegrees * Math.PI / 180.0;
24-
this.velocity.set(Math.cos(rad) * speed, Math.sin(rad) * speed);
20+
velocity.set(Math.cos(rad) * speed, Math.sin(rad) * speed);
2521
}
2622

27-
// instant stop
2823
public function stop():Void
2924
{
30-
this.velocity.set(0, 0);
31-
this.acceleration.set(0, 0);
25+
velocity.set(0, 0);
26+
acceleration.set(0, 0);
3227
}
3328
}

source/PlayState.hx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ package;
33
import flixel.FlxG;
44
import flixel.FlxState;
55
import flixel.math.FlxPoint;
6-
import flixel.tile.FlxBaseTilemap.FlxTilemapAutoTiling;
7-
import flixel.tile.FlxTilemap;
86

97
class PlayState extends FlxState
108
{
119
public var tilemap:GameMap;
1210
public var player:Player;
11+
public var reticle:Reticle;
1312

1413
override public function create():Void
1514
{
@@ -23,6 +22,9 @@ class PlayState extends FlxState
2322
player = new Player(tilemap.portalPixelX, tilemap.portalPixelY);
2423
add(player);
2524

25+
reticle = new Reticle(player);
26+
add(reticle);
27+
2628
FlxG.camera.setScrollBoundsRect(0, 0, Std.int(tilemap.width), Std.int(tilemap.height), true);
2729
FlxG.camera.follow(player);
2830
super.create();
@@ -31,8 +33,10 @@ class PlayState extends FlxState
3133
override public function update(elapsed:Float):Void
3234
{
3335
playerMovement(elapsed);
34-
36+
if (reticle != null)
37+
reticle.updateFromPlayer(player);
3538
super.update(elapsed);
39+
FlxG.collide(player, tilemap.wallsMap);
3640
}
3741

3842
private function playerMovement(elapsed:Float):Void

0 commit comments

Comments
 (0)