malc-game-engine 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/malc.js +101 -113
- package/malc.min.js +7 -10
- package/package.json +1 -1
package/malc.js
CHANGED
|
@@ -40,7 +40,39 @@ function generateId(prefix) {
|
|
|
40
40
|
return `${prefix}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
// ========== COLORED TEXT
|
|
43
|
+
// ========== COLORED TEXT FUNCTION (STANDALONE) ==========
|
|
44
|
+
function coloredText(str, x, y, horizontal, vertical, maxWidth) {
|
|
45
|
+
const p = _p5.prototype; // Use the current p5 instance
|
|
46
|
+
const parts = parseColoredText(str);
|
|
47
|
+
let currentX = x;
|
|
48
|
+
let currentY = y;
|
|
49
|
+
|
|
50
|
+
p.push();
|
|
51
|
+
p.textAlign(horizontal || LEFT, vertical || BASELINE);
|
|
52
|
+
|
|
53
|
+
for (const part of parts) {
|
|
54
|
+
if (part.isNewline) {
|
|
55
|
+
currentX = x;
|
|
56
|
+
currentY += p.textLeading() || p.textSize() * 1.2;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (part.color) {
|
|
61
|
+
try {
|
|
62
|
+
p.fill(part.color);
|
|
63
|
+
} catch (e) {
|
|
64
|
+
p.fill(255);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
p.text(part.text, currentX, currentY, maxWidth);
|
|
69
|
+
currentX += p.textWidth(part.text);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
p.pop();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Keep these helper functions (they don't need to change)
|
|
44
76
|
function parseColoredLine(str) {
|
|
45
77
|
const regex = /\\([^|\\\n]+)\|([^|]+)\|/g;
|
|
46
78
|
const parts = [];
|
|
@@ -95,36 +127,6 @@ function parseColoredText(str) {
|
|
|
95
127
|
return result;
|
|
96
128
|
}
|
|
97
129
|
|
|
98
|
-
function renderColoredText(p, str, x, y, horizontal, vertical, maxWidth) {
|
|
99
|
-
const parts = parseColoredText(str);
|
|
100
|
-
let currentX = x;
|
|
101
|
-
let currentY = y;
|
|
102
|
-
|
|
103
|
-
p.push();
|
|
104
|
-
p.textAlign(horizontal, vertical);
|
|
105
|
-
|
|
106
|
-
for (const part of parts) {
|
|
107
|
-
if (part.isNewline) {
|
|
108
|
-
currentX = x;
|
|
109
|
-
currentY += p.textLeading() || p.textSize() * 1.2;
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
if (part.color) {
|
|
114
|
-
try {
|
|
115
|
-
p.fill(part.color);
|
|
116
|
-
} catch (e) {
|
|
117
|
-
p.fill(255);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
p.text(part.text, currentX, currentY, maxWidth);
|
|
122
|
-
currentX += p.textWidth(part.text);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
p.pop();
|
|
126
|
-
}
|
|
127
|
-
|
|
128
130
|
// ========== SCENE CLASS (DEFINED FIRST) ==========
|
|
129
131
|
class Scene {
|
|
130
132
|
static scenes = [];
|
|
@@ -1132,49 +1134,45 @@ class Button extends gameObject {
|
|
|
1132
1134
|
}
|
|
1133
1135
|
|
|
1134
1136
|
render() {
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
|
-
let originalColor = this.formatting.color;
|
|
1151
|
-
this.formatting.color = buttonColor;
|
|
1152
|
-
|
|
1153
|
-
super.render();
|
|
1154
|
-
|
|
1155
|
-
if(!this.visible) return;
|
|
1156
|
-
|
|
1157
|
-
_p5.prototype.push();
|
|
1158
|
-
_p5.prototype.translate(this.x, this.y);
|
|
1159
|
-
if (this.rotationMode == "degrees") _p5.prototype.angleMode(_p5.prototype.DEGREES);
|
|
1160
|
-
_p5.prototype.rotate(this.rotation);
|
|
1161
|
-
|
|
1162
|
-
_p5.prototype.textStyle(btnFormat.text.style);
|
|
1163
|
-
_p5.prototype.textSize(btnFormat.text.size);
|
|
1164
|
-
_p5.prototype.fill(btnFormat.text.color);
|
|
1165
|
-
|
|
1166
|
-
// Use colored text if available, otherwise use normal text
|
|
1167
|
-
if (_p5.prototype.coloredText) {
|
|
1168
|
-
_p5.prototype.coloredText(btnFormat.text.display, 0, 0, _p5.prototype.CENTER, _p5.prototype.CENTER);
|
|
1169
|
-
} else {
|
|
1170
|
-
_p5.prototype.text(btnFormat.text.display, 0, 0);
|
|
1171
|
-
}
|
|
1172
|
-
|
|
1173
|
-
_p5.prototype.pop();
|
|
1174
|
-
|
|
1175
|
-
this.formatting.color = originalColor;
|
|
1137
|
+
if (!this.active) return;
|
|
1138
|
+
|
|
1139
|
+
let btnFormat = this.formatting.button;
|
|
1140
|
+
let buttonColor;
|
|
1141
|
+
|
|
1142
|
+
if (this.isDisabled) {
|
|
1143
|
+
buttonColor = btnFormat.colors.disabled;
|
|
1144
|
+
} else if (this.isPressed) {
|
|
1145
|
+
buttonColor = btnFormat.colors.pressed;
|
|
1146
|
+
} else if (this.isHovered) {
|
|
1147
|
+
buttonColor = btnFormat.colors.hover;
|
|
1148
|
+
} else {
|
|
1149
|
+
buttonColor = btnFormat.colors.normal;
|
|
1176
1150
|
}
|
|
1177
1151
|
|
|
1152
|
+
let originalColor = this.formatting.color;
|
|
1153
|
+
this.formatting.color = buttonColor;
|
|
1154
|
+
|
|
1155
|
+
super.render();
|
|
1156
|
+
|
|
1157
|
+
if(!this.visible) return;
|
|
1158
|
+
|
|
1159
|
+
_p5.prototype.push();
|
|
1160
|
+
_p5.prototype.translate(this.x, this.y);
|
|
1161
|
+
if (this.rotationMode == "degrees") _p5.prototype.angleMode(_p5.prototype.DEGREES);
|
|
1162
|
+
_p5.prototype.rotate(this.rotation);
|
|
1163
|
+
|
|
1164
|
+
_p5.prototype.textStyle(btnFormat.text.style);
|
|
1165
|
+
_p5.prototype.textSize(btnFormat.text.size);
|
|
1166
|
+
_p5.prototype.fill(btnFormat.text.color);
|
|
1167
|
+
|
|
1168
|
+
// Use the standalone coloredText function
|
|
1169
|
+
coloredText(btnFormat.text.display, 0, 0, _p5.prototype.CENTER, _p5.prototype.CENTER);
|
|
1170
|
+
|
|
1171
|
+
_p5.prototype.pop();
|
|
1172
|
+
|
|
1173
|
+
this.formatting.color = originalColor;
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1178
1176
|
// ========== BUTTON-SPECIFIC HELPER METHODS ==========
|
|
1179
1177
|
|
|
1180
1178
|
setText(text) {
|
|
@@ -2559,7 +2557,7 @@ const helpDocs = {
|
|
|
2559
2557
|
|
|
2560
2558
|
// ========== MALC MAIN OBJECT ==========
|
|
2561
2559
|
const MALC = {
|
|
2562
|
-
version: "1.0.
|
|
2560
|
+
version: "1.0.4", // Increment version
|
|
2563
2561
|
|
|
2564
2562
|
// Core classes
|
|
2565
2563
|
gameObject: gameObject,
|
|
@@ -2585,6 +2583,7 @@ const MALC = {
|
|
|
2585
2583
|
// Utility functions
|
|
2586
2584
|
generateId: generateId,
|
|
2587
2585
|
getTimestamp: getTimestamp,
|
|
2586
|
+
coloredText: coloredText, // Add this line
|
|
2588
2587
|
|
|
2589
2588
|
// Gravity constants
|
|
2590
2589
|
GRAVITY: GRAVITY,
|
|
@@ -2688,50 +2687,39 @@ const MALC = {
|
|
|
2688
2687
|
this.mouse = new MouseHandler();
|
|
2689
2688
|
window.mouse = this.mouse;
|
|
2690
2689
|
|
|
2691
|
-
|
|
2692
|
-
if (!_p5.prototype.coloredText) {
|
|
2693
|
-
_p5.prototype.coloredText = function(str, x, y, horizontal, vertical, maxWidth) {
|
|
2694
|
-
renderColoredText(this, str, x, y, horizontal || LEFT, vertical || BASELINE, maxWidth);
|
|
2695
|
-
return this;
|
|
2696
|
-
};
|
|
2697
|
-
}
|
|
2690
|
+
|
|
2698
2691
|
|
|
2699
2692
|
// Start FPS tracking
|
|
2700
2693
|
refreshLoop();
|
|
2701
2694
|
|
|
2702
2695
|
// Create default scenes
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
} catch (e) {
|
|
2731
|
-
// Fallback if coloredText fails
|
|
2732
|
-
_p5.prototype.text(`Loading Game...`, 120, 200);
|
|
2733
|
-
}
|
|
2734
|
-
});
|
|
2696
|
+
// Create default scenes
|
|
2697
|
+
new Scene("blank", 70);
|
|
2698
|
+
new Scene("loading", 50, function(self) {
|
|
2699
|
+
try {
|
|
2700
|
+
_p5.prototype.textSize(24);
|
|
2701
|
+
let timed = (self.timeActive / 250 % 4);
|
|
2702
|
+
let dots = "";
|
|
2703
|
+
|
|
2704
|
+
if (timed < 1) dots = ".";
|
|
2705
|
+
else if (timed < 2) dots = "..";
|
|
2706
|
+
else if (timed < 3) dots = "...";
|
|
2707
|
+
|
|
2708
|
+
// Use standalone coloredText function
|
|
2709
|
+
coloredText(`\\lime|Loading Game${dots}| `, 120, 200, _p5.prototype.LEFT, _p5.prototype.CENTER);
|
|
2710
|
+
|
|
2711
|
+
_p5.prototype.textSize(16);
|
|
2712
|
+
|
|
2713
|
+
let num = (Math.floor(self.timeActive / 100) / 10);
|
|
2714
|
+
let percentText = `${ Math.round((10 - num) * 10) / 10 + ((num + "").length < 2 ? ".0" : "")}`;
|
|
2715
|
+
|
|
2716
|
+
// Use standalone coloredText function
|
|
2717
|
+
coloredText(`\\red|${percentText}|`, 200, 225, _p5.prototype.CENTER, _p5.prototype.CENTER);
|
|
2718
|
+
} catch (e) {
|
|
2719
|
+
// Fallback if coloredText fails
|
|
2720
|
+
_p5.prototype.text(`Loading Game...`, 120, 200);
|
|
2721
|
+
}
|
|
2722
|
+
});
|
|
2735
2723
|
|
|
2736
2724
|
Scene.activeScene = "loading";
|
|
2737
2725
|
|
|
@@ -2771,4 +2759,4 @@ MALC.mouse = new MouseHandler();
|
|
|
2771
2759
|
|
|
2772
2760
|
return MALC;
|
|
2773
2761
|
|
|
2774
|
-
}));
|
|
2762
|
+
}));
|
package/malc.min.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
(function(root,factory){if(typeof define==='function'&&define.amd){define(['p5'],factory)}else if(typeof module==='object'&&module.exports){module.exports=factory(require('p5'))}else{root.MALC=factory(root.p5)}}(typeof self!=='undefined'?self:this,function(p5){const _p5=p5;const MALCgameObjects=[];const MALCbuttons=[];const MALCScene=[];var UIPlanes=[];var buttonsToggled=!0;const GRAVITY=0.5;const TERMINAL_VELOCITY=20;function getTimestamp(){return new Date().getTime()}
|
|
2
2
|
function generateId(prefix){return `${prefix}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`}
|
|
3
|
+
function coloredText(str,x,y,horizontal,vertical,maxWidth){const p=_p5.prototype;const parts=parseColoredText(str);let currentX=x;let currentY=y;p.push();p.textAlign(horizontal||LEFT,vertical||BASELINE);for(const part of parts){if(part.isNewline){currentX=x;currentY+=p.textLeading()||p.textSize()*1.2;continue}
|
|
4
|
+
if(part.color){try{p.fill(part.color)}catch(e){p.fill(255)}}
|
|
5
|
+
p.text(part.text,currentX,currentY,maxWidth);currentX+=p.textWidth(part.text)}
|
|
6
|
+
p.pop()}
|
|
3
7
|
function parseColoredLine(str){const regex=/\\([^|\\\n]+)\|([^|]+)\|/g;const parts=[];let lastIndex=0;let match;while((match=regex.exec(str))!==null){if(match.index>lastIndex){parts.push({text:str.substring(lastIndex,match.index),color:null})}
|
|
4
8
|
parts.push({text:match[2],color:match[1]});lastIndex=match.index+match[0].length}
|
|
5
9
|
if(lastIndex<str.length){parts.push({text:str.substring(lastIndex),color:null})}
|
|
6
10
|
return parts.length?parts:[{text:str,color:null}]}
|
|
7
11
|
function parseColoredText(str){const lines=str.split('\n');const result=[];for(let i=0;i<lines.length;i++){const line=lines[i];const parts=parseColoredLine(line);result.push(...parts);if(i<lines.length-1){result.push({text:'\n',color:null,isNewline:!0})}}
|
|
8
12
|
return result}
|
|
9
|
-
function renderColoredText(p,str,x,y,horizontal,vertical,maxWidth){const parts=parseColoredText(str);let currentX=x;let currentY=y;p.push();p.textAlign(horizontal,vertical);for(const part of parts){if(part.isNewline){currentX=x;currentY+=p.textLeading()||p.textSize()*1.2;continue}
|
|
10
|
-
if(part.color){try{p.fill(part.color)}catch(e){p.fill(255)}}
|
|
11
|
-
p.text(part.text,currentX,currentY,maxWidth);currentX+=p.textWidth(part.text)}
|
|
12
|
-
p.pop()}
|
|
13
13
|
class Scene{static scenes=[];static activeScene="blank";static started=!1;static sceneHistory=[];static historyLimit=10;static update(){this.started=!0;this.scenes=MALCScene;let activeSceneFound=!1;this.scenes.forEach(S=>{if(S.id==this.activeScene){activeSceneFound=!0;this.scenes.forEach(s=>{if(s!=S){s._active=!1;s.active=!1;s.objects.forEach(o=>{if(o&&typeof o.active!=='undefined')o.active=!1})}});S.active=!0;if(!S._active){S.activated=MALC.time.getTime();if(typeof S.onActivate=='function')S.onActivate();}
|
|
14
14
|
S._active=!0;S.timeActive=MALC.time.getTime()-S.activated;S.objects.forEach(o=>{if(o&&typeof o.active!=='undefined')o.active=!0});_p5.prototype.push();if(window.camera&&typeof window.camera.render=='function'){window.camera.render()}
|
|
15
15
|
S.render();_p5.prototype.pop()}});if(!activeSceneFound&&this.activeScene!="blank"){console.warn(`Scene "${this.activeScene}" not found, switching to blank`);this.activeScene="blank"}}
|
|
@@ -120,8 +120,7 @@ update(boolean){super.update(boolean);if(this.cooldownActive){let currentTime=Da
|
|
|
120
120
|
this.isHovered=this.events.hover();this.isPressed=this.events.pressed();if(this.events.clicked()&&this.onClick&&!this.isDisabled&&!this.cooldownActive){this.onClick(this);this.lastClickTime=Date.now();this.cooldownActive=!0}
|
|
121
121
|
MALCbuttons[this.buttonIndex]=this}
|
|
122
122
|
render(){if(!this.active)return;let btnFormat=this.formatting.button;let buttonColor;if(this.isDisabled){buttonColor=btnFormat.colors.disabled}else if(this.isPressed){buttonColor=btnFormat.colors.pressed}else if(this.isHovered){buttonColor=btnFormat.colors.hover}else{buttonColor=btnFormat.colors.normal}
|
|
123
|
-
let originalColor=this.formatting.color;this.formatting.color=buttonColor;super.render();if(!this.visible)return;_p5.prototype.push();_p5.prototype.translate(this.x,this.y);if(this.rotationMode=="degrees")_p5.prototype.angleMode(_p5.prototype.DEGREES);_p5.prototype.rotate(this.rotation);_p5.prototype.textStyle(btnFormat.text.style);_p5.prototype.textSize(btnFormat.text.size);_p5.prototype.fill(btnFormat.text.color);
|
|
124
|
-
_p5.prototype.pop();this.formatting.color=originalColor}
|
|
123
|
+
let originalColor=this.formatting.color;this.formatting.color=buttonColor;super.render();if(!this.visible)return;_p5.prototype.push();_p5.prototype.translate(this.x,this.y);if(this.rotationMode=="degrees")_p5.prototype.angleMode(_p5.prototype.DEGREES);_p5.prototype.rotate(this.rotation);_p5.prototype.textStyle(btnFormat.text.style);_p5.prototype.textSize(btnFormat.text.size);_p5.prototype.fill(btnFormat.text.color);coloredText(btnFormat.text.display,0,0,_p5.prototype.CENTER,_p5.prototype.CENTER);_p5.prototype.pop();this.formatting.color=originalColor}
|
|
125
124
|
setText(text){this.formatting.button.text.display=text;return this}
|
|
126
125
|
getRGBFromColor(colorInput){let c=_p5.prototype.color(colorInput);return[_p5.prototype.red(c),_p5.prototype.green(c),_p5.prototype.blue(c)]}
|
|
127
126
|
getBrightness(colorInput){let rgb=this.getRGBFromColor(colorInput);return 0.299*rgb[0]+0.587*rgb[1]+0.114*rgb[2]}
|
|
@@ -283,7 +282,7 @@ const helpDocs={overview:`
|
|
|
283
282
|
function draw() {
|
|
284
283
|
MALC.update(); // Updates all MALC systems
|
|
285
284
|
}
|
|
286
|
-
`};const MALC={version:"1.0.
|
|
285
|
+
`};const MALC={version:"1.0.4",gameObject:gameObject,Button:Button,Scene:Scene,UIPlane:UIPlane,Camera:Camera,mouse:null,keyboard:keyboard,controller:controller,fps:fps,getFPS:getFPS,time:new Date(),startTime:new Date().getTime(),timer:0,generateId:generateId,getTimestamp:getTimestamp,coloredText:coloredText,GRAVITY:GRAVITY,TERMINAL_VELOCITY:TERMINAL_VELOCITY,help:function(topic="overview"){if(topic==="overview"){console.log(helpDocs.overview);return helpDocs.overview}
|
|
287
286
|
if(helpDocs.classes[topic]){console.log(`=== ${topic.toUpperCase()} ===`);console.log(helpDocs.classes[topic].description);console.log("\nConstructor:",helpDocs.classes[topic].constructor);if(helpDocs.classes[topic].properties){console.log("\nProperties:");Object.entries(helpDocs.classes[topic].properties).forEach(([prop,desc])=>{console.log(` ${prop}: ${desc}`)})}
|
|
288
287
|
if(helpDocs.classes[topic].methods){console.log("\nMethods:");Object.entries(helpDocs.classes[topic].methods).forEach(([method,desc])=>{console.log(` ${method}: ${desc}`)})}
|
|
289
288
|
if(helpDocs.classes[topic].staticMethods){console.log("\nStatic Methods:");Object.entries(helpDocs.classes[topic].staticMethods).forEach(([method,desc])=>{console.log(` static ${method}: ${desc}`)})}
|
|
@@ -292,8 +291,6 @@ if(helpDocs.input[topic]){console.log(`=== ${topic.toUpperCase()} ===`);console.
|
|
|
292
291
|
return helpDocs.input[topic]}
|
|
293
292
|
if(helpDocs.utilities[topic]){console.log(`=== ${topic.toUpperCase()} ===`);console.log(helpDocs.utilities[topic]);return helpDocs.utilities[topic]}
|
|
294
293
|
if(topic==="quickStart"||topic==="start"){console.log(helpDocs.quickStart);return helpDocs.quickStart}
|
|
295
|
-
console.log(`Help topic "${topic}" not found. Try: overview, classes (gameObject, Button, Scene, UIPlane, Camera), input (mouse, keyboard, controller), utilities (coloredText, getFPS), quickStart`);return null},helpTopics:function(){const topics=["overview","classes: "+Object.keys(helpDocs.classes).join(", "),"input: "+Object.keys(helpDocs.input).join(", "),"utilities: "+Object.keys(helpDocs.utilities).join(", "),"quickStart"];console.log("Available help topics:\n"+topics.join("\n"));return topics},init:function(canvasX,canvasY){_p5.prototype.createCanvas(canvasX,canvasY);this.time=new Date();this.startTime=this.time.getTime();window.camera=new Camera(canvasX,canvasY);this.mouse=new MouseHandler();window.mouse=this.mouse;
|
|
296
|
-
refreshLoop();new Scene("blank",70);new Scene("loading",50,function(self){try{_p5.prototype.textSize(24);let timed=(self.timeActive/250%4);let dots="";if(timed<1)dots=".";else if(timed<2)dots="..";else if(timed<3)dots="...";if(_p5.prototype.coloredText){_p5.prototype.coloredText(`\\lime|Loading Game${dots}| `,120,200,_p5.prototype.LEFT,_p5.prototype.CENTER)}else{_p5.prototype.text(`Loading Game${dots}`,120,200)}
|
|
297
|
-
_p5.prototype.textSize(16);let num=(Math.floor(self.timeActive/100)/10);let percentText=`${ Math.round((10 - num) * 10) / 10 + ((num + "").length < 2 ? ".0" : "")}`;if(_p5.prototype.coloredText){_p5.prototype.coloredText(`\\red|${percentText}|`,200,225,_p5.prototype.CENTER,_p5.prototype.CENTER)}else{_p5.prototype.text(percentText,200,225)}}catch(e){_p5.prototype.text(`Loading Game...`,120,200)}});Scene.activeScene="loading";console.log("MALC Game Engine initialized v"+this.version);console.log("Type MALC.help() for documentation")},update:function(){this.time=new Date();this.timer=this.time-this.startTime;if(this.mouse){this.mouse.rawX=_p5.prototype.mouseX;this.mouse.rawY=_p5.prototype.mouseY;this.mouse.x=this.mouse.rawX+window.camera.getOrientation()[0];this.mouse.y=this.mouse.rawY+window.camera.getOrientation()[1];this.mouse.down=_p5.prototype.mouseIsPressed}
|
|
294
|
+
console.log(`Help topic "${topic}" not found. Try: overview, classes (gameObject, Button, Scene, UIPlane, Camera), input (mouse, keyboard, controller), utilities (coloredText, getFPS), quickStart`);return null},helpTopics:function(){const topics=["overview","classes: "+Object.keys(helpDocs.classes).join(", "),"input: "+Object.keys(helpDocs.input).join(", "),"utilities: "+Object.keys(helpDocs.utilities).join(", "),"quickStart"];console.log("Available help topics:\n"+topics.join("\n"));return topics},init:function(canvasX,canvasY){_p5.prototype.createCanvas(canvasX,canvasY);this.time=new Date();this.startTime=this.time.getTime();window.camera=new Camera(canvasX,canvasY);this.mouse=new MouseHandler();window.mouse=this.mouse;refreshLoop();new Scene("blank",70);new Scene("loading",50,function(self){try{_p5.prototype.textSize(24);let timed=(self.timeActive/250%4);let dots="";if(timed<1)dots=".";else if(timed<2)dots="..";else if(timed<3)dots="...";coloredText(`\\lime|Loading Game${dots}| `,120,200,_p5.prototype.LEFT,_p5.prototype.CENTER);_p5.prototype.textSize(16);let num=(Math.floor(self.timeActive/100)/10);let percentText=`${ Math.round((10 - num) * 10) / 10 + ((num + "").length < 2 ? ".0" : "")}`;coloredText(`\\red|${percentText}|`,200,225,_p5.prototype.CENTER,_p5.prototype.CENTER)}catch(e){_p5.prototype.text(`Loading Game...`,120,200)}});Scene.activeScene="loading";console.log("MALC Game Engine initialized v"+this.version);console.log("Type MALC.help() for documentation")},update:function(){this.time=new Date();this.timer=this.time-this.startTime;if(this.mouse){this.mouse.rawX=_p5.prototype.mouseX;this.mouse.rawY=_p5.prototype.mouseY;this.mouse.x=this.mouse.rawX+window.camera.getOrientation()[0];this.mouse.y=this.mouse.rawY+window.camera.getOrientation()[1];this.mouse.down=_p5.prototype.mouseIsPressed}
|
|
298
295
|
controller.update();gameObject.update();Button.updateButton();this.fps=fps;if(typeof window.camera.render=="function"){window.camera.render()}
|
|
299
296
|
Scene.update()}};MALC.mouse=new MouseHandler();return MALC}))
|