├── Changes.md
├── LICENSE
├── README.md
├── apps
├── Flappybalt
│ ├── Flappybalt.hxproj
│ ├── LICENSE
│ ├── Project.xml
│ ├── README.md
│ ├── assets
│ │ ├── bg.png
│ │ ├── dove.png
│ │ ├── feather.png
│ │ ├── icon.png
│ │ ├── icon.svg
│ │ ├── paddle.png
│ │ ├── screenshot.png
│ │ └── spike.png
│ └── source
│ │ ├── Main.hx
│ │ ├── Paddle.hx
│ │ ├── PlayState.hx
│ │ ├── Player.hx
│ │ └── Reg.hx
├── HerokuShaders
│ └── project.nmml
├── PiratePig
│ └── project.nmml
├── Tilemap
│ ├── Tilemap.hx
│ ├── Tilemap.nmml
│ ├── Tiles.png
│ └── icon.svg
└── boot
│ ├── build.nmml
│ ├── default.svg
│ └── src
│ └── AcadnmeBoot.hx
├── engine
├── assets
│ ├── banner.svg
│ └── icon.svg
├── build.nmml
└── src
│ ├── Acadnme.hx
│ ├── AllNme.hx
│ └── IBoot.hx
├── haxelib.json
├── include.xml
└── tools
└── run
├── RunMain.hx
└── compile.hxml
/Changes.md:
--------------------------------------------------------------------------------
1 | - update Flappybalt to flixel version 4
2 | - Updated to latest NME version
3 |
4 | 1.0.0
5 | --------------------------
6 | * Created
7 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2013 nmehost
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # acadnme
2 | Acadnme is the basic Cppia host for Nme applications
3 |
4 |
5 | Rebuilding
6 | ----------
7 | First, you need to rebuild the 'exports' directory.
8 | This is done with
9 | ```
10 | cd engine
11 | nme nocompile
12 | ```
13 |
14 | Then, you build each of the apps into a ".nme" file
15 | ```
16 | cd apps/boot
17 | nme cppia installer
18 | cd apps/Flappybalt
19 | nme cppia installer
20 | cd apps/HerokuShaders
21 | nme cppia installer
22 | cd apps/PiratePig
23 | nme cppia installer
24 | cd apps/Tilemap
25 | nme cppia installer
26 | ```
27 |
28 | Finally, compile the engine into a runtime:
29 | ```
30 | cd engine
31 | nme cpp (for your host target)
32 | or
33 | nme android
34 | or
35 | nme ios update
36 | ```
37 | If you need a debug build, you can add the "-debug" flag:
38 | ```
39 | cd engine
40 | nme cpp -debug
41 | ```
42 |
43 |
44 | Having built the host, you can test the included apps (or indeed any project) with
45 | ```
46 | cd app/MyApp
47 | nme cppia
48 | ```
49 |
50 | From a git version, you will also need to build the 'run.n' script so "haxelib run..." will work. This is done with:
51 | ```
52 | cd tools/run
53 | haxe compile.hxml
54 | ```
55 |
--------------------------------------------------------------------------------
/apps/Flappybalt/Flappybalt.hxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/apps/Flappybalt/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Adam 'Atomic' Saltsman
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/apps/Flappybalt/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/apps/Flappybalt/README.md:
--------------------------------------------------------------------------------
1 | #  Flappybalt
2 |
3 |
4 |
5 |
6 |
7 | A cross-platform port of [AdamAtomic](https://github.com/AdamAtomic)'s [Flappybalt](http://adamatomic.com/flappybalt/), converted to [Haxe](http://www.haxe.org) and [HaxeFlixel](http://www.haxeflixel.com). You can play this on your Android by downloading it from the [Google Play Store](https://play.google.com/store/apps/details?id=com.steverichey.flappybalt) if you'd like.
8 |
9 | # Releasing for Android with HaxeFlixel (Windows)
10 |
11 | The process for releasing a HaxeFlixel game as an Android app is a bit complicated, so I thought I'd step through some of the steps. This is for Windows, but the process is largely the same for any platform.
12 |
13 | 1. [Register](https://play.google.com/apps/publish/signup/) for a Google Play Developer Console account. The charge is currently $25.
14 | 2. Prepare to compile by running `lime setup android`. Make sure that your path to the Java JDK looks like `c:\java\jdk1.6.0_37` and NOT to the `bin` directory.
15 | 2. Compile your app for Android. This can be done simply by running `lime build android` from the command line in your project directory. Make sure your input is set up properly, accounting for touch controls and the lack of mouse/keyboard! HaxeFlixel has some handy Haxe defines for this, e.g. `FLX_NO_MOUSE`, `FLX_NO_KEYBOARD`, etc.
16 | 3. Test your app on an Android device! You can set up the Android Debug Bridge (ADB) for this, but you could just email the APK to yourself. Slower, but easier.
17 | 4. Provided everything works, you'll need to sign your app before you release it. So long as your `JAVA_HOME` environment variable points to the BIN directory (e.g. `c:/java/jdk1.6.0_37/bin/`) you can do this by running `keytool` from the command line. [Google recommends](http://developer.android.com/tools/publishing/app-signing.html) the following settings:
18 |
19 | ````
20 | keytool -genkey -v -keystore YOUR_RELEASE_KEY.keystore -alias YOUR_ALIAS -keyalg RSA -keysize 2048 -validity 10000
21 | ````
22 |
23 | It will ask for a password and stuff, which you will need to remember! Obviously, use your own values for `YOUR_RELEASE_KEY` and `YOUR_ALIAS`.
24 |
25 | In order for Lime to see your certificate, you need to add it to the `Project.XML` file. You can add this line:
26 |
27 | ````
28 |
29 | ````
30 |
31 | Obviously use your own values where appropriate. Now when you run `lime build android` it will sign the app automagically! Just look for `MyApp-release.apk` in `export/android/bin/bin/`.
32 |
33 | Finally, [upload your APK](https://play.google.com/apps/publish/)! You can set up Google Play stuff too.
34 |
35 | ## Optional Steps
36 |
37 | * If you have an SVG file set up as your icon in your `Project.XML` file, Lime will make nice high-res icons for you. Do this! Just add `` to your `Project.XML` file. You can create SVGs using [InkScape](http://inkscape.org/en/), or even by hand, as they are [basically just XML files](http://www.w3.org/TR/SVG11/).
38 | * Don't want to scare off potential customers with a bunch of app permissions? Lime includes a few by default, but this can be overridden. After building your app at least once, get `export/android/bin/bin/AndroidManifest.xml` and copy it somewhere else (I usually put it into a `libs` directory). Then, in your `Project.XML`, add:
39 |
40 | ````
41 |
42 | ````
43 |
44 | Now Lime will use this file instead of the default AndroidManifest it would normally generate. Inside this file you'll notice a few lines:
45 |
46 | ````
47 |
48 |
49 |
50 |
51 | ````
52 |
53 | **As far as I know** you can delete these lines without issue. If you do this, when someone goes to launch your app, it will say "This app requires no special permissions". Obviously, this is not applicable if you actually need one of these permissions!
54 |
55 | All of the code in this repository is available under an MIT license. Code not included in this repository (mostly just app settings, private keys, etc) is copyright [SteveRichey](https://github.com/steverichey) but if you have questions about implementation let me know and I'll help you out!
56 |
57 | ### Changes:
58 | * Pixel-perfect collisions.
59 | * Special FX
60 |
61 | Canabalt-themed flappy-like for [FlappyJam](http://itch.io/jam/flappyjam).
62 |
63 | The original version was programmed in ActionScript 3, and required [flixel](http://flixel.org/) to compile.
64 |
--------------------------------------------------------------------------------
/apps/Flappybalt/assets/bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nmehost/acadnme/520692655ba8844acf007a2173512bb2d58cb3dd/apps/Flappybalt/assets/bg.png
--------------------------------------------------------------------------------
/apps/Flappybalt/assets/dove.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nmehost/acadnme/520692655ba8844acf007a2173512bb2d58cb3dd/apps/Flappybalt/assets/dove.png
--------------------------------------------------------------------------------
/apps/Flappybalt/assets/feather.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nmehost/acadnme/520692655ba8844acf007a2173512bb2d58cb3dd/apps/Flappybalt/assets/feather.png
--------------------------------------------------------------------------------
/apps/Flappybalt/assets/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nmehost/acadnme/520692655ba8844acf007a2173512bb2d58cb3dd/apps/Flappybalt/assets/icon.png
--------------------------------------------------------------------------------
/apps/Flappybalt/assets/icon.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/apps/Flappybalt/assets/paddle.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nmehost/acadnme/520692655ba8844acf007a2173512bb2d58cb3dd/apps/Flappybalt/assets/paddle.png
--------------------------------------------------------------------------------
/apps/Flappybalt/assets/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nmehost/acadnme/520692655ba8844acf007a2173512bb2d58cb3dd/apps/Flappybalt/assets/screenshot.png
--------------------------------------------------------------------------------
/apps/Flappybalt/assets/spike.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nmehost/acadnme/520692655ba8844acf007a2173512bb2d58cb3dd/apps/Flappybalt/assets/spike.png
--------------------------------------------------------------------------------
/apps/Flappybalt/source/Main.hx:
--------------------------------------------------------------------------------
1 | package;
2 |
3 | import flixel.FlxGame;
4 | import openfl.display.Sprite;
5 |
6 | class Main extends Sprite
7 | {
8 | public function new()
9 | {
10 | super();
11 | addChild(new FlxGame(160, 240, PlayState));
12 | }
13 | }
--------------------------------------------------------------------------------
/apps/Flappybalt/source/Paddle.hx:
--------------------------------------------------------------------------------
1 | package;
2 |
3 | import flixel.FlxG;
4 | import flixel.FlxObject;
5 | import flixel.FlxSprite;
6 | import flixel.math.FlxRandom;
7 |
8 | class Paddle extends FlxSprite
9 | {
10 | public var targetY:Int = 0;
11 |
12 | inline static public var SPEED:Int = 480;
13 |
14 | public function new(X:Float = 0, Facing:Int = 0)
15 | {
16 | super(X, FlxG.height);
17 | loadGraphic("assets/paddle.png", false);
18 |
19 | if (Facing == FlxObject.LEFT)
20 | {
21 | flipX = true;
22 | }
23 | }
24 |
25 | public function randomize():Void
26 | {
27 | targetY = Reg.PS.randomPaddleY();
28 |
29 | if (targetY < y)
30 | velocity.y = -SPEED;
31 | else
32 | velocity.y = SPEED;
33 | }
34 |
35 | override public function update(elapsed:Float):Void
36 | {
37 | if (((velocity.y < 0) && (y <= targetY + SPEED * elapsed)) ||
38 | ((velocity.y > 0) && (y >= targetY - SPEED * elapsed)))
39 | {
40 | velocity.y = 0;
41 | y = targetY;
42 | }
43 |
44 | super.update(elapsed);
45 | }
46 | }
--------------------------------------------------------------------------------
/apps/Flappybalt/source/PlayState.hx:
--------------------------------------------------------------------------------
1 | package;
2 |
3 | import flixel.effects.particles.FlxEmitter;
4 | import flixel.FlxG;
5 | import flixel.FlxObject;
6 | import flixel.FlxSprite;
7 | import flixel.FlxState;
8 | import flixel.group.FlxGroup;
9 | import flixel.text.FlxText;
10 | import flixel.ui.FlxButton;
11 | import flixel.math.FlxRandom;
12 | import flixel.util.FlxSave;
13 |
14 | class PlayState extends FlxState
15 | {
16 | private var _player:Player;
17 | private var _bounceLeft:FlxSprite;
18 | private var _bounceRight:FlxSprite;
19 | private var _paddleLeft:Paddle;
20 | private var _paddleRight:Paddle;
21 | private var _spikeBottom:FlxSprite;
22 | private var _spikeTop:FlxSprite;
23 | private var _scoreDisplay:FlxText;
24 | private var _feathers:FlxEmitter;
25 | private var _highScore:FlxText;
26 |
27 | inline static private var SAVE_DATA:String = "FLAPPYBALT";
28 |
29 | override public function create():Void
30 | {
31 | super.create();
32 |
33 | // Keep a reference to this state in Reg for global access.
34 |
35 | Reg.PS = this;
36 |
37 | // Set background color identical to the bottom of the "city", so on tall screens there's not a big black bar at the bottom.
38 |
39 | FlxG.camera.bgColor = 0xff646A7D;
40 |
41 | // Hide the mouse.
42 |
43 | #if !FLX_NO_MOUSE
44 | FlxG.mouse.visible = false;
45 | #end
46 |
47 | // The background city.
48 |
49 | add(new FlxSprite(0, 0, "assets/bg.png"));
50 |
51 | // Current score.
52 |
53 | _scoreDisplay = new FlxText(0, 180, FlxG.width);
54 | _scoreDisplay.alignment = CENTER;
55 | _scoreDisplay.color = 0xff868696;
56 | add(_scoreDisplay);
57 |
58 | _scoreDisplay.text = "[Start]";
59 |
60 | // Update all-time high score.
61 |
62 | Reg.highScore = loadScore();
63 |
64 | // Display high score.
65 |
66 | _highScore = new FlxText(0, 40, FlxG.width, "");
67 | _highScore.alignment = CENTER;
68 | _highScore.color = 0xff868696;
69 | add(_highScore);
70 |
71 | if (Reg.highScore > 0)
72 | _highScore.text = Std.string(Reg.highScore);
73 |
74 | // The left bounce panel. Drawn via code in Reg to fit screen height.
75 |
76 | _bounceLeft = new FlxSprite(1, 17);
77 | _bounceLeft.loadGraphic(Reg.getBounceImage(FlxG.height - 34), true, 4, FlxG.height - 34);
78 | _bounceLeft.animation.add("flash", [1,0], 8, false);
79 | add(_bounceLeft);
80 |
81 | // The right bounce panel.
82 |
83 | _bounceRight = new FlxSprite(FlxG.width - 5, 17);
84 | _bounceRight.loadGraphic(Reg.getBounceImage(FlxG.height - 34), true, 4, FlxG.height - 34);
85 | _bounceRight.animation.add("flash", [1,0], 8, false);
86 | add(_bounceRight);
87 |
88 | // The left spiky paddle
89 |
90 | _paddleLeft = new Paddle(6, FlxObject.RIGHT);
91 | add(_paddleLeft);
92 |
93 | // The right spiky paddle
94 |
95 | _paddleRight = new Paddle(FlxG.width-15, FlxObject.LEFT);
96 | add(_paddleRight);
97 |
98 | // Spikes at the bottom of the screen
99 |
100 | _spikeBottom = new FlxSprite(0, 0, "assets/spike.png");
101 | _spikeBottom.y = FlxG.height - _spikeBottom.height;
102 | add(_spikeBottom);
103 |
104 | // Spikes at the top of the screen. Rotated to reduce number of assets.
105 |
106 | _spikeTop = new FlxSprite(0, 0);
107 | _spikeTop.loadRotatedGraphic("assets/spike.png", 4);
108 | _spikeTop.angle = 180;
109 | _spikeTop.y = -72;
110 | add(_spikeTop);
111 |
112 | // The bird.
113 |
114 | _player = new Player();
115 | add(_player);
116 |
117 | // A simple emitter to make some feathers when the bird gets spiked.
118 |
119 | _feathers = new FlxEmitter();
120 | _feathers.loadParticles("assets/feather.png", 50, 32);
121 | _feathers.velocity.set( -10, -10, 10, 10);
122 | _feathers.acceleration.set(0, 10);
123 | add(_feathers);
124 | }
125 |
126 | override public function update(elapsed:Float):Void
127 | {
128 | if (FlxG.pixelPerfectOverlap(_player, _spikeBottom) || FlxG.pixelPerfectOverlap(_player, _spikeTop)
129 | || FlxG.pixelPerfectOverlap(_player, _paddleLeft) || FlxG.pixelPerfectOverlap(_player, _paddleRight))
130 | {
131 | _player.kill();
132 | }
133 | else if (_player.x < 5)
134 | {
135 | _player.x = 5;
136 | _player.velocity.x = -_player.velocity.x;
137 | _player.flipX = false;
138 | increaseScore();
139 | _bounceLeft.animation.play("flash");
140 | _paddleRight.randomize();
141 | }
142 | else if (_player.x + _player.width > FlxG.width - 5)
143 | {
144 | _player.x = FlxG.width - _player.width - 5;
145 | _player.velocity.x = -_player.velocity.x;
146 | _player.flipX = true;
147 | increaseScore();
148 | _bounceRight.animation.play("flash");
149 | _paddleLeft.randomize();
150 | }
151 |
152 | #if !FLX_NO_KEYBOARD
153 | if (FlxG.keys.justPressed.E && (FlxG.keys.pressed.CONTROL || FlxG.keys.pressed.SHIFT || FlxG.keys.pressed.ALT))
154 | {
155 | clearSave();
156 | FlxG.resetState();
157 | }
158 | #end
159 |
160 | super.update(elapsed);
161 | }
162 |
163 | public function launchFeathers(X:Float, Y:Float, Amount:Int):Void
164 | {
165 | _feathers.x = X;
166 | _feathers.y = Y;
167 | _feathers.start(true, 0, Amount);
168 | }
169 |
170 | public function randomPaddleY():Int
171 | {
172 | return FlxG.random.int(Std.int(_bounceLeft.y), Std.int(_bounceLeft.y + _bounceLeft.height - _paddleLeft.height));
173 | }
174 |
175 | private function increaseScore():Void
176 | {
177 | Reg.score++;
178 | _scoreDisplay.text = Std.string(Reg.score);
179 | _scoreDisplay.size = 24;
180 | }
181 |
182 | /**
183 | * Resets the state to its initial position without having to call FlxG.resetState().
184 | */
185 | public function reset()
186 | {
187 | _paddleLeft.y = FlxG.height;
188 | _paddleRight.y = FlxG.height;
189 | _player.flipX = false;
190 | Reg.score = 0;
191 | _scoreDisplay.text = "";
192 | Reg.highScore = loadScore();
193 |
194 | if (Reg.highScore > 0)
195 | _highScore.text = Std.string(Reg.highScore);
196 | }
197 |
198 | /**
199 | * Safely store a new high score into the saved session, if possible.
200 | */
201 | static public function saveScore():Void
202 | {
203 | Reg.save = new FlxSave();
204 |
205 | if (Reg.save.bind(SAVE_DATA))
206 | {
207 | if ((Reg.save.data.score == null) || (Reg.save.data.score < Reg.score))
208 | Reg.save.data.score = Reg.score;
209 | }
210 |
211 | // Have to do this in order for saves to work on native targets!
212 |
213 | Reg.save.flush();
214 | }
215 |
216 | /**
217 | * Load data from the saved session.
218 | *
219 | * @return The total points of the saved high score.
220 | */
221 | static public function loadScore():Int
222 | {
223 | Reg.save = new FlxSave();
224 |
225 | if (Reg.save.bind(SAVE_DATA))
226 | {
227 | if ((Reg.save.data != null) && (Reg.save.data.score != null))
228 | return Reg.save.data.score;
229 | }
230 |
231 | return 0;
232 | }
233 |
234 | /**
235 | * Wipe save data.
236 | */
237 | static public function clearSave():Void
238 | {
239 | Reg.save = new FlxSave();
240 |
241 | if (Reg.save.bind(SAVE_DATA))
242 | Reg.save.erase();
243 | }
244 | }
245 |
--------------------------------------------------------------------------------
/apps/Flappybalt/source/Player.hx:
--------------------------------------------------------------------------------
1 | package;
2 |
3 | import flixel.FlxG;
4 | import flixel.FlxObject;
5 | import flixel.FlxSprite;
6 |
7 | class Player extends FlxSprite
8 | {
9 | public function new()
10 | {
11 | super(FlxG.width * 0.5 - 4, FlxG.height * 0.5 - 4);
12 | loadGraphic("assets/dove.png", true);
13 | animation.frameIndex = 2;
14 | animation.add("flap",[1,0,1,2],12,false);
15 | }
16 |
17 | override public function update(elapsed:Float)
18 | {
19 | if (FlxG.keys.justPressed.SPACE || FlxG.keys.justPressed.ENTER ||
20 | FlxG.touches.justStarted().length > 0 || FlxG.mouse.justPressed)
21 | {
22 | if (acceleration.y == 0)
23 | {
24 | acceleration.y = 500;
25 | velocity.x = 80;
26 | }
27 |
28 | velocity.y = -240;
29 |
30 | animation.play("flap", true);
31 | }
32 |
33 | super.update(elapsed);
34 | }
35 |
36 | override public function kill():Void
37 | {
38 | if (!exists)
39 | return;
40 |
41 | Reg.PS.launchFeathers(x, y, 10);
42 |
43 | super.kill();
44 |
45 | FlxG.camera.flash(0xffFFFFFF, 1, onFlashDone);
46 | FlxG.camera.shake(0.02, 0.35);
47 | }
48 |
49 | override public function revive():Void
50 | {
51 | x = FlxG.width * 0.5 - 4;
52 | y = FlxG.height * 0.5 - 4;
53 | acceleration.x = 0;
54 | acceleration.y = 0;
55 | velocity.x = 0;
56 | velocity.y = 0;
57 |
58 | super.revive();
59 | }
60 |
61 | public function onFlashDone():Void
62 | {
63 | PlayState.saveScore();
64 | revive();
65 | Reg.PS.reset();
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/apps/Flappybalt/source/Reg.hx:
--------------------------------------------------------------------------------
1 | package;
2 |
3 | import flash.display.BitmapData;
4 | import flash.geom.Rectangle;
5 | import flixel.util.FlxSave;
6 |
7 | class Reg
8 | {
9 | /**
10 | * The current total score.
11 | */
12 | static public var score:Int = 0;
13 |
14 | /**
15 | * High score storage.
16 | */
17 | static public var highScore:Int = 0;
18 |
19 | /**
20 | * A reference to the active playstate. Lets you call Reg.PS globally to access the playstate.
21 | */
22 | static public var PS:PlayState;
23 |
24 | /**
25 | * Used for saving and loading high scores.
26 | */
27 | static public var save:FlxSave;
28 |
29 | /**
30 | * Just a 2px by 2px transparent piece of "dust".
31 | */
32 | static public function dustMote():BitmapData
33 | {
34 | if (dustMoteData == null)
35 | dustMoteData = new BitmapData(2, 2, true, 0x88FFFFFF);
36 | return dustMoteData;
37 | }
38 |
39 | static private var dustMoteData:BitmapData;
40 |
41 | /**
42 | * Draws the bounce panels. Useful for mobile devices with weird resolutions.
43 | *
44 | * @param Height The height of the panel to draw.
45 | * @return A BitmapData object representing the paddle. Cached for the second paddle to save time.
46 | */
47 | static public function getBounceImage(Height:Int):BitmapData
48 | {
49 | if (_bitmapData != null)
50 | return _bitmapData;
51 |
52 | _bitmapData = new BitmapData(8, Height, false, GREY_MED);
53 |
54 | _rect = new Rectangle(4, 0, 4, Height);
55 | _bitmapData.fillRect(_rect, GREY_LIGHT);
56 | _rect = new Rectangle(0, 1, 1, Height - 2);
57 | _bitmapData.fillRect(_rect, GREY_DARK);
58 | _rect.x = 3;
59 | _bitmapData.fillRect(_rect, GREY_DARK);
60 | _rect = new Rectangle(1, 0, 2, 1);
61 | _bitmapData.fillRect(_rect, GREY_DARK);
62 | _rect.y = Height - 1;
63 | _bitmapData.fillRect(_rect, GREY_DARK);
64 | _rect = new Rectangle(4, 1, 1, Height - 2);
65 | _bitmapData.fillRect(_rect, WHITE);
66 | _rect.x = 7;
67 | _bitmapData.fillRect(_rect, WHITE);
68 | _rect = new Rectangle(5, 0, 2, 1);
69 | _bitmapData.fillRect(_rect, WHITE);
70 | _rect.y = Height - 1;
71 | _bitmapData.fillRect(_rect, WHITE);
72 |
73 | return _bitmapData;
74 | }
75 |
76 | // This is all stuff used for drawing the paddles.
77 |
78 | static private var _bitmapData:BitmapData;
79 | static private var _rect:Rectangle;
80 |
81 | inline static private var WHITE:Int = 0xffFFFFFF;
82 | inline static private var GREY_LIGHT:Int = 0xffB0B0BF;
83 | inline static private var GREY_MED:Int = 0xff646A7D;
84 | inline static private var GREY_DARK:Int = 0xff35353D;
85 | }
--------------------------------------------------------------------------------
/apps/HerokuShaders/project.nmml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/apps/PiratePig/project.nmml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/apps/Tilemap/Tilemap.hx:
--------------------------------------------------------------------------------
1 | import nme.display.Sprite;
2 | import nme.geom.Point;
3 | import gm2d.blit.Tilesheet;
4 | import gm2d.blit.Tile;
5 | import gm2d.blit.Layer;
6 | import gm2d.blit.Grid;
7 | import gm2d.Game;
8 | import gm2d.ui.Layout;
9 | import nme.events.Event;
10 | import nme.events.MouseEvent;
11 | import gm2d.Screen;
12 |
13 | import nme.ui.Keyboard;
14 |
15 |
16 | class Tilemap extends Screen
17 | {
18 | var mTilesheet:Tilesheet;
19 | var mTiles:Array;
20 | var mViewport:gm2d.blit.Viewport;
21 | var mMapLayer:Layer;
22 | var mPlayerLayer:Layer;
23 | var mPlayerX:Float;
24 | var mPlayerY:Float;
25 | var mMousePos:Point;
26 | var mWon:Bool;
27 |
28 | static var map = [
29 | "######~~~~~~~~~~~~~~~~~~~###############",
30 | "# ##### ######~###############",
31 | "# ##### # #### ## ##",
32 | "# ##### ########O ### ##",
33 | "### ######## ### ### ###",
34 | "### ############## ##### ######## ######",
35 | "### ###### ##### ######## ######",
36 | "### ####### ###### ##### ######## ######",
37 | "### ####### ##### ##",
38 | "# ############################ ##",
39 | "# # ## ####### ##",
40 | "# ##### ## ######## # ##",
41 | "# ###### ################### # ##",
42 | "## ############ ################### # ##",
43 | "## # # ## ### #### # ##",
44 | "## # ### ## ### ########## #### # ##",
45 | "## # ##### #### ### ########## #### # ##",
46 | "## # ##### ### ########## #### # ##",
47 | "## ###### ####### ########## #### # ##",
48 | "########### ####### ########## #### # ##",
49 | "########### ####### ##### #### # ##",
50 | "########### ############ #### # ##",
51 | "########### ############ ########## # ##",
52 | "## ########## # ##",
53 | "## ################################ # ##",
54 | "## ## ######################## # ##",
55 | "## ## #### ##",
56 | "## ## #### ## ## ##################",
57 | "## ############ ## ## ##################",
58 | "## ##### ## ## ##################",
59 | "## ##### ## ## ##################",
60 | "## ##### ## ## ####",
61 | "#### ########## ## ## ####",
62 | "# # ########## ## ## ####",
63 | "# ## ########## ## ## ####",
64 | "# ## # ########## ##########",
65 | "# ################ # ##########",
66 | "# ########################### ##########",
67 | "# ##########",
68 | "########################################"
69 | ];
70 |
71 | function new()
72 | {
73 | super();
74 | nme.ui.Mouse.hide();
75 | var bmp = nme.Assets.getBitmapData("Tiles.png");
76 | mTilesheet = new Tilesheet(bmp);
77 | mTiles = mTilesheet.partition(32,32);
78 | mTiles[3].hotX = 16;
79 | mTiles[3].hotY = 16;
80 |
81 | mViewport = gm2d.blit.Viewport.create(400, 300);
82 | mViewport.worldWidth = 640*2;
83 | mViewport.worldHeight = 640*2;
84 | mViewport.x = 40;
85 | mViewport.y = 10;
86 | addChild(mViewport);
87 | //mViewport.cacheAsBitmap = true;
88 |
89 | var grid = new Grid();
90 | for(y in 0...40)
91 | {
92 | var row = map[y];
93 | grid[y] = new Tiles();
94 | var tiles = grid[y];
95 | for(x in 0...40)
96 | {
97 | switch( row.substr(x,1) )
98 | {
99 | case "#","~" : tiles.push(mTiles[0]);
100 | case " " : tiles.push(mTiles[1]);
101 | case "O" : tiles.push(mTiles[2]);
102 | default : tiles.push(null);
103 | }
104 | }
105 | }
106 |
107 | mMapLayer = mViewport.createGridLayer(grid);
108 | mPlayerLayer = mViewport.createLayer();
109 |
110 | mPlayerX = 48;
111 | mPlayerY = 48;
112 | mPlayerLayer.addTile(mTiles[3],mPlayerX,mPlayerY);
113 |
114 | stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouse);
115 | stage.addEventListener(MouseEvent.MOUSE_UP, onMouse);
116 | stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouse);
117 | makeCurrent();
118 | }
119 |
120 | public function onMouse(e:MouseEvent)
121 | {
122 | if (e.buttonDown)
123 | mMousePos = new Point( e.stageX, e.stageY );
124 | else
125 | mMousePos = null;
126 | }
127 |
128 | override public function scaleScreen(inScale:Float)
129 | {
130 | if (inScale<=1)
131 | scaleX = scaleY = 1;
132 | else
133 | scaleX = scaleY = Std.int(inScale*2)*0.5;
134 | }
135 |
136 | function showWon()
137 | {
138 | var popup = new gm2d.ui.Window(["SimpleTile"]);
139 | popup.setItemLayout( new gm2d.ui.VerticalLayout() );
140 | popup.addWidget(new gm2d.ui.TextLabel("Winner!", { fontSize:gm2d.skin.Skin.scale(48) } ));
141 | var button = gm2d.ui.Button.TextButton("Restart", Game.closePopup, ["SimpleTile"] );
142 | popup.addWidget(button);
143 | popup.build();
144 | button.isCurrent = true;
145 | Game.popup(popup, function() { mPlayerX = mPlayerY = 48; mWon = false; } );
146 | }
147 |
148 |
149 |
150 | public function canMove(inX:Float, inY:Float)
151 | {
152 | if (inX<=8 || inY<=8)
153 | return false;
154 |
155 | var x0 = Std.int( (inX-8)/32 );
156 | var x1 = Std.int( (inX+8)/32 );
157 | var y0 = Std.int( (inY-8)/32 );
158 | var y1 = Std.int( (inY+8)/32 );
159 |
160 | for(y in y0...y1+1)
161 | for(x in x0...x1+1)
162 | if (map[y].substr(x,1)=="#")
163 | return false;
164 | return true;
165 | }
166 |
167 | override public function updateDelta(inDT:Float)
168 | {
169 | if (mWon)
170 | return;
171 |
172 | var stagePos = mViewport.localToGlobal( new Point(mPlayerX-mViewport.originX,mPlayerY-mViewport.originY) );
173 |
174 | if (inDT>0.1) inDT = 0.1;
175 | var px = mPlayerX;
176 | if (Game.isKeyDown(Keyboard.LEFT) || (mMousePos!=null && mMousePos.xstagePos.x+2) )
179 | px += inDT*100;
180 | if (px!=0 && canMove(px,mPlayerY))
181 | mPlayerX = px;
182 |
183 | var py = mPlayerY;
184 | if (Game.isKeyDown(Keyboard.UP) || (mMousePos!=null && mMousePos.ystagePos.y+2) )
187 | py += inDT*100;
188 | if (py!=0 && canMove(mPlayerX,py))
189 | mPlayerY = py;
190 |
191 | mPlayerLayer.clear();
192 | mPlayerLayer.addTile(mTiles[3],mPlayerX,mPlayerY);
193 | mViewport.centerOn(mPlayerX,mPlayerY);
194 |
195 | if (map[Std.int((mPlayerY)/32)].charAt(Std.int((mPlayerX)/32))=="O")
196 | {
197 | mWon = true;
198 | showWon();
199 | }
200 | }
201 |
202 |
203 | }
204 |
205 |
--------------------------------------------------------------------------------
/apps/Tilemap/Tilemap.nmml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
12 |
13 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/apps/Tilemap/Tiles.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nmehost/acadnme/520692655ba8844acf007a2173512bb2d58cb3dd/apps/Tilemap/Tiles.png
--------------------------------------------------------------------------------
/apps/Tilemap/icon.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
186 |
--------------------------------------------------------------------------------
/apps/boot/build.nmml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
16 |
17 |
18 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/apps/boot/default.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
--------------------------------------------------------------------------------
/apps/boot/src/AcadnmeBoot.hx:
--------------------------------------------------------------------------------
1 | import cpp.cppia.HostClasses;
2 |
3 | import nme.display.Sprite;
4 | import nme.display.Bitmap;
5 | import nme.display.BitmapData;
6 | import nme.script.Server;
7 | import nme.geom.Point;
8 | import nme.Assets;
9 | import nme.utils.ByteArray;
10 | import gm2d.Screen;
11 | import nme.geom.Rectangle;
12 | import gm2d.ui.Layout;
13 | import gm2d.ui.TextLabel;
14 | import gm2d.ui.TileControl;
15 | import gm2d.ui.Widget;
16 | import gm2d.ui.Button;
17 | import gm2d.ui.TextInput;
18 | import gm2d.ui.CheckButtons;
19 | import gm2d.ui.Image;
20 | import gm2d.ui.ListControl;
21 | import gm2d.skin.FillStyle;
22 | import gm2d.skin.LineStyle;
23 | import gm2d.skin.Style;
24 | import gm2d.skin.Skin;
25 | import gm2d.svg.Svg;
26 | import gm2d.svg.SvgRenderer;
27 | import sys.FileSystem;
28 | import nme.net.SharedObject;
29 | import sys.io.File;
30 |
31 | using StringTools;
32 |
33 | class AcadnmeBoot extends Screen implements IBoot
34 | {
35 | var defaultDir:String;
36 | var tileCtrl:TileControl;
37 | var launchScript:Map;
38 | var serverPassword:String;
39 | var serverEnabled:Bool;
40 | var store:SharedObject;
41 | var storeData:Dynamic;
42 |
43 | public function new()
44 | {
45 | super();
46 |
47 | Acadnme.boot = this;
48 |
49 | store = SharedObject.getLocal("acadnme-server");
50 | storeData = store.data;
51 |
52 | serverPassword = storeData.serverPassword ==null ? "" : storeData.serverPassword;
53 | serverEnabled = storeData.serverEnabled==null ? true : storeData.serverEnabled;
54 | Server.setEnabled(serverEnabled);
55 | Server.setPassword(serverPassword);
56 |
57 |
58 | Server.functions["launch"] = launch;
59 | Server.functions["apps"] = apps;
60 | Server.functions["uninstall"] = uninstall;
61 | Server.functions["reload"] = reloadSync;
62 | defaultDir = getDefaultDir();
63 |
64 | var pad = Skin.scale(2);
65 | Skin.guiLight = 0xf0f0f0;
66 | Skin.guiDark = 0xa0a0a0;
67 | Skin.replaceAttribs("DialogTitle", null, {
68 | align: Layout.AlignStretch | Layout.AlignCenterY,
69 | textAlign: "left",
70 | fontSize: Skin.scale(20),
71 | padding: new Rectangle(pad,pad,pad*2,pad*2),
72 | style: StyleUnderlineRect,
73 | fill: FillSolid(0xffffff,1),
74 | line: LineSolid(1,0xFF9800,2),
75 | });
76 |
77 | setItemLayout( new VerticalLayout([0,1]).stretch() );
78 |
79 | var titleBar = new Widget(["AppBar"], { fill: FillSolid(0xFF9800,1) } );
80 | titleBar.setItemLayout( new VerticalLayout().stretch() );
81 | addWidget(titleBar);
82 |
83 | var titleText = "";
84 | for(engine in Acadnme.getEngines())
85 | {
86 | if (titleText!="")
87 | titleText += " + ";
88 | titleText += engine.name + "(v" + engine.version + ")";
89 | }
90 | if (titleText=="")
91 | titleText = "No engine setting found";
92 | var accent = 0xFFF3E0;
93 | titleBar.addWidget( new TextLabel(titleText,{ textColor:0xffffff, fontSize:Skin.scale(24), bold:true, align:Layout.AlignCenterX|Layout.AlignTop }) );
94 | titleBar.addWidget(new TextLabel(defaultDir,{ textColor:accent, align: Layout.AlignCenterY|Layout.AlignLeft }) );
95 |
96 |
97 | var hostBar = new Widget({ align:Layout.AlignCenterY });
98 | hostBar.setItemLayout( new HorizontalLayout([1,0]).stretch() );
99 |
100 | hostBar.addWidget(new TextLabel("Host:" + getConnectionStatus(),{ textColor:accent, align:Layout.AlignCenterY|Layout.AlignStretch }) );
101 | hostBar.addWidget( Button.BMPButton( createMenuIcon(), onMenu, { style:StyleNone } ) );
102 | hostBar.build();
103 |
104 | titleBar.addWidget(hostBar);
105 | titleBar.build();
106 |
107 |
108 | tileCtrl = new TileControl(["Stretch"], { padding:new Rectangle(10,0,20,10), columnWidth:400});
109 | fillList();
110 | addWidget(tileCtrl);
111 |
112 | build();
113 | makeCurrent();
114 | }
115 |
116 | function onEnable(inValue:Bool)
117 | {
118 | serverEnabled = inValue;
119 | Server.setEnabled(inValue);
120 | Reflect.setField(storeData, "serverEnabled", inValue);
121 | store.flush();
122 | }
123 |
124 | function onPassword(inPassword:String)
125 | {
126 | serverPassword = inPassword;
127 | Server.setPassword(inPassword);
128 | Reflect.setField(storeData, "serverPassword", inPassword);
129 | store.flush();
130 | }
131 |
132 | function onMenu()
133 | {
134 | var panel = new gm2d.ui.Panel("Settings");
135 | panel.addLabelUI("Enable Network", new CheckButtons(serverEnabled, onEnable) );
136 | panel.addLabelUI("Network Password", new TextInput(serverPassword, onPassword) );
137 | panel.addTextButton("Ok", function() { gm2d.Game.closeDialog(); } );
138 | panel.showDialog(true, { chromeButtons:[] } );
139 | }
140 |
141 | function createMenuIcon()
142 | {
143 | var gap = Skin.scale(1);
144 | var bar = Skin.scale(2);
145 | var size = gap * 6+bar*5;
146 | var bmp = new BitmapData(size,size, true, 0x0);
147 | var y = gap;
148 | var shape = new nme.display.Shape();
149 | var gfx = shape.graphics;
150 | gfx.beginFill(0xffffff);
151 | for(r in 0...3)
152 | {
153 | gfx.drawRect(1,y,size-1,bar);
154 | y+= gap*2 + bar;
155 | }
156 | bmp.draw(shape);
157 | return bmp;
158 | }
159 |
160 |
161 | function uninstall(app:String)
162 | {
163 | var path = launchScript.get(app);
164 | if (path!=null)
165 | return uninstallScript(path);
166 | if (path==null)
167 | {
168 | for(k in launchScript.keys())
169 | {
170 | var parts = k.split(".");
171 | if (parts[ parts.length-1 ]==app)
172 | return uninstallScript( launchScript.get(k) );
173 | }
174 | }
175 | return 'Unknown application $app';
176 | }
177 |
178 |
179 | function launch(name:String) : String
180 | {
181 | if (name=="" || name==null)
182 | return "usage : launch appName";
183 |
184 | var path = launchScript.get(name);
185 | if (path==null)
186 | {
187 | for(k in launchScript.keys())
188 | {
189 | var parts = k.split(".");
190 | if (parts[ parts.length-1 ]==name)
191 | path = launchScript[k];
192 | }
193 | }
194 | if (path==null)
195 | return 'Unknown application $name';
196 | haxe.Timer.delay( function() Acadnme.runScript(path), 0 );
197 | return "launched...";
198 | };
199 |
200 |
201 | function apps() : String
202 | {
203 | var result = new Array();
204 | for(k in launchScript.keys())
205 | result.push(k + " (" + launchScript.get(k) + ")" );
206 |
207 | return result.join("\n");
208 | }
209 |
210 |
211 | public static function removeRecurse(directory:String):Void
212 | {
213 | if (FileSystem.exists(directory))
214 | {
215 | for(file in FileSystem.readDirectory(directory))
216 | {
217 | var path = directory + "/" + file;
218 |
219 | if (FileSystem.isDirectory(path))
220 | removeRecurse(path);
221 | else
222 | FileSystem.deleteFile(path);
223 | }
224 | FileSystem.deleteDirectory(directory);
225 | }
226 | }
227 |
228 |
229 | public function uninstallScript(path:String) : String
230 | {
231 | if (!haxe.io.Path.isAbsolute(path))
232 | return "Can' uninstall built-in app " + path;
233 |
234 | try
235 | {
236 | if (path.endsWith(".nme"))
237 | {
238 | FileSystem.deleteFile(path);
239 | return reloadSync();
240 | }
241 | else if (path.endsWith(".cppia"))
242 | {
243 | var dir = haxe.io.Path.directory(path);
244 | removeRecurse(dir);
245 | return reloadSync();
246 | }
247 | }
248 | catch(e:Dynamic)
249 | {
250 | return "Error uninstalling " + path + ":" + e;
251 | }
252 |
253 | return "Unknown uninstall type " + path;
254 | }
255 |
256 | public function onConnect()
257 | {
258 | }
259 |
260 |
261 | public function getDefaultDir():String
262 | {
263 | return Acadnme.directory;
264 | }
265 |
266 |
267 | public function getConnectionStatus():String
268 | {
269 | return Acadnme.connectionStatus;
270 | }
271 |
272 | public function remove()
273 | {
274 | gm2d.Game.destroy();
275 | }
276 |
277 | public function reloadSync()
278 | {
279 | haxe.Timer.delay( function() {
280 | fillList();
281 | relayout();
282 | }, 0);
283 | return "ok";
284 | }
285 |
286 | public function onSelect(path:String):Void
287 | {
288 | if (path!=null)
289 | Acadnme.runScript(path);
290 | }
291 |
292 | function addNmeApp(appName:String, details:Dynamic,path:String)
293 | {
294 | if (details!=null)
295 | {
296 | var bitmap:Widget = null;
297 | if (details.bmpIcon!=null)
298 | {
299 | var bmp:BitmapData = details.bmpIcon;
300 | if (bmp!=null && bmp.width>0 && bmp.height>0)
301 | {
302 | var size = gm2d.skin.Skin.scale(48);
303 | var square = new BitmapData(size,size,true,0x00000000);
304 | var bitmapDraw = new Bitmap(bmp);
305 | var scale = new nme.geom.Matrix();
306 | scale.a = size/bmp.width;
307 | scale.d = size/bmp.height;
308 | square.draw( bitmapDraw, scale );
309 | bitmap = new Image(square, { padding:3, wantsFocus:false } );
310 | }
311 | }
312 | else if (details.svgIcon!=null)
313 | bitmap = createSvgBmp( details.svgIcon );
314 |
315 | if (bitmap==null)
316 | bitmap = createSvgBmp( Assets.getString("default.svg") );
317 |
318 | var idx = 0;
319 | while(true)
320 | {
321 | var key = idx==0 ? appName : appName + "." + idx;
322 | if (!launchScript.exists(key))
323 | {
324 | launchScript[key] = path;
325 | break;
326 | }
327 | idx++;
328 | }
329 |
330 | var disabled = getHeaderError(details.engines);
331 |
332 | tileCtrl.add(createDetails(bitmap, defaultDir,details.name,details.developer, disabled, path));
333 | }
334 | }
335 |
336 | public function getHeaderError(engines:Array<{name:String, version:String}>) : String
337 | {
338 | if (engines==null || engines.length==0)
339 | return "No version";
340 |
341 | var haveEngines:Array<{name:String, version:String}> = Acadnme.getEngines();
342 | if (engines!=null && haveEngines!=null)
343 | {
344 | for(e in engines)
345 | for(h in haveEngines)
346 | if (e.name==h.name && e.version==h.version)
347 | return null;
348 | }
349 | return "Version mismatch " + engines[0].name + " " + engines[0].version;
350 | }
351 |
352 |
353 | public function fillList()
354 | {
355 | launchScript = new Map();
356 | tileCtrl.clear();
357 |
358 |
359 | // User apps first...
360 | try
361 | {
362 | for( name in FileSystem.readDirectory(defaultDir))
363 | {
364 | var title = name;
365 | var dir = defaultDir + "/" +name;
366 | if (sys.FileSystem.isDirectory(dir))
367 | {
368 | var script = dir+"/ScriptMain.cppia";
369 | if (!FileSystem.exists(script))
370 | continue;
371 |
372 | var disabled = "No manifest";
373 | var manifest = dir+"/manifest.json";
374 | var developer = "unknown";
375 | if (FileSystem.exists(manifest))
376 | {
377 | disabled = "Bad manifest";
378 | try
379 | {
380 | var content = File.getContent(manifest);
381 | var json = haxe.Json.parse(content);
382 | if (json!=null)
383 | {
384 | var header = json.header;
385 | if (header!=null)
386 | {
387 | var engines = header.engines;
388 | if (disabled!=null)
389 | disabled = getHeaderError(engines);
390 | if (header.developer!=null)
391 | developer = "developer:" + header.developer;
392 | if (header.name!=null)
393 | title = header.name;
394 | }
395 | }
396 | }
397 | catch(e:Dynamic) { }
398 | }
399 |
400 |
401 | var bitmap:Widget = null;
402 | for(ext in ["svg", "png", "jpg"])
403 | {
404 | var icon = dir + "/icon." + ext;
405 | if (sys.FileSystem.exists(icon))
406 | {
407 | if (ext=="svg")
408 | {
409 | try
410 | {
411 | var src = sys.io.File.getContent(icon);
412 | if (src!=null)
413 | bitmap = createSvgBmp(src);
414 | }
415 | }
416 | else
417 | bitmap = createBmp(icon);
418 | }
419 | if (bitmap!=null)
420 | break;
421 | }
422 | if (bitmap==null)
423 | bitmap = createSvgBmp( Assets.getString("default.svg") );
424 |
425 | var path = disabled==null ? script : null;
426 | if (path!=null)
427 | launchScript[name] = path;
428 | tileCtrl.add(createDetails(bitmap, dir,title,developer,disabled, path));
429 | }
430 | }
431 | }
432 | catch(e:Dynamic)
433 | {
434 | }
435 |
436 |
437 |
438 | // Distributed apps
439 | var nmeDir = Acadnme.getNmeAppsDir();
440 | if (nmeDir!=null)
441 | {
442 | try
443 | {
444 | for(app in FileSystem.readDirectory(nmeDir))
445 | {
446 | if (app.endsWith(".nme") && app!="AcadnmeBoot.nme" )
447 | {
448 | var nmePath = nmeDir + "/" + app;
449 | var details = nme.script.Nme.getFileHeader(nmePath);
450 | addNmeApp(app,details,nmePath);
451 | }
452 | }
453 | }
454 | catch(e:Dynamic) { }
455 | }
456 |
457 | // Build-in apps
458 | var assets = nme.Assets.info;
459 | for(asset in assets.keys())
460 | {
461 | if (asset.endsWith(".nme") && asset!="AcadnmeBoot.nme")
462 | {
463 | if (nme.Assets.hasBytes(asset))
464 | {
465 | var bytes = nme.Assets.getBytes(asset);
466 | if (bytes==null)
467 | trace("No bytes for " + asset + "?");
468 | else
469 | {
470 | var details = nme.script.Nme.getBytesHeader( nme.Assets.getBytes(asset) );
471 | addNmeApp(asset,details,asset);
472 | }
473 | }
474 | }
475 | }
476 |
477 |
478 |
479 | }
480 |
481 | public function createDetails(bitmap:Widget, dir:String, name:String, developer:String, inDisabled:String, path:String)
482 | {
483 | var result = new gm2d.ui.Control(["SimpleTile"],{ onEnter:function() onSelect(path) } );
484 | result.addChild(bitmap);
485 | var row = new HorizontalLayout();
486 | row.add(bitmap.getLayout());
487 |
488 | var layout = new VerticalLayout();
489 | layout.setAlignment(Layout.AlignLeft|Layout.AlignCenterY);
490 | row.add(layout);
491 |
492 | var text = new TextLabel(name,{bold:true});
493 | result.addChild(text);
494 | layout.add(text.getLayout().setAlignment(Layout.AlignLeft));
495 |
496 | var text = new TextLabel(" " + (inDisabled!=null ? inDisabled : developer) );
497 | result.addChild(text);
498 | layout.add(text.getLayout().setAlignment(Layout.AlignLeft));
499 |
500 | result.setItemLayout( row.setAlignment(Layout.AlignLeft|Layout.AlignCenterY) );
501 | result.getLayout().stretch();
502 | result.build();
503 |
504 | return result;
505 | }
506 |
507 | public function createBmp(filename:String) : Widget
508 | {
509 | return null;
510 | }
511 |
512 | public function createSvgBmp(inSrc:String) : Widget
513 | {
514 | try
515 | {
516 | var xml = Xml.parse(inSrc);
517 | var svg = new Svg(xml);
518 | var renderer = new SvgRenderer(svg);
519 | var w = renderer.width;
520 | var h = renderer.height;
521 | if (w==0 || h==0)
522 | return null;
523 |
524 | var size = gm2d.skin.Skin.scale(48);
525 | var sx = size/w;
526 | var sh = size/h;
527 | var scale = Math.min(sx,sh);
528 | var bmp = renderer.renderBitmap( new Rectangle(0,0,size/scale,size/scale), scale );
529 | return new Image(bmp, { padding:3, wantsFocus:false } );
530 | }
531 | catch(e:Dynamic) { }
532 | return null;
533 | }
534 |
535 |
536 | public function browse()
537 | {
538 | gm2d.ui.FileOpen.load("Select Cppia File", function(name:String, bytes:ByteArray)
539 | {
540 | if (bytes!= null)
541 | {
542 | }
543 | }, "Cppia Script Files|*.cppia");
544 |
545 | }
546 | }
547 |
548 |
549 |
550 |
--------------------------------------------------------------------------------
/engine/assets/banner.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
276 |
--------------------------------------------------------------------------------
/engine/assets/icon.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
171 |
--------------------------------------------------------------------------------
/engine/build.nmml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
20 |
21 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/engine/src/Acadnme.hx:
--------------------------------------------------------------------------------
1 | import nme.display.Sprite;
2 | import nme.display.Stage;
3 | import nme.text.TextField;
4 | import nme.events.Event;
5 | import nme.system.System;
6 | import nme.ui.Scale;
7 | import nme.utils.Float32Array;
8 | import nme.utils.UInt8Array;
9 | import nme.events.KeyboardEvent;
10 | import AllNme;
11 | import Sys;
12 |
13 | import nme.script.Server;
14 | import nme.script.IScriptHandler;
15 |
16 |
17 | class Acadnme extends Sprite implements IScriptHandler
18 | {
19 | var script:String;
20 | var server:Server;
21 | var listener:Stage;
22 |
23 | static var instance:Acadnme;
24 | public static var directory:String = null;
25 | public static var connectionStatus:String;
26 |
27 | // Set by script
28 | public static var boot:IBoot;
29 |
30 | public function new()
31 | {
32 | super();
33 |
34 | instance = this;
35 | var startServer = #if emscripten false #else true #end;
36 |
37 | // For attaching a debugger
38 | var delay = Sys.getEnv("ACADNME_DELAY")!=null;
39 |
40 | var args = Sys.args();
41 | var idx = 0;
42 |
43 | #if android
44 | installBackHandler();
45 | #end
46 |
47 | while(idx downTime + 2.0 )
152 | nme.system.System.restart();
153 | }
154 | downTime = 0.0;
155 | } );
156 |
157 | }
158 |
159 | function onClick(_)
160 | {
161 | stage.removeEventListener( nme.events.MouseEvent.CLICK, onClick );
162 | run(script);
163 | }
164 |
165 |
166 | // IScriptHandler
167 | public function scriptLog(inMessage:String)
168 | {
169 | trace("acadnme: " + inMessage);
170 | }
171 |
172 |
173 | public function scriptRunSync(f:Void->Void) : Void
174 | {
175 | haxe.Timer.delay(f,0);
176 | }
177 |
178 | public function onEnter(_)
179 | {
180 | while(server!=null)
181 | {
182 | var func = server.pollQueue();
183 | if (func==null)
184 | break;
185 | clearBoot();
186 | func();
187 | }
188 | }
189 |
190 |
191 | function clearBoot()
192 | {
193 | if (boot!=null)
194 | {
195 | boot.remove();
196 | boot = null;
197 | }
198 | if (listener!=null)
199 | {
200 | listener.removeEventListener(Event.ENTER_FRAME, onEnter);
201 | listener = null;
202 | }
203 | }
204 |
205 | public function run(inScript:String)
206 | {
207 | clearBoot();
208 |
209 | if (nme.Assets.hasBytes(inScript))
210 | {
211 | trace("Run resource " + inScript);
212 | nme.script.Nme.runBytes(nme.Assets.getBytes(inScript));
213 | }
214 | else
215 | {
216 | trace("Run file " + inScript);
217 | nme.script.Nme.runFile(inScript);
218 | }
219 | }
220 |
221 | public function runBoot()
222 | {
223 | if (nme.Assets.hasBytes("AcadnmeBoot.nme"))
224 | {
225 | trace("Run AcadnmeBoot.nme");
226 | nme.script.Nme.runBytes(nme.Assets.getBytes("AcadnmeBoot.nme"));
227 | }
228 | else
229 | {
230 | var appsDir = getNmeAppsDir();
231 | if (appsDir==null)
232 | trace("Could not find boot directory");
233 | var file = appsDir+"/AcadnmeBoot.nme";
234 | nme.script.Nme.runFile(file);
235 | }
236 | }
237 |
238 |
239 | @:keep // Used by boot
240 | public static function runScript(inScript:String)
241 | {
242 | instance.run(inScript);
243 | }
244 |
245 | @:keep // Used by boot
246 | public static function getEngines() : Array< {name:String, version:String} >
247 | {
248 | #if cppia
249 | return [];
250 | #else
251 | return cast ApplicationMain.engines;
252 | #end
253 | }
254 |
255 | }
256 |
257 |
--------------------------------------------------------------------------------
/engine/src/AllNme.hx:
--------------------------------------------------------------------------------
1 | import nme.app.AppEvent;
2 | import nme.app.Application;
3 | import nme.app.EventId;
4 | import nme.app.EventName;
5 | import nme.app.FrameTimer;
6 | import nme.app.IAppEventHandler;
7 | import nme.app.IPollClient;
8 | import nme.app.NmeApplication;
9 | import nme.app.Window;
10 | import nme.AssetInfo;
11 | import nme.Assets;
12 | import nme.AssetType;
13 | import nme.bare.Surface;
14 | import nme.display.Bitmap;
15 | import nme.display.BitmapData;
16 | import nme.display.BitmapDataChannel;
17 | import nme.display.BitmapInt32;
18 | import nme.display.BlendMode;
19 | import nme.display.CapsStyle;
20 | import nme.display.DirectRenderer;
21 | import nme.display.DisplayObject;
22 | import nme.display.DisplayObjectContainer;
23 | import nme.display.FPS;
24 | import nme.display.GradientType;
25 | import nme.display.Graphics;
26 | import nme.display.GraphicsBitmapFill;
27 | import nme.display.GraphicsEndFill;
28 | import nme.display.GraphicsGradientFill;
29 | import nme.display.GraphicsPath;
30 | import nme.display.GraphicsPathCommand;
31 | import nme.display.GraphicsPathWinding;
32 | import nme.display.GraphicsSolidFill;
33 | import nme.display.GraphicsStroke;
34 | import nme.display.IBitmapDrawable;
35 | import nme.display.IGraphicsData;
36 | import nme.display.InteractiveObject;
37 | import nme.display.InterpolationMethod;
38 | import nme.display.JointStyle;
39 | import nme.display.LineScaleMode;
40 | import nme.display.Loader;
41 | import nme.display.LoaderInfo;
42 | import nme.display.ManagedStage;
43 | import nme.display.MovieClip;
44 | import nme.display.OpenGLView;
45 | import nme.display.PixelSnapping;
46 | import nme.display.Shape;
47 | import nme.display.SimpleButton;
48 | import nme.display.SpreadMethod;
49 | import nme.display.Sprite;
50 | import nme.display.Stage;
51 | import nme.display.Stage3D;
52 | import nme.display.StageAlign;
53 | import nme.display.StageDisplayState;
54 | import nme.display.StageQuality;
55 | import nme.display.StageScaleMode;
56 | import nme.display.Tilesheet;
57 | import nme.display.TriangleCulling;
58 | import nme.display3D.Context3D;
59 | import nme.display3D.Context3DBlendFactor;
60 | import nme.display3D.Context3DClearMask;
61 | import nme.display3D.Context3DCompareMode;
62 | import nme.display3D.Context3DProfile;
63 | import nme.display3D.Context3DProgramType;
64 | import nme.display3D.Context3DRenderMode;
65 | import nme.display3D.Context3DStencilAction;
66 | import nme.display3D.Context3DTextureFormat;
67 | import nme.display3D.Context3DTriangleFace;
68 | import nme.display3D.Context3DUtils;
69 | import nme.display3D.Context3DVertexBufferFormat;
70 | import nme.display3D.IndexBuffer3D;
71 | import nme.display3D.Program3D;
72 | import nme.display3D.shaders.glsl.GLSLFragmentShader;
73 | import nme.display3D.shaders.glsl.GLSLProgram;
74 | import nme.display3D.shaders.glsl.GLSLShader;
75 | import nme.display3D.shaders.glsl.GLSLVertexShader;
76 | import nme.display3D.shaders.Shader;
77 | import nme.display3D.shaders.ShaderUtils;
78 | import nme.display3D.textures.CubeTexture;
79 | import nme.display3D.textures.RectangleTexture;
80 | import nme.display3D.textures.Texture;
81 | import nme.display3D.textures.TextureBase;
82 | import nme.display3D.VertexBuffer3D;
83 | import nme.errors.ArgumentError;
84 | import nme.errors.EOFError;
85 | import nme.errors.Error;
86 | import nme.errors.IllegalOperationError;
87 | import nme.errors.RangeError;
88 | import nme.errors.SecurityError;
89 | import nme.errors.TypeError;
90 | import nme.events.AccelerometerEvent;
91 | import nme.events.AsyncErrorEvent;
92 | import nme.events.ErrorEvent;
93 | import nme.events.Event;
94 | import nme.events.EventDispatcher;
95 | import nme.events.EventPhase;
96 | import nme.events.FocusEvent;
97 | import nme.events.HTTPStatusEvent;
98 | import nme.events.IEventDispatcher;
99 | import nme.events.IOErrorEvent;
100 | import nme.events.JoystickEvent;
101 | import nme.events.KeyboardEvent;
102 | import nme.events.MouseEvent;
103 | import nme.events.NetStatusEvent;
104 | import nme.events.ProgressEvent;
105 | import nme.events.SampleDataEvent;
106 | import nme.events.SecurityErrorEvent;
107 | import nme.events.StageVideoAvailabilityEvent;
108 | import nme.events.StageVideoEvent;
109 | import nme.events.StatusEvent;
110 | import nme.events.SystemEvent;
111 | import nme.events.TextEvent;
112 | import nme.events.TimerEvent;
113 | import nme.events.TouchEvent;
114 | import nme.external.ExternalInterface;
115 | import nme.feedback.Haptic;
116 | import nme.filesystem.File;
117 | import nme.filesystem.StorageVolume;
118 | import nme.filesystem.StorageVolumeInfo;
119 | import nme.filters.BitmapFilter;
120 | import nme.filters.BitmapFilterQuality;
121 | import nme.filters.BitmapFilterType;
122 | import nme.filters.BlurFilter;
123 | import nme.filters.ColorMatrixFilter;
124 | import nme.filters.DropShadowFilter;
125 | import nme.filters.GlowFilter;
126 | import nme.geom.ColorTransform;
127 | import nme.geom.Matrix;
128 | import nme.geom.Matrix3D;
129 | import nme.geom.Point;
130 | import nme.geom.Rectangle;
131 | import nme.geom.Transform;
132 | import nme.geom.Vector3D;
133 | import nme.gl.Buffer;
134 | import nme.gl.GL;
135 | import nme.gl.GLActiveInfo;
136 | import nme.gl.GLBuffer;
137 | import nme.gl.GLContextAttributes;
138 | import nme.gl.GLFramebuffer;
139 | import nme.gl.GLObject;
140 | import nme.gl.GLProgram;
141 | import nme.gl.GLRenderbuffer;
142 | import nme.gl.GLShader;
143 | import nme.gl.GLTexture;
144 | import nme.gl.GLUniformLocation;
145 | import nme.gl.Utils;
146 | import nme.Lib;
147 | import nme.Loader;
148 | import nme.macros.Embed;
149 | import nme.media.Camera;
150 | import nme.media.ID3Info;
151 | import nme.media.Sound;
152 | import nme.media.SoundChannel;
153 | import nme.media.SoundLoaderContext;
154 | import nme.media.SoundTransform;
155 | import nme.media.StageVideo;
156 | import nme.media.StageVideoAvailability;
157 | import nme.media.Video;
158 | import nme.media.VideoStatus;
159 | import nme.Memory;
160 | import nme.native.ARGB;
161 | import nme.native.ImageBuffer;
162 | import nme.native.Include;
163 | import nme.native.NativeEvent;
164 | import nme.native.Object;
165 | import nme.net.FileFilter;
166 | import nme.net.NetConnection;
167 | import nme.net.NetStream;
168 | import nme.net.SharedObject;
169 | import nme.net.SharedObjectFlushStatus;
170 | import nme.net.URLLoader;
171 | import nme.net.URLLoaderDataFormat;
172 | import nme.net.URLRequest;
173 | import nme.net.URLRequestHeader;
174 | import nme.net.URLRequestMethod;
175 | import nme.net.URLVariables;
176 | import nme.preloader.Basic;
177 | import nme.script.Client;
178 | import nme.script.IScriptHandler;
179 | import nme.script.Nme;
180 | import nme.script.Server;
181 | import nme.script.Value;
182 | import nme.sensors.Accelerometer;
183 | import nme.system.ApplicationDomain;
184 | import nme.system.Capabilities;
185 | import nme.system.LoaderContext;
186 | import nme.system.SecurityDomain;
187 | import nme.system.System;
188 | import nme.text.AntiAliasType;
189 | import nme.text.Font;
190 | import nme.text.FontStyle;
191 | import nme.text.FontType;
192 | import nme.text.GridFitType;
193 | import nme.text.NMEFont;
194 | import nme.text.TextField;
195 | import nme.text.TextFieldAutoSize;
196 | import nme.text.TextFieldType;
197 | import nme.text.TextFormat;
198 | import nme.text.TextFormatAlign;
199 | import nme.text.TextLineMetrics;
200 | import nme.ui.Acceleration;
201 | import nme.ui.Accelerometer;
202 | import nme.ui.Keyboard;
203 | import nme.ui.Mouse;
204 | import nme.ui.Multitouch;
205 | import nme.ui.MultitouchInputMode;
206 | import nme.ui.Scale;
207 | import nme.utils.ArrayBuffer;
208 | import nme.utils.ArrayBufferView;
209 | import nme.utils.ByteArray;
210 | import nme.utils.CompressionAlgorithm;
211 | import nme.utils.Endian;
212 | import nme.utils.Float32Array;
213 | import nme.utils.IDataInput;
214 | import nme.utils.IDataOutput;
215 | import nme.utils.IMemoryRange;
216 | import nme.utils.Int16Array;
217 | import nme.utils.Int32Array;
218 | import nme.utils.Object;
219 | import nme.utils.Timer;
220 | import nme.utils.UInt8Array;
221 | import nme.utils.WeakRef;
222 | import nme.utils.XmlRelay;
223 | import nme.Vector;
224 | import nme.Version;
225 | import nme.xml.XML;
226 | import haxe.Timer;
227 | import nme.android.Bluetooth;
228 | import nme.utils.JNI;
229 | import nme.JNI;
230 |
231 | class AllNme
232 | {
233 | }
234 |
235 |
--------------------------------------------------------------------------------
/engine/src/IBoot.hx:
--------------------------------------------------------------------------------
1 | interface IBoot
2 | {
3 | public function remove():Void;
4 | }
5 |
--------------------------------------------------------------------------------
/haxelib.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "acadnme",
3 | "url": "https://github.com/nmehost",
4 | "license": "MIT",
5 | "tags": [ "cpp", "nme", "cppia", "acadnme", "android", "ios" ],
6 | "description": "Acadnme provides a scripting host for Nme applications on iOS, Android, Windows, Mac and Linux platforms",
7 | "version": "5.6.0",
8 | "binaryversion": "11",
9 | "releasenote": "see Changes.md",
10 | "contributors": [ "gamehaxe" ],
11 | "dependencies": {}
12 | }
13 |
14 |
--------------------------------------------------------------------------------
/include.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/tools/run/RunMain.hx:
--------------------------------------------------------------------------------
1 | using StringTools;
2 |
3 | class RunMain
4 | {
5 | public static function main()
6 | {
7 | var arguments = Sys.args();
8 |
9 | if (arguments.length > 0)
10 | {
11 | // When the command-line tools are called from haxelib,
12 | // the last argument is the user directory and the
13 | // path to acadnme is the current working directory
14 | arguments.pop();
15 | }
16 |
17 | var system = Sys.systemName();
18 | var sys = system.toLowerCase().substr(0,3);
19 | var exe:String = switch(sys)
20 | {
21 | case "win" : ".\\bin\\Windows\\Acadnme\\Acadnme.exe";
22 | case "lin" : "./bin/Linux/Acadnme/Acadnme";
23 | case "mac" : "./bin/Mac/Acadnme.app/Contents/MacOS/Acadnme";
24 | default:
25 | throw 'Unkown host system $system';
26 | }
27 |
28 | if (!exe.endsWith(".exe"))
29 | Sys.command("chmod", ["755", exe]);
30 |
31 | Sys.command(exe, arguments);
32 | }
33 | }
34 |
35 |
--------------------------------------------------------------------------------
/tools/run/compile.hxml:
--------------------------------------------------------------------------------
1 | -neko ../../run.n
2 | -main RunMain
3 | -D neko_v1
4 | -debug
5 |
--------------------------------------------------------------------------------