This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Cannon::Update(float dt) | |
{ | |
if (m_pTarget != nullptr && m_pSprite != nullptr) | |
{ | |
cocos2d::Vec2 thisPosition; | |
thisPosition = m_pSprite->getPosition(); | |
m_TargetPosition = WorldManager::getInstance()->GetCenter(m_pTarget); | |
float angle = atan2(thisPosition.x - m_TargetPosition.x, thisPosition.y - m_TargetPosition.y); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <fstream> | |
#include "external/json/stringbuffer.h" | |
#include "external/json/writer.h" | |
void JsonParser::JsonToFile(rapidjson::Document &jsonObject, std::string &fullpath) { | |
std::ofstream outputFile; | |
outputFile.open(fullpath); | |
if(outputFile.is_open()) { | |
std::string jsonObjectData = JsonToString(jsonObject); | |
outputFile << jsonObjectData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import pi, sin, cos | |
from direct.showbase.ShowBase import ShowBase | |
from direct.task import Task | |
from direct.actor.Actor import Actor | |
from direct.interval.IntervalGlobal import * | |
from panda3d.core import Point3 | |
class MyApp(ShowBase): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2016 David Morton. All rights reserved. | |
// Use of this source code is governed by a license that can be | |
// found in the LICENSE file. | |
#include "gtest/gtest.h" | |
#include "Base/Utils.h" | |
TEST(UtilsTest, to_strCanConvertIntZeroToString) { | |
std::string result = Utils::to_str(0); | |
ASSERT_EQ("0", result); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2016 David Morton. All rights reserved. | |
// Use of this source code is governed by a license that can be | |
// found in the LICENSE file. | |
#ifndef BASE_UTILS_H | |
#define BASE_UTILS_H | |
#include <iostream> | |
class Utils { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <sstream> | |
#include <map> | |
using namespace std; | |
std::map<unsigned int, short> parityCache; | |
short parityOf(unsigned long x){ | |
short result = 0; | |
while(x){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
class B { | |
}; | |
class A : public B { | |
}; | |
template<typename D, typename B> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Command | |
const InsertCommand = (database, id) => { | |
return { | |
execute: () => database.insertRecord(id), | |
undo: () => database.deleteRecord(id) | |
}; | |
}; | |
// Receiver | |
const insertRecord = id => console.log('>>> Database insert', id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Receiver | |
class Entity { | |
String name; | |
public Entity(String name){ | |
this.name = name; | |
} | |
public void jump(){ | |
System.out.println(name + " Jump"); | |
} | |
public void fire(){ |
OlderNewer