diff --git a/Makefile b/Makefile index bca8e47..7fb2ab2 100644 --- a/Makefile +++ b/Makefile @@ -18,11 +18,6 @@ PLATFORMER_OBJ_FILES = \ obj/Hero.o \ obj/Kitten.o \ obj/platformer.o - -squids_OBJ_FILES = \ - obj/SplineTree.o \ - obj/squids.o - # COMPILER CC = clang CPP = clang++ @@ -55,25 +50,17 @@ CFLAGS += -arch i386 AFLAGS = 32 # AFLAGS = 64 -# stest: bin/squids bin/squids.bin -# bin/squids - test : bin/platformer bin/platformer.bin - cp platformer/assets/song.mid bin/song.mid + cp demo/assets/song.mid bin/song.mid bin/platformer -bin/squids: lib/liblittlepolygon.a $(squids_OBJ_FILES) - $(CPP) -o $@ $(CFLAGS) $(CCFLAGS) $(LIBS) $(squids_OBJ_FILES) - -bin/squids.bin: squids/assets/* tools/*.py - tools/export_asset_bin.py squids/assets/assets.yaml $@ $(AFLAGS) - - bin/platformer: lib/liblittlepolygon.a $(PLATFORMER_OBJ_FILES) + mkdir -p bin $(CPP) -o $@ $(CFLAGS) $(CCFLAGS) $(LIBS) $(PLATFORMER_OBJ_FILES) -bin/platformer.bin: platformer/assets/* tools/*.py platformer/tools/*.py - platformer/tools/export_game_assets.py platformer/assets/assets.yaml $@ $(AFLAGS) +bin/platformer.bin: demo/assets/* tools/*.py demo/tools/*.py + mkdir -p bin + demo/tools/export_game_assets.py demo/assets/assets.yaml $@ $(AFLAGS) clean: rm -f lib/* @@ -81,18 +68,18 @@ clean: rm -f bin/* lib/liblittlepolygon.a: $(LIBRARY_OBJ_FILES) + mkdir -p lib ar rcs $@ $^ obj/%.o: src/%.c + mkdir -p obj $(CC) $(CFLAGS) -c -o $@ $< obj/%.o: src/%.cpp include/*.h + mkdir -p obj $(CPP) $(CFLAGS) $(CCFLAGS) -c -o $@ $< -obj/%.o: platformer/src/%.cpp platformer/src/*.h - $(CPP) $(CFLAGS) $(CCFLAGS) -c -o $@ $< - -obj/%.o: squids/src/%.cpp # squids/src/*.h +obj/%.o: demo/src/%.cpp demo/src/*.h + mkdir -p obj $(CPP) $(CFLAGS) $(CCFLAGS) -c -o $@ $< - diff --git a/platformer/assets/assets.yaml b/demo/assets/assets.yaml similarity index 100% rename from platformer/assets/assets.yaml rename to demo/assets/assets.yaml diff --git a/platformer/assets/bg.psd b/demo/assets/bg.psd similarity index 100% rename from platformer/assets/bg.psd rename to demo/assets/bg.psd diff --git a/platformer/assets/button.psd b/demo/assets/button.psd similarity index 100% rename from platformer/assets/button.psd rename to demo/assets/button.psd diff --git a/platformer/assets/button.wav b/demo/assets/button.wav similarity index 100% rename from platformer/assets/button.wav rename to demo/assets/button.wav diff --git a/platformer/assets/button_down.psd b/demo/assets/button_down.psd similarity index 100% rename from platformer/assets/button_down.psd rename to demo/assets/button_down.psd diff --git a/platformer/assets/button_right.psd b/demo/assets/button_right.psd similarity index 100% rename from platformer/assets/button_right.psd rename to demo/assets/button_right.psd diff --git a/platformer/assets/button_shift.psd b/demo/assets/button_shift.psd similarity index 100% rename from platformer/assets/button_shift.psd rename to demo/assets/button_shift.psd diff --git a/platformer/assets/button_up.psd b/demo/assets/button_up.psd similarity index 100% rename from platformer/assets/button_up.psd rename to demo/assets/button_up.psd diff --git a/platformer/assets/catturn.wav b/demo/assets/catturn.wav similarity index 100% rename from platformer/assets/catturn.wav rename to demo/assets/catturn.wav diff --git a/platformer/assets/death.wav b/demo/assets/death.wav similarity index 100% rename from platformer/assets/death.wav rename to demo/assets/death.wav diff --git a/platformer/assets/explosion.psd b/demo/assets/explosion.psd similarity index 100% rename from platformer/assets/explosion.psd rename to demo/assets/explosion.psd diff --git a/platformer/assets/explosion.wav b/demo/assets/explosion.wav similarity index 100% rename from platformer/assets/explosion.wav rename to demo/assets/explosion.wav diff --git a/platformer/assets/fire.psd b/demo/assets/fire.psd similarity index 100% rename from platformer/assets/fire.psd rename to demo/assets/fire.psd diff --git a/platformer/assets/footfall.wav b/demo/assets/footfall.wav similarity index 100% rename from platformer/assets/footfall.wav rename to demo/assets/footfall.wav diff --git a/platformer/assets/hero.psd b/demo/assets/hero.psd similarity index 100% rename from platformer/assets/hero.psd rename to demo/assets/hero.psd diff --git a/platformer/assets/hero_idle.png b/demo/assets/hero_idle.png similarity index 100% rename from platformer/assets/hero_idle.png rename to demo/assets/hero_idle.png diff --git a/platformer/assets/jump.wav b/demo/assets/jump.wav similarity index 100% rename from platformer/assets/jump.wav rename to demo/assets/jump.wav diff --git a/platformer/assets/kitten.png b/demo/assets/kitten.png similarity index 100% rename from platformer/assets/kitten.png rename to demo/assets/kitten.png diff --git a/platformer/assets/kitten.psd b/demo/assets/kitten.psd similarity index 100% rename from platformer/assets/kitten.psd rename to demo/assets/kitten.psd diff --git a/platformer/assets/land.wav b/demo/assets/land.wav similarity index 100% rename from platformer/assets/land.wav rename to demo/assets/land.wav diff --git a/platformer/assets/nokiafc22.ttf b/demo/assets/nokiafc22.ttf similarity index 100% rename from platformer/assets/nokiafc22.ttf rename to demo/assets/nokiafc22.ttf diff --git a/platformer/assets/pickup.wav b/demo/assets/pickup.wav similarity index 100% rename from platformer/assets/pickup.wav rename to demo/assets/pickup.wav diff --git a/platformer/assets/put.wav b/demo/assets/put.wav similarity index 100% rename from platformer/assets/put.wav rename to demo/assets/put.wav diff --git a/platformer/assets/song.mid b/demo/assets/song.mid similarity index 100% rename from platformer/assets/song.mid rename to demo/assets/song.mid diff --git a/platformer/assets/test.png b/demo/assets/test.png similarity index 100% rename from platformer/assets/test.png rename to demo/assets/test.png diff --git a/platformer/assets/test.tmx b/demo/assets/test.tmx similarity index 100% rename from platformer/assets/test.tmx rename to demo/assets/test.tmx diff --git a/platformer/assets/throw.wav b/demo/assets/throw.wav similarity index 100% rename from platformer/assets/throw.wav rename to demo/assets/throw.wav diff --git a/platformer/src/Environment.cpp b/demo/src/Environment.cpp similarity index 100% rename from platformer/src/Environment.cpp rename to demo/src/Environment.cpp diff --git a/platformer/src/Hero.cpp b/demo/src/Hero.cpp similarity index 100% rename from platformer/src/Hero.cpp rename to demo/src/Hero.cpp diff --git a/platformer/src/Kitten.cpp b/demo/src/Kitten.cpp similarity index 100% rename from platformer/src/Kitten.cpp rename to demo/src/Kitten.cpp diff --git a/platformer/src/platformer.cpp b/demo/src/platformer.cpp similarity index 100% rename from platformer/src/platformer.cpp rename to demo/src/platformer.cpp diff --git a/platformer/src/platformer.h b/demo/src/platformer.h similarity index 100% rename from platformer/src/platformer.h rename to demo/src/platformer.h diff --git a/platformer/tools/export_game_assets.py b/demo/tools/export_game_assets.py similarity index 100% rename from platformer/tools/export_game_assets.py rename to demo/tools/export_game_assets.py diff --git a/squids/assets/Apache License.txt b/squids/assets/Apache License.txt deleted file mode 100755 index 989e2c5..0000000 --- a/squids/assets/Apache License.txt +++ /dev/null @@ -1,201 +0,0 @@ -Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file diff --git a/squids/assets/DroidSans-Bold.ttf b/squids/assets/DroidSans-Bold.ttf deleted file mode 100755 index 7ac04b6..0000000 Binary files a/squids/assets/DroidSans-Bold.ttf and /dev/null differ diff --git a/squids/assets/DroidSans.ttf b/squids/assets/DroidSans.ttf deleted file mode 100755 index 767c63a..0000000 Binary files a/squids/assets/DroidSans.ttf and /dev/null differ diff --git a/squids/assets/_max.gif b/squids/assets/_max.gif deleted file mode 100644 index 8caff78..0000000 Binary files a/squids/assets/_max.gif and /dev/null differ diff --git a/squids/assets/assets.yaml b/squids/assets/assets.yaml deleted file mode 100644 index 6786be2..0000000 --- a/squids/assets/assets.yaml +++ /dev/null @@ -1,6 +0,0 @@ - -font/droid: { path: DroidSans-Bold.ttf, size: 16 } - -texture/sprites: - image/max: { path: _max.gif, pivot: center } - diff --git a/squids/assets/templates.yaml b/squids/assets/templates.yaml deleted file mode 100644 index aad504a..0000000 --- a/squids/assets/templates.yaml +++ /dev/null @@ -1,76 +0,0 @@ -# This is an example of creating scenes using littlepolygon_go. Each -# template is a recipe for building a game object with a number of -# predefined components. These templates can be refined and ultimately -# instantiated, every level adding or overriding parameters like in CSS. - -# The types of the components are enumerated in the python scripts for -# this project which knows how to serialize them to asset userdata. - -# just a plain-old shared property, using typical YAML anchor stuff -squidColor: &sc - r: 155 - g: 255 - b: 75 - -eyeColor: &ec - r: 75 - g: 155 - b: 255 - - -template/squid: - description: a basic squid with an eye and three tentacles - enabled: Yes - - - - - - -# A basic squid template with three tentacles and an eye. The "slash" syntax -# is a compact type/name idiom. -go/squid: - description: a basic squid with an eye and three tentacles - enabled: Yes - tentacle/tentacle1: - color: *sc - angle: -30 - length: 96 - tentacle/tentacle2: - color: *sc - angle: 0 - length: 128 - tentacle/tentacle3: - color: *sc - angle: 30 - length: 96 - eye/myeyeball: - color: *ec - radius: 64 - -# now we instantiate a bunch of squids. We use a special bang! to denote -# actual concrete instances - -squid!/squid1: - position: [10,10] - -squid!/squid2: - position: [20,10] - -differentColor: &dc - r: 255 - g: 255 - b: 35 - -# squid 3 overrides the color - -squid!/squid3: - position: [30,10] - tentacle/tentacle1: - color: *dc - tentacle/tentacle2: - color: *dc - tentacle/tentacle3: - color: *dc - -# you'll be able to look this fella up at runtime with find(goContext, "squid3") diff --git a/squids/src/DisplayTree.h b/squids/src/DisplayTree.h deleted file mode 100644 index a6d6e36..0000000 --- a/squids/src/DisplayTree.h +++ /dev/null @@ -1,12 +0,0 @@ -#include - -class DisplayTree { -private: - FkTreeRef tree; - -public: - DisplayTree(FkTreeRef aTree) : tree(aTre) {} - - - -}; \ No newline at end of file diff --git a/squids/src/SplineTree.cpp b/squids/src/SplineTree.cpp deleted file mode 100644 index 7f703e8..0000000 --- a/squids/src/SplineTree.cpp +++ /dev/null @@ -1,88 +0,0 @@ -#include "SplineTree.h" -#include - -SplineTree::SplineTree() { -} - -Knot* SplineTree::addKnot(const AffineMatrix *tform, vec2 attitude) { - auto result = knotPool.alloc(); - result->tform = tform; - result->attitude = attitude; - return result; -} - -void SplineTree::removeKnot(Knot *knot) { - // remove any segments that start or end with this - auto p = segmentPool.begin(); - while(p != segmentPool.end()) { - if (p->k0 == knot || p->k1 == knot) { - segmentPool.release(p); - } else { - ++p; - } - } - knotPool.release(knot); -} - -void SplineTree::addSegment(const Knot *k0, const Knot *k1) { - auto p = std::find_if( - segmentPool.begin(), - segmentPool.end(), - [k0,k1](const Segment &s) { return s.matches(k0,k1); } - ); - if (p == segmentPool.end()) { - auto s = segmentPool.alloc(); - s->k0 = k0; - s->k1 = k1; - } -} - -void SplineTree::removeSegment(const Knot *k0, const Knot *k1) { - auto p = std::find_if( - segmentPool.begin(), - segmentPool.end(), - [k0,k1](const Segment &s) { return s.matches(k0,k1); } - ); - if (p != segmentPool.end()) { - segmentPool.release(p); - } -} - -void SplineTree::draw(SplinePlotterRef splines, Color c, float ss) { - for (auto& s : segmentPool) { - auto p0 = s.k0->tform->t; - auto p1 = s.k1->tform->t; - auto u0 = s.k0->tform->transformVector(s.k0->attitude); - auto u1 = s.k1->tform->transformVector(s.k1->attitude); - splines.plot( - hermiteMatrix( - vec4f(p0.x, p0.y, 0, 0), - vec4f(p1.x, p1.y, 0, 0), - vec4f(u0.x, u0.y, 0, 0), - vec4f(u1.x, u1.y, 0, 0) - ), - eccentricStroke(ss * 12, ss * -6, ss * 12), - c - ); - } -} - -void SplineTree::drawKnots(LinePlotterRef lines, Color c) { - Knot *p; - for(auto i=knotPool.listSlots(); i.next(p);) { - auto p0 = p->tform->t; - auto u = 0.3333 * p->tform->transformVector(p->attitude); - // plot a little square - lines.plot(p0+vec(-4,-4), p0+vec(4,-4), c); - lines.plot(p0+vec(4,-4), p0+vec(4,4), c); - lines.plot(p0+vec(4,4), p0+vec(-4,4), c); - lines.plot(p0+vec(-4,4), p0+vec(-4,-4), c); - - // plot tangent - lines.plot(p0, p0+u, c); - - // plot a little arrow - lines.plot(p0+u, p0 + u + 8*(u.clockwise()-u).normalized(), c); - lines.plot(p0+u, p0 + u + 8*(u.anticlockwise()-u).normalized(), c); - } -} \ No newline at end of file diff --git a/squids/src/SplineTree.h b/squids/src/SplineTree.h deleted file mode 100644 index 0b009b2..0000000 --- a/squids/src/SplineTree.h +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include - -struct Knot { - const AffineMatrix *tform; - vec2 attitude; -}; - -class SplineTree { -public: - SplineTree(); - - Knot* addKnot(const AffineMatrix *tform, vec2 attitude); - void removeKnot(Knot *knot); - - void addSegment(const Knot *k0, const Knot *k1); - void removeSegment(const Knot *k0, const Knot *k1); - void draw(SplinePlotterRef splines, Color c, float strokeScale=1); - void drawKnots(LinePlotterRef lines, Color c); - -private: - struct Segment { - const Knot *k0; - const Knot *k1; - - bool matches(const Knot *a0, const Knot *a1) const { - return (k0 == a0 && k1 == a1) || (k0 == a1 && k1 == a0); - } - }; - - BitsetPool knotPool; - CompactPool segmentPool; -}; - diff --git a/squids/src/squids.cpp b/squids/src/squids.cpp deleted file mode 100644 index ffefe1b..0000000 --- a/squids/src/squids.cpp +++ /dev/null @@ -1,154 +0,0 @@ -#include "SplineTree.h" -#include -#include -#include -#include - -static void handleKeyDown(const SDL_KeyboardEvent& key, bool *outDone) { - switch(key.keysym.sym) { - case SDLK_ESCAPE: - case SDLK_q: - *outDone = 1; - break; - } -} - -static void handleEvents(bool *outDone) { - SDL_Event event; - while(SDL_PollEvent(&event)) { - switch(event.type) { - case SDL_QUIT: - *outDone = 1; - break; - case SDL_KEYDOWN: - if (!event.key.repeat) { - handleKeyDown(event.key, outDone); - } - break; - } - } -} - -int main(int argc, char *argv[]) { - int w=1000, h=700; - auto window = initContext("GameObject Demo", w, h); - AssetRef assets = loadAssets("squids.bin"); - SplinePlotterRef splines = createSplinePlotter(); - SpritePlotterRef sprites = createSpritePlotter(); - LinePlotterRef lines = createLinePlotter(); - CirclePlotterRef circles = createCirclePlotter(); - FkTreeRef nodes = createFkContext(); - auto tree = new SplineTree(); - - FkNodeRef root = nodes.addNode("root"); - FkNodeRef rotor = root.addNode("rotor"); - FkNodeRef rotor2 = root.addNode("rotor2"); - FkNodeRef rotor2a = rotor2.addNode("rotor2a"); - rotor2a.setPosition(80, 0); - - FkNodeRef n0 = rotor.addNode("n0"); - n0.setPosition(300, 0); - n0.setAttitude(0, 1); - - FkNodeRef n1 = rotor.addNode("n1"); - n1.setPosition(-300, 0); - n1.setAttitude(0, 1); - - FkNodeRef n2 = rotor2a.addNode("n2"); - n2.setPosition(0, -200); - n2.setAttitude(-1, 0); - - FkNodeRef n3 = rotor2a.addNode("n3"); - n3.setPosition(0, 200); - n3.setAttitude(-1, 0); - - auto k0 = tree->addKnot(n0.cachedTransform(), vec(500,0)); - auto k1 = tree->addKnot(n1.cachedTransform(), vec(500,0)); - auto k2 = tree->addKnot(n2.cachedTransform(), vec(500,0)); - auto k3 = tree->addKnot(n3.cachedTransform(), vec(500,0)); - - tree->addSegment(k0, k1); - tree->addSegment(k1, k2); - tree->addSegment(k2, k3); - tree->addSegment(k3, k0); - - auto color = rgb(0x4E9689); - float dim = 0.9f; - glClearColor( - dim * color.red(), - dim * color.green(), - dim * color.blue(), - 0.0f - ); - - Timer timer; - timer.reset(); - - bool done = false; - - root.setPosition(0.5f * vec(w,h)); - - while(!done) { - handleEvents(&done); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - SDL_Point p; - SDL_GetMouseState(&p.x, &p.y); - float yAmount = p.y / float(h); - - timer.timeScale = 0.25 * 1.333 * yAmount; - timer.tick(); - - - root.setPosition(easeTowards(root.position(), p, 0.1, 0.001 * timer.deltaTicks)); - rotor.setRotation(M_TAU * timer.seconds); - rotor2.setRotation(-0.2 * M_TAU * timer.seconds); - - n0.apply(affineRotation(0.2 * M_TAU * timer.deltaSeconds)); - n1.apply(affineRotation(0.333 * M_TAU * timer.deltaSeconds)); - n2.apply(affineRotation(-0.1 * M_TAU * timer.deltaSeconds)); - n3.apply(affineRotation(-0.4 * M_TAU * timer.deltaSeconds)); - nodes.cacheWorldTransforms(); - - auto canvasSize = vec(w, h); - auto scrolling = vec(0,0); - - splines.begin(canvasSize, scrolling); - splines.plot( - quadraticBezierMatrix(vec4f(0,0,0,0), vec4f(p.x, p.y, 0, 0), vec4f(canvasSize.x, canvasSize.y, 0, 0)), - eccentricStroke(32, -30, 32), - rgb(0x4E9689) - ); - tree->draw(splines, rgb(0x87D69B), 1.5f); - tree->draw(splines, rgb(0xC3FF68)); - splines.end(); - - lines.begin(canvasSize, scrolling); - tree->drawKnots(lines, rgb(0x222255)); - lines.end(); - - circles.begin(canvasSize, scrolling); - circles.plotFilled(p, 12, rgba(0xF4FCE844)); - circles.plotArc(root.local().t, 24, 28, rgba(0x7ED0D644)); - circles.end(); - - glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - - sprites.begin(canvasSize, scrolling); - sprites.drawImage(assets.image("max"), p); - sprites.drawLabel(assets.font("droid"), vec(4,4), rgba(0xffffff00), "Hello World!"); - sprites.end(); - - glDisable(GL_BLEND); - - SDL_GL_SwapWindow(window); - } - - delete tree; - sprites.destroy(); - splines.destroy(); - circles.destroy(); -} - - diff --git a/toolchain.command b/toolchain.command index 2dad912..42843c0 100755 --- a/toolchain.command +++ b/toolchain.command @@ -1,6 +1,7 @@ #!/bin/bash # Little Polygon Setup Script for Mac OS export LITTLE_POLYGON_DIR="`(cd $(dirname \"$0\"); pwd)`" +export PATH=$PATH:$LITTLE_POLYGON_DIR/tools export PYTHONPATH=$PYTHONPATH:$LITTLE_POLYGON_DIR/tools export PS1="[\[\e[1;32m\]little-polygon\[\e[0m\]] \h:\W \u\$ " export PS2="> "