<commit_before>//
//  GameScene.cpp
//  yamiHikariGame
//
//  Created by slightair on 2013/07/16.
//
//

#include "GameScene.h"
#include "Constants.h"
#include "GameEngine.h"
#include "SimpleAudioEngine.h"

#include "DropItem.h"

#define kDropItemInterval 0.2
#define kEmergedAreaHorizontalMarginRate 0.1
#define kCollisionAreaPadding 8
#define kSEItemGet "SE001.mp3"

CCScene* GameScene::scene()
{
    CCScene *scene = CCScene::create();

    GameScene *layer = GameScene::create();
    scene->addChild(layer);

    return scene;
}

void GameScene::update(float delta)
{
    _monster->followBrave(_brave->getPosition(), delta);

    CCSize braveSize = _brave->getContentSize();
    _braveRect = CCRectMake(_brave->getPosition().x - braveSize.width / 2 + kCollisionAreaPadding,
                            _brave->getPosition().y - braveSize.height / 2 + kCollisionAreaPadding,
                            braveSize.width - kCollisionAreaPadding * 2,
                            braveSize.height - kCollisionAreaPadding * 2);
    collisionCheck();
}

void GameScene::onEnter()
{
    CCLayer::onEnter();

    CCSize windowSize = CCDirector::sharedDirector()->getWinSize();

    _worldNode = CCNode::create();
    _groundNode = Ground::create();
    _itemsNode = CCSpriteBatchNode::create(SpriteSheetImageFileName);
    _scoreBoardNode = ScoreBoard::create();

    _worldNode->addChild(_groundNode);
    _worldNode->addChild(_itemsNode);

    _monster = Monster::createWithSpriteFrameName("monster.png");
    _monster->setPosition(ccp(windowSize.width / 2, windowSize.height - _monster->getContentSize().height));
    _worldNode->addChild(_monster);

    _brave = Brave::createWithSpriteFrameName("brave.png");
    _brave->setPosition(ccp(windowSize.width / 2, windowSize.height - _monster->getContentSize().height * 2 - _brave->getContentSize().height / 2));
    _worldNode->addChild(_brave);

    _darknessNode = Darkness::create(_brave->getPosition());

    this->addChild(_worldNode);
    this->addChild(_darknessNode);
    this->addChild(_scoreBoardNode);

    CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 0, true);
    
    CocosDenshion::SimpleAudioEngine::sharedEngine()->setEffectsVolume(0.15);
    CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect(kSEItemGet);

    this->scheduleUpdate();
}

void GameScene::onEnterTransitionDidFinish()
{
    CCLayer::onEnterTransitionDidFinish();

    _monster->startAnimation();
    _brave->startAnimation();

    this->schedule(schedule_selector(GameScene::dropItem), kDropItemInterval);
}

void GameScene::onExit()
{
    CCDirector::sharedDirector()->getTouchDispatcher()->removeDelegate(this);
    CocosDenshion::SimpleAudioEngine::sharedEngine()->unloadEffect(kSEItemGet);

    CCLayer::onExit();
}

bool GameScene::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
{
    _touchedLocation = pTouch->getLocationInView();

    return true;
}
<commit_msg>replace sound effect volume value to constant macro<commit_after>//
//  GameScene.cpp
//  yamiHikariGame
//
//  Created by slightair on 2013/07/16.
//
//

#include "GameScene.h"
#include "Constants.h"
#include "GameEngine.h"
#include "SimpleAudioEngine.h"

#include "DropItem.h"

#define kDropItemInterval 0.2
#define kEmergedAreaHorizontalMarginRate 0.1
#define kCollisionAreaPadding 8
#define kSEItemGet "SE001.mp3"
#define kSoundEffectVolume 0.15

CCScene* GameScene::scene()
{
    CCScene *scene = CCScene::create();

    GameScene *layer = GameScene::create();
    scene->addChild(layer);

    return scene;
}

void GameScene::update(float delta)
{
    _monster->followBrave(_brave->getPosition(), delta);

    CCSize braveSize = _brave->getContentSize();
    _braveRect = CCRectMake(_brave->getPosition().x - braveSize.width / 2 + kCollisionAreaPadding,
                            _brave->getPosition().y - braveSize.height / 2 + kCollisionAreaPadding,
                            braveSize.width - kCollisionAreaPadding * 2,
                            braveSize.height - kCollisionAreaPadding * 2);
    collisionCheck();
}

void GameScene::onEnter()
{
    CCLayer::onEnter();

    CCSize windowSize = CCDirector::sharedDirector()->getWinSize();

    _worldNode = CCNode::create();
    _groundNode = Ground::create();
    _itemsNode = CCSpriteBatchNode::create(SpriteSheetImageFileName);
    _scoreBoardNode = ScoreBoard::create();

    _worldNode->addChild(_groundNode);
    _worldNode->addChild(_itemsNode);

    _monster = Monster::createWithSpriteFrameName("monster.png");
    _monster->setPosition(ccp(windowSize.width / 2, windowSize.height - _monster->getContentSize().height));
    _worldNode->addChild(_monster);

    _brave = Brave::createWithSpriteFrameName("brave.png");
    _brave->setPosition(ccp(windowSize.width / 2, windowSize.height - _monster->getContentSize().height * 2 - _brave->getContentSize().height / 2));
    _worldNode->addChild(_brave);

    _darknessNode = Darkness::create(_brave->getPosition());

    this->addChild(_worldNode);
    this->addChild(_darknessNode);
    this->addChild(_scoreBoardNode);

    CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 0, true);
    
    CocosDenshion::SimpleAudioEngine::sharedEngine()->setEffectsVolume(kSoundEffectVolume);
    CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect(kSEItemGet);

    this->scheduleUpdate();
}

void GameScene::onEnterTransitionDidFinish()
{
    CCLayer::onEnterTransitionDidFinish();

    _monster->startAnimation();
    _brave->startAnimation();

    this->schedule(schedule_selector(GameScene::dropItem), kDropItemInterval);
}

void GameScene::onExit()
{
    CCDirector::sharedDirector()->getTouchDispatcher()->removeDelegate(this);
    CocosDenshion::SimpleAudioEngine::sharedEngine()->unloadEffect(kSEItemGet);

    CCLayer::onExit();
}

bool GameScene::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
{
    _touchedLocation = pTouch->getLocationInView();

    return true;
}

{'fraction_non_alphanumeric': 0.13675929025778372, 'fraction_numerical': 0.009708737864077669, 'mean_word_length': 4.506912442396313, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 67, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2960978', 'n_tokens_mistral': 1944, 'n_tokens_neox': 1842, 'n_words': 270}