mirror of https://github.com/axmolengine/axmol.git
SimpleSnake small updates
- CodeCleanup - MIT License file - readme update
This commit is contained in:
parent
559bb6881e
commit
05f92e4208
|
@ -157,20 +157,16 @@ void SimpleSnake::onKeyPressed(EventKeyboard::KeyCode keyCode, Event* event)
|
||||||
switch (keyCode)
|
switch (keyCode)
|
||||||
{
|
{
|
||||||
case cocos2d::EventKeyboard::KeyCode::KEY_LEFT_ARROW:
|
case cocos2d::EventKeyboard::KeyCode::KEY_LEFT_ARROW:
|
||||||
if (dir != 2)
|
if (dir != 2) dir = 1;
|
||||||
dir = 1;
|
|
||||||
break;
|
break;
|
||||||
case cocos2d::EventKeyboard::KeyCode::KEY_RIGHT_ARROW:
|
case cocos2d::EventKeyboard::KeyCode::KEY_RIGHT_ARROW:
|
||||||
if (dir != 1)
|
if (dir != 1) dir = 2;
|
||||||
dir = 2;
|
|
||||||
break;
|
break;
|
||||||
case cocos2d::EventKeyboard::KeyCode::KEY_UP_ARROW:
|
case cocos2d::EventKeyboard::KeyCode::KEY_UP_ARROW:
|
||||||
if (dir != 3)
|
if (dir != 3) dir = 0;
|
||||||
dir = 0;
|
|
||||||
break;
|
break;
|
||||||
case cocos2d::EventKeyboard::KeyCode::KEY_DOWN_ARROW:
|
case cocos2d::EventKeyboard::KeyCode::KEY_DOWN_ARROW:
|
||||||
if (dir != 0)
|
if (dir != 0) dir = 3;
|
||||||
dir = 3;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -204,23 +200,19 @@ void SimpleSnake::update(float delta)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
s[0].y++;
|
s[0].y++;
|
||||||
if (s[0].y >= M)
|
if (s[0].y >= M) s[0].y = 0;
|
||||||
s[0].y = 0;
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
s[0].x--;
|
s[0].x--;
|
||||||
if (s[0].x < 0)
|
if (s[0].x < 0) s[0].x = N;
|
||||||
s[0].x = N;
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
s[0].x++;
|
s[0].x++;
|
||||||
if (s[0].x >= N)
|
if (s[0].x >= N) s[0].x = 0;
|
||||||
s[0].x = 0;
|
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
s[0].y--;
|
s[0].y--;
|
||||||
if (s[0].y < 0)
|
if (s[0].y < 0) s[0].y = M;
|
||||||
s[0].y = M;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -249,7 +241,7 @@ void SimpleSnake::update(float delta)
|
||||||
myScore[num - StartBodies] = endLevelTime;
|
myScore[num - StartBodies] = endLevelTime;
|
||||||
sprintf(buffer, "Level %i Time : %f", num - StartBodies + 1, myScore[num - StartBodies]);
|
sprintf(buffer, "Level %i Time : %f", num - StartBodies + 1, myScore[num - StartBodies]);
|
||||||
myScoreLabel[num - StartBodies]->setString(buffer);
|
myScoreLabel[num - StartBodies]->setString(buffer);
|
||||||
if (num >= (snakeBodies + StartBodies-1))
|
if (num >= (snakeBodies + StartBodies - 1))
|
||||||
{
|
{
|
||||||
myScoreLabel[num - StartBodies]->setString("FINISH");
|
myScoreLabel[num - StartBodies]->setString("FINISH");
|
||||||
finish = true;
|
finish = true;
|
||||||
|
|
|
@ -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.
|
|
@ -1,7 +1,20 @@
|
||||||
Simple Snake
|
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
|
MIT License
|
||||||
|
|
||||||
|
|
||||||
# adxe Simple Snake Example
|
|
||||||
Easy adxe version of a "Simple Snake" game
|
|
Loading…
Reference in New Issue