Skip to content

Instantly share code, notes, and snippets.

View ChristianHohlfeld's full-sized avatar
👋
Hi there!

Chris Field ChristianHohlfeld

👋
Hi there!
View GitHub Profile
//
// TestMessage.hpp
// UDPTEST
//
// Created by Christian Hohlfeld on 16.09.18.
//
#ifndef TestMessage_hpp
#define TestMessage_hpp
//
// Physics.cpp
// UDPTEST
//
// Created by Christian Hohlfeld on 22.09.18.
//
#include "Physics.h"
#include <cocos2d.h>
using namespace cocos2d;
//
// Physics.h
// UDPTEST
//
// Created by Christian Hohlfeld on 22.09.18.
//
#ifndef Physics_h
#define Physics_h
#include "Box2D/Box2D.h"
double cTime = 100.0f;
uint64_t clientId = 0;
const double deltaTime = 0.01f;
void HelloWorld::initClient() {
GameAdapter gameAdapter = GameAdapter(&GetDefaultAllocator());
random_bytes((uint8_t*)&clientId, 8);
log("client id is %.16" PRIx64 "\n", clientId);
yojimbo::Address* clientAddress = new Address(localProperties.GetProperty("CLIENT_IP_ADDRESS").c_str()); //TODO: delete
GameConnectionConfig config;
client = new GameClient(GetDefaultAllocator(), clientAddress, gameAdapter, config, cTime); // TODO: delete
double sTime = 100.0f;
void HelloWorld::initServer() {
GameConnectionConfig config;
yojimbo::Address* serverAddress = new Address(localProperties.GetProperty("SERVER_IP_ADDRESS").c_str(), 4000); //TODO: delete
server = new GameServer(GetDefaultAllocator(), serverAddress, adapter, config, sTime);//TODO: delete
server->Start();
char addressString[256];
server->GetAddress().ToString(addressString, sizeof(addressString));
log("server address is %s\n", addressString);
}
double sTime = 100.0f;
void HelloWorld::initServer() {
GameConnectionConfig config;
yojimbo::Address* serverAddress = new Address(localProperties.GetProperty("SERVER_IP_ADDRESS").c_str(), 4000);
server = new GameServer(GetDefaultAllocator(), serverAddress, adapter, config, sTime);
server->Start();
char addressString[256];
server->GetAddress().ToString(addressString, sizeof(addressString));
log("server address is %s\n", addressString);
}
double cTime = 100.0f;
uint64_t clientId = 0;
const double deltaTime = 0.01f;
void HelloWorld::initClient() {
GameAdapter gameAdapter = GameAdapter(&GetDefaultAllocator());
random_bytes((uint8_t*)&clientId, 8);
log("client id is %.16" PRIx64 "\n", clientId);
yojimbo::Address* clientAddress = new Address(localProperties.GetProperty("CLIENT_IP_ADDRESS").c_str()); //TODO: delete
GameConnectionConfig config;
client = new GameClient(GetDefaultAllocator(), clientAddress, gameAdapter, config, cTime); // TODO: delete
void HelloWorld::update(float dt) {
if (std::stoi(localProperties.GetProperty("IS_GAMESERVER"))) {
UpdateServer(dt);
}
else {
UpdateClient(dt);
}
//update game state
if(serverGameObject != nullptr){
2018-10-04 21:54:57.351610+0200 UDPTEST-desktop[7043:209923] flock failed to lock maps file: errno = 35
2018-10-04 21:54:57.352593+0200 UDPTEST-desktop[7043:209923] flock failed to lock maps file: errno = 35
{
gl.supports_OES_map_buffer: false
gl.supports_vertex_array_object: true
cocos2d.x.version: cocos2d-x-3.17
gl.vendor: Intel Inc.
gl.supports_PVRTC: false
gl.renderer: Intel Iris OpenGL Engine
@ChristianHohlfeld
ChristianHohlfeld / GameAdapter.cpp
Created September 17, 2018 17:29
yojimbo integration with cocos2d-x win32
//
// GameAdapter.cpp
// UDPTEST
//
// Created by Christian Hohlfeld on 16.09.18.
//
#include <stdio.h>
#include "GameAdapter.h"
#include "GameServer.h"