PageSourceSearch

https://davidyao.me/projects/envymygun/js/client/client-events.js

js davidyao.me collected 2026-10-04 00:20:47 UTC 2,654 bytes, 103 lines download raw bytes

1// Global NVMC Client: Events Handlers
2
3var NVMCClient = NVMCClient || {};
4
5NVMCClient.onInitialize = function() {
6  var gl = this.ui.gl;
7  NVMC.log("SpiderGL Version : " + SGL_VERSION_STRING + "\n");
8  this.game.player.color = [1.0, 0.0, 0.0, 1.0];
9  this.initMotionKeyHandlers();
10  this.stack = new SglMatrixStack();
11  this.initializeObjects(gl);
12  this.initializeCameras();
13  this.uniformShader = new uniformShader(gl);
14  this.lambertianShader = new lambertianSingleColorShader(gl);
15};
16
17NVMCClient.onTerminate = function() {};
18
19NVMCClient.onConnectionOpen = function() {
20  NVMC.log("[Connection Open]");
21};
22
23NVMCClient.onConnectionError = function(err) {
24  NVMC.log("[Connection Error] : " + err);
25};
26
27NVMCClient.onLogIn = function() {
28  NVMC.log("[Logged In]");
29};
30
31NVMCClient.onLogOut = function() {
32  NVMC.log("[Logged Out]");
33};
34
35NVMCClient.onNewRace = function(race) {
36  NVMC.log("[New Race]");
37};
38
39NVMCClient.onPlayerJoin = function(id) {
40  NVMC.log("[Player Join] : " + id);
41  this.game.opponents[id].color = [0.0, 1.0, 0.0, 1.0];
42};
43
44NVMCClient.onPlayerLeave = function(id) {
45  NVMC.log("[Player Leave] : " + id);
46};
47
48NVMCClient.onKeyDown = function(keyCode, event) {
49  var carMotion = this.carMotionKey[keyCode];
50  if (carMotion)
51    carMotion(true);
52
53  this.character.keyDown(keyCode);
54
55  this.cameras[this.currentCamera].keyDown(keyCode);
56};
57
58NVMCClient.onKeyUp = function(keyCode, event) {
59  var cameraSwitch = this.cameraSwitchKey[keyCode];
60  if (cameraSwitch) {
61    cameraSwitch();
62    return;
63  }
64
65  var carMotion = this.carMotionKey[keyCode];
66  if (carMotion)
67    carMotion(false);
68
69  this.character.keyUp(keyCode);
70  this.bullet.keyUp(keyCode);
71  this.cameras[this.currentCamera].keyUp(keyCode);
72};
73
74NVMCClient.onKeyPress = function(keyCode, event) {};
75
76NVMCClient.onMouseButtonDown = function(button, x, y, event) {
77  this.cameras[this.currentCamera].mouseButtonDown(x,y);
78};
79
80NVMCClient.onMouseButtonUp = function(button, x, y, event) {
81  this.cameras[this.currentCamera].mouseButtonUp(x,y);
82};
83
84NVMCClient.onMouseMove = function(x, y, event) {
85  this.cameras[this.currentCamera].mouseMove(x,y);
86};
87
88NVMCClient.onMouseWheel = function(delta, x, y, event) {};
89NVMCClient.onClick = function(button, x, y, event) {};
90NVMCClient.onDoubleClick = function(button, x, y, event) {};
91NVMCClient.onDragStart = function(button, x, y) {};
92NVMCClient.onDragEnd = function(button, x, y) {};
93NVMCClient.onDrag = function(button, x, y) {};
94NVMCClient.onResize = function(width, height, event) {};
95
96NVMCClient.onAnimate = function(dt) {
97  this.ui.postDrawEvent();
98};
99
100NVMCClient.onDraw = function() {
101  var gl = this.ui.gl;
102  this.drawScene(gl);
103};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.