- 博客(17)
- 资源 (1)
- 收藏
- 关注
原创 C#中Protobuf的使用
using System;using System.IO;namespace CsharpProtobuf{ class Program { static void Main(string[] args) { YjzMessage.Vector2f pos = new YjzMessage.Vector2f(); ...
2018-05-10 16:42:19 977
原创 使用C#task和异步socket实现多线程服务器
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading;using System.Threading.Tasks;using System.Net;using System.Net.Sockets;namespace 并发编程{ class...
2018-03-23 12:02:07 1830
原创 游戏服务器gmID的生成
//平台id + 区服id + 秒级时间戳 + 自增id unsigned long long GetGmID(int platformId = 2, int areaId = 1) { static int index = 0; time_t nowTime = time(NULL); static time_t lastTime = time(NULL); unsigned long long gmid = platform...
2020-10-30 15:35:44 319
原创 C++ 实现string::format
class StreamBuffer{public: template <class ...Args> static std::string Format(Args &&... args) { ss.clear(); ss.str(""); int arr[] = { (printarg(args), 0).....
2018-11-29 11:41:05 4634
原创 把C++的类,方法,成员,枚举转换成对应的字符串
std::string ConversionString;#define XToString(val) getString(#val)string & getString(const char * val) { ConversionString = val; return ConversionString;};
2018-09-07 20:10:38 2552
原创 C++ 改变控制台输出文字的颜色
#include <iostream>#include <windows.h>int main(){ HANDLE hstdin = GetStdHandle(STD_INPUT_HANDLE); HANDLE hstdout = GetStdHandle(STD_OUTPUT_HANDLE); WORD index = 0; C...
2018-09-03 12:11:43 2429
原创 Unity中使用位图字体
/// <summary> /// 创建位图字体 /// </summary> [MenuItem("我的工具/创建位图字体")] static void CreatFont() { BmFont bm_font = GameObject.Find("BMFont").GetComponent<BmFont>(); ...
2018-05-31 15:18:31 1260
原创 自己实现字符串转int
std::string num = "770756"; int Number = 0; int x, y; if (num[0] == '-') { x = 1; y = num.length() - 2; for (; x < num.length(), y >= 0; x++, y--) { int NewNumber = num[x] - 48; Number +...
2018-05-16 18:32:09 231
原创 OpenGL绘制三角形
#include<Windows.h>#include<iostream>#include<fstream>#include <glad/glad.h>#include <GLFW/glfw3.h>#include<string>#pragma comment(lib,"glfw3.lib") //链接金泰哭#pragm
2018-05-16 16:58:18 463
原创 c/c++把float转成固定的四个char
//利用 联合体内存对齐的特点union FloatType { float FloatNum; int IntNum;};unsigned char * FloatToByteArray(float f){ unsigned char * DataBuf = new unsigned char[4]; FloatType Number; Number.FloatNum = f; DataBuf...
2018-04-13 18:48:12 2564
原创 四种排序算法(冒泡,选择,插入,归并)
#include<iostream>#include<time.h>#include<array>#include<list>using namespace std;void Merge(int arr[], int low, int mid, int high);void MergeSort(int arr[], int n);int main(i...
2018-04-13 10:50:14 184
原创 将int或者short转成固定的字节数
#include<iostream>using namespace std;using byte = unsigned char;int main(){ cout << 0xff << endl; int IntNumber = 123456; byte IntData[4] = { 0 }; IntData[0] = (unsigned char)(IntNu...
2018-03-28 10:16:26 254
原创 c++双向链表
#includeusing namespace std;templatestruct Node{T data;Node * p_next;//指向下一个数据Node * p_previous;//指向上一个数据};templateclass MyList{public:MyList();void AddValue(T number);
2018-01-08 17:57:54 151
原创 c++ 手动实现链表
#includeusing namespace std;templatestruct Node{T data;Node * p_next;//指向下一个数据Node * p_previous;//指向上一个数据};templateclass MyList{public:MyList();void AddValue(T number);
2018-01-08 16:42:51 244
原创 c++控制台程序双缓冲解决闪屏
#include#includeusing namespace std;#define MAP_HEGHT 20#define MAP_WIGHT 30void map(int CountX, int CountY);int main(){HANDLE hOutput;COORD coord = { 0, 0 };hOutput = GetStdHand
2017-12-10 11:16:58 4911 2
原创 使用unity动态切割图片 然后重新组合
//把这个脚本挂到画布下面的一个空节点就可以using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.UI;using System;public class ImageCropping : MonoBehaviour { [Ser
2017-11-01 11:15:05 2778 1
原创 使用unity画圆
代码如下: 主要用的就是三角函数using System.Collections;using System.Collections.Generic;using UnityEngine;public class Trigonometric : MonoBehaviour{ private float NowAngle = 0; List Poin
2017-10-28 11:35:36 2507
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人