From 05f92e4208c2ba8d98ed5b1773bf3f1ce7942003 Mon Sep 17 00:00:00 2001 From: aismann Date: Wed, 15 Jun 2022 07:02:08 +0200 Subject: [PATCH] SimpleSnake small updates - CodeCleanup - MIT License file - readme update --- .../SimpleSnake/Classes/SimpleSnakeScene.cpp | 28 +++++++------------ examples/SimpleSnake/LICENSE | 21 ++++++++++++++ examples/SimpleSnake/README.md | 17 +++++++++-- 3 files changed, 46 insertions(+), 20 deletions(-) create mode 100644 examples/SimpleSnake/LICENSE diff --git a/examples/SimpleSnake/Classes/SimpleSnakeScene.cpp b/examples/SimpleSnake/Classes/SimpleSnakeScene.cpp index f839f345b5..4a4a7ad835 100644 --- a/examples/SimpleSnake/Classes/SimpleSnakeScene.cpp +++ b/examples/SimpleSnake/Classes/SimpleSnakeScene.cpp @@ -157,20 +157,16 @@ void SimpleSnake::onKeyPressed(EventKeyboard::KeyCode keyCode, Event* event) switch (keyCode) { case cocos2d::EventKeyboard::KeyCode::KEY_LEFT_ARROW: - if (dir != 2) - dir = 1; + if (dir != 2) dir = 1; break; case cocos2d::EventKeyboard::KeyCode::KEY_RIGHT_ARROW: - if (dir != 1) - dir = 2; + if (dir != 1) dir = 2; break; case cocos2d::EventKeyboard::KeyCode::KEY_UP_ARROW: - if (dir != 3) - dir = 0; + if (dir != 3) dir = 0; break; case cocos2d::EventKeyboard::KeyCode::KEY_DOWN_ARROW: - if (dir != 0) - dir = 3; + if (dir != 0) dir = 3; break; default: break; @@ -185,7 +181,7 @@ void SimpleSnake::menuCloseCallback(Ref* sender) void SimpleSnake::update(float delta) { static float runTime = 0; - static bool finish = false; + static bool finish = false; runTime += delta; endLevelTime += delta; @@ -204,23 +200,19 @@ void SimpleSnake::update(float delta) { case 0: s[0].y++; - if (s[0].y >= M) - s[0].y = 0; + if (s[0].y >= M) s[0].y = 0; break; case 1: s[0].x--; - if (s[0].x < 0) - s[0].x = N; + if (s[0].x < 0) s[0].x = N; break; case 2: s[0].x++; - if (s[0].x >= N) - s[0].x = 0; + if (s[0].x >= N) s[0].x = 0; break; case 3: s[0].y--; - if (s[0].y < 0) - s[0].y = M; + if (s[0].y < 0) s[0].y = M; break; default: break; @@ -249,7 +241,7 @@ void SimpleSnake::update(float delta) myScore[num - StartBodies] = endLevelTime; sprintf(buffer, "Level %i Time : %f", num - StartBodies + 1, myScore[num - StartBodies]); myScoreLabel[num - StartBodies]->setString(buffer); - if (num >= (snakeBodies + StartBodies-1)) + if (num >= (snakeBodies + StartBodies - 1)) { myScoreLabel[num - StartBodies]->setString("FINISH"); finish = true; diff --git a/examples/SimpleSnake/LICENSE b/examples/SimpleSnake/LICENSE new file mode 100644 index 0000000000..fc35ef1041 --- /dev/null +++ b/examples/SimpleSnake/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) @aismann; Peter Eismann, Germany; dreifrankensoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/examples/SimpleSnake/README.md b/examples/SimpleSnake/README.md index 58e7245103..139fa19a4e 100644 --- a/examples/SimpleSnake/README.md +++ b/examples/SimpleSnake/README.md @@ -1,7 +1,20 @@ Simple Snake +adxe version of a "Simple Snake" game. + +If you have any questions or want to continue this project feel free to do so. + +Here are some ideas: +- Improve the "score optic" +- Save the "highsore times" +- Use sprites unstead of draw primitives +- Add some effects (sound, exploding stuff, traps, etc) + +- or use it as startup + +Idea from here: +https://www.youtube.com/channel/UCC7qpnId5RIQruKDJOt2exw + MIT License -# adxe Simple Snake Example -Easy adxe version of a "Simple Snake" game \ No newline at end of file