-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathold.ts
156 lines (124 loc) · 5.03 KB
/
old.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
// import {raylib_enums} from "./raylib_enums";
import {Exporter} from "./Exporter";
import {ArgumentIdentifier, BoolType, FloatType, OptionalArg, ParmType, PointerType, StringType} from "./c_types";
import {ExportC} from "./Exporters/CExporter";
let e = new Exporter();
let Rectangle = e.DefStruct("Rectangle")
.Int("x")
.Int("y")
.Int("width")
.Int("height");
let Color = e.DefStruct("Color")
.Int("r")
.Int("g")
.Int("b")
.Int("a");
/*
typedef struct Camera2D {
Vector2 offset; // Camera offset (displacement from target)
Vector2 target; // Camera target (rotation and zoom origin)
float rotation; // Camera rotation in degrees
float zoom; // Camera zoom (scaling), should be 1.0f by default
} Camera2D;
*/
let Vector2 = e.DefStruct("Vector2")
.Float("x")
.Float("y");
let Camera2D = e.DefStruct("Camera2D")
.AddMember(new ParmType("offset", Vector2))
.AddMember(new ParmType("target", Vector2))
.Float("rotation")
.Float("zoom")
/*
// What if we didn't want to allocate data for stuff that's already in the header?
// Allocate Color table, set light userdata to &RAYWHITE
*/
e.DefStructConst("LIGHTGRAY", Color, { r:200, g:200, b:200, a:255 } )
e.DefStructConst("BLUE", Color,{r : 0, g : 0, b : 245, a : 255})
e.DefStructConst("RAYWHITE", Color,{r : 245, g : 245, b : 245, a : 255})
e.DefGlobalFunction("BeginMode2D").Parm(Camera2D, "camera");
e.DefGlobalFunction("EndMode2D")
e.DefGlobalFunction("GetScreenToWorld2D").Parm(Vector2, "position").Parm(Camera2D, "camera").Return(Vector2);
e.DefGlobalFunction("IsKeyPressed").IntParm("key").Return(new BoolType())
e.DefGlobalFunction("IsKeyDown").IntParm("key").Return(new BoolType())
e.DefGlobalFunction("IsKeyReleased").IntParm("key").Return(new BoolType())
e.DefGlobalFunction("IsKeyUp").IntParm("key").Return(new BoolType())
e.DefGlobalFunction("IsMouseButtonDown").IntParm("button").Return(new BoolType())
e.DefGlobalFunction("GetMousePosition").Return(Vector2)
e.DefGlobalFunction("GetMouseDelta").Return(Vector2)
// let VectorContainer = e.DefStruct("VectorContainer")
// .AddMember(new ParmType("vec", Vector2))
//
// // DrawRectangleV(Vector2 position, Vector2 size, Color color);
// e.DefGlobalFunction("DrawRectangleV")
// .Parm(Vector2, "position")
// .Parm(Vector2, "size")
// .Parm(Color, "color");
//
// DefGlobalFunction("DrawRectangleV")
// .Parm(Vector2, "position")
// .Parm(Vector2, "size")
// .Parm(Color, "color")
// .IntParm("foo");
// RLAPI int GetRandomValue(int min, int max);
// e.DefGlobalFunction("GetRandomValue")
// .IntParm("min")
// .IntParm("max")
// .Return(new IntType());
// e.DefGlobalFunction("MakeAVector")
// .IntParm("foo")
// .Return(Vector2);
// // char *LoadFileText(const char *fileName);
// e.DefGlobalFunction("LoadFileText")
// .Parm(new StringType(), "fileName")
// .Return(new StringType())
//
// // void DrawText(const char *text, int posX, int posY, int fontSize, Color color);
e.DefGlobalFunction("DrawText")
.Parm(new StringType().Const(), "text")
.IntParm("posX")
.IntParm("posY")
.IntParm("fontSize")
.Parm(Color, "color")
// raylib_enums(e);
// rshapes
// DrawPixel, DrawPixelV
e.DefGlobalFunction("DrawLine")
.FloatParm("startPosX")
.FloatParm("startPosY")
.FloatParm("endPosX")
.FloatParm("endPosY")
.Parm(Color, "color")
e.DefGlobalFunction("DrawCircle").FloatParm("centerX").FloatParm("centerY").FloatParm("radius").Parm(Color, "color")
e.DefGlobalFunction("DrawRectangle")
.IntParm("posX")
.IntParm("posY")
.IntParm("width")
.IntParm("height")
.Parm(Color, "color")
e.DefGlobalFunction("DrawRectangleLinesEx").Parm(Rectangle, "rec").FloatParm("lineThick").Parm(Color, "color")
e.DefGlobalFunction("CheckCollisionLines")
.Parm(Vector2, "startPos1")
.Parm(Vector2, "endPos1")
.Parm(Vector2, "startPos2")
.Parm(Vector2, "endPos2")
.Arg(OptionalArg(new ArgumentIdentifier("collisionPoint", new PointerType(Vector2))))
.Return(new BoolType())
// rtextures
e.DefGlobalFunction("ColorAlpha").Parm(Color, "color").FloatParm("alpha").Return(Color)
// e.DefGlobalFunction("rlRotatef")
// .FloatParm("angle")
// .FloatParm("x")
// .FloatParm("y")
// .FloatParm("z")
// raymath
e.DefGlobalFunction("Vector2Scale").Parm(Vector2, "v").FloatParm("scale").Return(Vector2)
e.DefGlobalFunction("Vector2Add").Parm(Vector2, "v1").Parm(Vector2, "v2").Return(Vector2)
e.DefGlobalFunction("Vector2Distance").Parm(Vector2, "v1").Parm(Vector2, "v2").Return(new FloatType())
e.DefGlobalFunction("Vector2DistanceSqr").Parm(Vector2, "v1").Parm(Vector2, "v2").Return(new FloatType())
// ExportC(e, "/Users/mattj/projects/luatest/luatest/src/raylib_bindings1.cpp", true);
// let luaExporter = new LuaExporter("/Users/mattj/projects/luatest/luatest/resources/raylib_bindings.lua", e);
// luaExporter.Run();
//
// let typescriptDefsExporter = new TypescriptDefsExporter("/Users/mattj/projects/luatest/luatest/ts/rl.d.ts", e);
// typescriptDefsExporter.Run();