Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init Earth Warrior with Intel Common Connectivity Framework SDK #22

Open
wants to merge 22 commits into
base: v3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions samples/EarthWarrior3D-CSDK/.cocos-project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"project_type": "cpp"
}
174 changes: 174 additions & 0 deletions samples/EarthWarrior3D-CSDK/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
cmake_minimum_required(VERSION 2.6)

set(APP_NAME MyGame)
project (${APP_NAME})

include(cocos2d/build/BuildHelpers.CMakeLists.txt)

option(USE_CHIPMUNK "Use chipmunk for physics library" ON)
option(USE_BOX2D "Use box2d for physics library" OFF)
option(DEBUG_MODE "Debug or release?" ON)

if(DEBUG_MODE)
set(CMAKE_BUILD_TYPE DEBUG)
else(DEBUG_MODE)
set(CMAKE_BUILD_TYPE RELEASE)
endif(DEBUG_MODE)

set(CMAKE_C_FLAGS_DEBUG "-g -Wall -DCOCOS2D_DEBUG=1")
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

if(USE_CHIPMUNK)
message("Using chipmunk ...")
add_definitions(-DLINUX -DCC_ENABLE_CHIPMUNK_INTEGRATION=1)
elseif(USE_BOX2D)
message("Using box2d ...")
add_definitions(-DLINUX -DCC_ENABLE_BOX2D_INTEGRATION=1)
else(USE_CHIPMUNK)
message(FATAL_ERROR "Must choose a physics library.")
endif(USE_CHIPMUNK)

# architecture
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set(ARCH_DIR "64-bit")
else()
set(ARCH_DIR "32-bit")
endif()


set(GAME_SRC
proj.linux/main.cpp
Classes/AppDelegate.cpp
Classes/HelloWorldScene.cpp
)

set(COCOS2D_ROOT ${CMAKE_SOURCE_DIR}/cocos2d)

include_directories(
/usr/local/include/GLFW
${COCOS2D_ROOT}
${COCOS2D_ROOT}/cocos
${COCOS2D_ROOT}/cocos/audio/include
${COCOS2D_ROOT}/cocos/2d
${COCOS2D_ROOT}/cocos/2d/renderer
${COCOS2D_ROOT}/cocos/2d/platform
${COCOS2D_ROOT}/cocos/2d/platform/desktop
${COCOS2D_ROOT}/cocos/2d/platform/linux
${COCOS2D_ROOT}/cocos/base
${COCOS2D_ROOT}/cocos/deprecated
${COCOS2D_ROOT}/cocos/physics
${COCOS2D_ROOT}/cocos/editor-support
${COCOS2D_ROOT}/cocos/math/kazmath
${COCOS2D_ROOT}/extensions
${COCOS2D_ROOT}/external
${COCOS2D_ROOT}/external/edtaa3func
${COCOS2D_ROOT}/external/jpeg/include/linux
${COCOS2D_ROOT}/external/tiff/include/linux
${COCOS2D_ROOT}/external/webp/include/linux
${COCOS2D_ROOT}/external/tinyxml2
${COCOS2D_ROOT}/external/unzip
${COCOS2D_ROOT}/external/chipmunk/include/chipmunk
${COCOS2D_ROOT}/external/freetype2/include/linux
${COCOS2D_ROOT}/external/websockets/include/linux
${COCOS2D_ROOT}/external/spidermonkey/include/linux
${COCOS2D_ROOT}/external/linux-specific/fmod/include/${ARCH_DIR}
${COCOS2D_ROOT}/external/xxhash
)

link_directories(
/usr/local/lib
${COCOS2D_ROOT}/external/jpeg/prebuilt/linux/${ARCH_DIR}
${COCOS2D_ROOT}/external/tiff/prebuilt/linux/${ARCH_DIR}
${COCOS2D_ROOT}/external/webp/prebuilt/linux/${ARCH_DIR}
${COCOS2D_ROOT}/external/freetype2/prebuilt/linux/${ARCH_DIR}
${COCOS2D_ROOT}/external/websockets/prebuilt/linux/${ARCH_DIR}
${COCOS2D_ROOT}/external/spidermonkey/prebuilt/linux/${ARCH_DIR}
${COCOS2D_ROOT}/external/linux-specific/fmod/prebuilt/${ARCH_DIR}
)

# kazmath
add_subdirectory(${COCOS2D_ROOT}/cocos/math/kazmath)

# chipmunk library
add_subdirectory(${COCOS2D_ROOT}/external/chipmunk/src)

# box2d library
add_subdirectory(${COCOS2D_ROOT}/external/Box2D)

# unzip library
add_subdirectory(${COCOS2D_ROOT}/external/unzip)

# tinyxml2 library
add_subdirectory(${COCOS2D_ROOT}/external/tinyxml2)

# audio
add_subdirectory(${COCOS2D_ROOT}/cocos/audio)

# xxhash library
add_subdirectory(${COCOS2D_ROOT}/external/xxhash)

# cocos base library
add_subdirectory(${COCOS2D_ROOT}/cocos/base)

# cocos 2d library
add_subdirectory(${COCOS2D_ROOT}/cocos/2d)

# cocos storage
add_subdirectory(${COCOS2D_ROOT}/cocos/storage)

# ui
add_subdirectory(${COCOS2D_ROOT}/cocos/ui)

# network
add_subdirectory(${COCOS2D_ROOT}/cocos/network)

# extensions
add_subdirectory(${COCOS2D_ROOT}/extensions)

## Editor Support

# spine
add_subdirectory(${COCOS2D_ROOT}/cocos/editor-support/spine)

# cocosbuilder
add_subdirectory(${COCOS2D_ROOT}/cocos/editor-support/cocosbuilder)

# cocostudio
add_subdirectory(${COCOS2D_ROOT}/cocos/editor-support/cocostudio)

# add the executable
add_executable(${APP_NAME}
${GAME_SRC}
)

if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set(FMOD_LIB "fmodex64")
else()
set(FMOD_LIB "fmodex")
endif()

target_link_libraries(${APP_NAME}
ui
network
storage
spine
cocostudio
cocosbuilder
extensions
audio
cocos2d
)

set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin")

set_target_properties(${APP_NAME} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}")

pre_build(${APP_NAME}
COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}/Resources
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${APP_BIN_DIR}/Resources
)

74 changes: 74 additions & 0 deletions samples/EarthWarrior3D-CSDK/Classes/AirCraft.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/****************************************************************************
Copyright (c) 2014 Chukong Technologies Inc.

http://github.com/chukong/EarthWarrior3D

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.
****************************************************************************/

#include "AirCraft.h"
#include "SimpleAudioEngine.h"
#include "Effects.h"
#include "HelloWorldScene.h"

bool AirCraft::hurt(float damage)
{
_HP -= damage;
if(_HP <= 0)
{
die();
return true;
}
return false;
}
void AirCraft::die()
{
CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("explodeEffect.mp3");
EffectManager::createBigExplosion(getPosition());
auto helloworld = (HelloWorld*)Director::getInstance()->getRunningScene()->getChildByTag(100);
int score = helloworld->getScore();
helloworld->setScore(score+=_score);
std::stringstream ss;
std::string str;
ss<<score;
ss>>str;
const char *p = str.c_str();
helloworld->getScoreLabel()->setString(p);
_alive = false;
auto scale = ScaleTo::create(0.1, 1.2);
auto scaleBack = ScaleTo::create(0.1, 1);
auto label =helloworld->getScoreLabel();
label->runAction(Sequence::create(scale, scaleBack,NULL));
//removeFromParent();
}

void AirCraft::move(float y, float dt)
{
//setPosition(getPosition().x+getPosition().y+y);
forward(y);
}

void AirCraft::reset()
{
_alive = true;
}
bool AirCraft::alive()
{
return _alive;
}
48 changes: 48 additions & 0 deletions samples/EarthWarrior3D-CSDK/Classes/AirCraft.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/****************************************************************************
Copyright (c) 2014 Chukong Technologies Inc.

http://github.com/chukong/EarthWarrior3D

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.
****************************************************************************/

#ifndef __Moon3d__AirCraft__
#define __Moon3d__AirCraft__

#include "cocos2d.h"
#include "GameEntity.h"
USING_NS_CC;

class AirCraft : public GameEntity
{
public:
virtual bool hurt(float damage);
virtual void die();
void shoot();
//CC_SYNTHESIZE(float, _HP, HP);
bool alive();
virtual void move(float y, float dt);
virtual void reset();
protected:
bool _alive;
float _HP;
int _score;
};

#endif /* defined(__Moon3d__AirCraft__) */
93 changes: 93 additions & 0 deletions samples/EarthWarrior3D-CSDK/Classes/AppDelegate.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/****************************************************************************
Copyright (c) 2014 Chukong Technologies Inc.

http://github.com/chukong/EarthWarrior3D

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.
****************************************************************************/

#include "AppDelegate.h"
#include "MainMenuScene.h"
#include "HelloWorldScene.h"
#include "LoadingScene.h"
#include "SimpleAudioEngine.h"
USING_NS_CC;

AppDelegate::AppDelegate() {

}

AppDelegate::~AppDelegate()
{
}

bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
//glview->setDesignResolutionSize(480,800,ResolutionPolicy::FIXED_HEIGHT);
if(!glview) {
int height, width;
height = 800;
width = height*(640.0/960.0);

glview = GLView::createWithRect("EarthWarrior3D", Rect(0, 0, width, height));

director->setOpenGLView(glview);
}
glview->setDesignResolutionSize(640, 960, ResolutionPolicy::SHOW_ALL);

// turn on display FPS
director->setDisplayStats(false);

// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);

// create a scene. it's an autorelease object
//auto scene = LoadingScene::createScene();
auto scene = MainMenuScene::createScene();
//auto scene = HelloWorld::createScene();
// run
director->runWithScene(scene);
glEnable(GL_CULL_FACE);
return true;
}

// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground() {
SimpleAudioEngine::getInstance()->pauseAllEffects();
SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
Director::getInstance()->stopAnimation();


// if you use SimpleAudioEngine, it must be pause
// SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}

// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground() {
SimpleAudioEngine::getInstance()->resumeAllEffects();
SimpleAudioEngine::getInstance()->resumeBackgroundMusic();

Director::getInstance()->startAnimation();

// if you use SimpleAudioEngine, it must resume here
// SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}

Loading