Skip to content

Cocos2d-x game; Simple snake game that clones "Snake Duel", multiplayer enabled

Notifications You must be signed in to change notification settings

highjump0615/SimpleSnake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Snake

Cocos2d-x Game; Simple snake game that clones Snake Duel, multiplayer enabled

Overview

loading main menu main

Main Features

  • Multiplayer Snake Game

Techniques

1. UI Implementation

All UI assets are extracted from Facebook Instant Game - Snake Duel

2. Function Implementation

2.1 Snake body

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)

2.2 Joysticks

assets/scripts/Joystick.js

  • Listens cc.Node.EventType.TOUCH_MOVE event and update direction as normalized vector

2.3 Food

assets/scripts/Food.js
Generated in postions received from server

3. Third-Party Libraries

Matchvs Plugin

Implemented game server using Matchvs SDK.
Its source code is here.

  • Not added to github
    • packages/plugin-matchvs/

Need to Improve

Complete and Update features

About

Cocos2d-x game; Simple snake game that clones "Snake Duel", multiplayer enabled

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published