malc-game-engine 1.0.4 → 1.0.5

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.
Files changed (3) hide show
  1. package/malc.js +35 -38
  2. package/malc.min.js +2 -2
  3. package/package.json +1 -1
package/malc.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * MALC Game Engine Library
3
- * Version: 1.0.3
3
+ * Version: 1.0.5
4
4
  * Description: A comprehensive 2D game engine for p5.js
5
5
  */
6
6
 
@@ -2557,7 +2557,7 @@ const helpDocs = {
2557
2557
 
2558
2558
  // ========== MALC MAIN OBJECT ==========
2559
2559
  const MALC = {
2560
- version: "1.0.4", // Increment version
2560
+ version: "1.0.5", // Increment version
2561
2561
 
2562
2562
  // Core classes
2563
2563
  gameObject: gameObject,
@@ -2674,8 +2674,10 @@ const MALC = {
2674
2674
  },
2675
2675
 
2676
2676
  // Initialize the engine
2677
+
2677
2678
  init: function(canvasX, canvasY) {
2678
- _p5.prototype.createCanvas(canvasX, canvasY);
2679
+ // Use the current p5 instance (this) to create the canvas
2680
+ this.createCanvas(canvasX, canvasY);
2679
2681
 
2680
2682
  this.time = new Date();
2681
2683
  this.startTime = this.time.getTime();
@@ -2687,57 +2689,51 @@ const MALC = {
2687
2689
  this.mouse = new MouseHandler();
2688
2690
  window.mouse = this.mouse;
2689
2691
 
2690
-
2691
-
2692
2692
  // Start FPS tracking
2693
2693
  refreshLoop();
2694
2694
 
2695
2695
  // Create default scenes
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
- });
2696
+ new Scene("blank", 70);
2697
+ new Scene("loading", 50, function(self) {
2698
+ try {
2699
+ this.textSize(24);
2700
+ let timed = (self.timeActive / 250 % 4);
2701
+ let dots = "";
2702
+
2703
+ if (timed < 1) dots = ".";
2704
+ else if (timed < 2) dots = "..";
2705
+ else if (timed < 3) dots = "...";
2706
+
2707
+ coloredText(`\\lime|Loading Game${dots}| `, 120, 200, this.LEFT, this.CENTER);
2708
+
2709
+ this.textSize(16);
2710
+
2711
+ let num = (Math.floor(self.timeActive / 100) / 10);
2712
+ let percentText = `${ Math.round((10 - num) * 10) / 10 + ((num + "").length < 2 ? ".0" : "")}`;
2713
+
2714
+ coloredText(`\\red|${percentText}|`, 200, 225, this.CENTER, this.CENTER);
2715
+ } catch (e) {
2716
+ this.text(`Loading Game...`, 120, 200);
2717
+ }
2718
+ });
2723
2719
 
2724
2720
  Scene.activeScene = "loading";
2725
2721
 
2726
2722
  console.log("MALC Game Engine initialized v" + this.version);
2727
2723
  console.log("Type MALC.help() for documentation");
2728
2724
  },
2729
-
2730
- // Update all systems (call in draw)
2731
- update: function() {
2725
+
2726
+ // Update all systems (call in draw)
2727
+ update: function() {
2732
2728
  this.time = new Date();
2733
2729
  this.timer = this.time - this.startTime;
2734
2730
 
2735
2731
  if (this.mouse) {
2736
- this.mouse.rawX = _p5.prototype.mouseX;
2737
- this.mouse.rawY = _p5.prototype.mouseY;
2732
+ this.mouse.rawX = this.mouseX;
2733
+ this.mouse.rawY = this.mouseY;
2738
2734
  this.mouse.x = this.mouse.rawX + window.camera.getOrientation()[0];
2739
2735
  this.mouse.y = this.mouse.rawY + window.camera.getOrientation()[1];
2740
- this.mouse.down = _p5.prototype.mouseIsPressed;
2736
+ this.mouse.down = this.mouseIsPressed;
2741
2737
  }
2742
2738
 
2743
2739
  controller.update();
@@ -2760,3 +2756,4 @@ MALC.mouse = new MouseHandler();
2760
2756
  return MALC;
2761
2757
 
2762
2758
  }));
2759
+
package/malc.min.js CHANGED
@@ -282,7 +282,7 @@ const helpDocs={overview:`
282
282
  function draw() {
283
283
  MALC.update(); // Updates all MALC systems
284
284
  }
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}
285
+ `};const MALC={version:"1.0.5",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}
286
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}`)})}
287
287
  if(helpDocs.classes[topic].methods){console.log("\nMethods:");Object.entries(helpDocs.classes[topic].methods).forEach(([method,desc])=>{console.log(` ${method}: ${desc}`)})}
288
288
  if(helpDocs.classes[topic].staticMethods){console.log("\nStatic Methods:");Object.entries(helpDocs.classes[topic].staticMethods).forEach(([method,desc])=>{console.log(` static ${method}: ${desc}`)})}
@@ -291,6 +291,6 @@ if(helpDocs.input[topic]){console.log(`=== ${topic.toUpperCase()} ===`);console.
291
291
  return helpDocs.input[topic]}
292
292
  if(helpDocs.utilities[topic]){console.log(`=== ${topic.toUpperCase()} ===`);console.log(helpDocs.utilities[topic]);return helpDocs.utilities[topic]}
293
293
  if(topic==="quickStart"||topic==="start"){console.log(helpDocs.quickStart);return helpDocs.quickStart}
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}
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){this.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{this.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,this.LEFT,this.CENTER);this.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,this.CENTER,this.CENTER)}catch(e){this.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=this.mouseX;this.mouse.rawY=this.mouseY;this.mouse.x=this.mouse.rawX+window.camera.getOrientation()[0];this.mouse.y=this.mouse.rawY+window.camera.getOrientation()[1];this.mouse.down=this.mouseIsPressed}
295
295
  controller.update();gameObject.update();Button.updateButton();this.fps=fps;if(typeof window.camera.render=="function"){window.camera.render()}
296
296
  Scene.update()}};MALC.mouse=new MouseHandler();return MALC}))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "malc-game-engine",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "A comprehensive 2D game engine for p5.js",
5
5
  "main": "malc.js",
6
6
  "unpkg": "malc.min.js",