Cocos2d-x Game; Simple snake game that clones Snake Duel, multiplayer enabled
- Multiplayer Snake Game
- Cocos2d js
- DevTool: Cocos Creator v2.0.1
All UI assets are extracted from Facebook Instant Game - Snake Duel
assets/scripts/Snake.js
- Each joint of the body is a class object
- Connect the objects as a linked list to maintain a whole snake
- prev, next
- Save movement path as array of
cc.Vec2
cc.Class({
extends: cc.Component,
properties: {
paths: [],
...
}
...
});
- Update position and angle of each joint in
update(dt)
assets/scripts/Joystick.js
- Listens
cc.Node.EventType.TOUCH_MOVE
event and update direction as normalized vector
assets/scripts/Food.js
Generated in postions received from server
Matchvs Plugin
Implemented game server using Matchvs SDK.
Its source code is here.
- Not added to github
- packages/plugin-matchvs/
Complete and Update features