From ec4cf72e0a98418712f73ab4e1078b5c5d3635ff Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Thu, 27 Feb 2020 16:13:25 +0900 Subject: [PATCH] Create test.js --- test.js | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 test.js diff --git a/test.js b/test.js new file mode 100644 index 0000000..ba62624 --- /dev/null +++ b/test.js @@ -0,0 +1,124 @@ + + +var canvas = document.getElementById("mainScreen"); +var con = canvas.getContext("2d"); + +var ironplate = loadImage("ironplate.png"); + +var keysDown = []; +var mouseDown = []; + +var GAMESPEED = 60; + +canvas.addEventListener("mousemove",mouseMoveEvent); +canvas.addEventListener("mouseup",mouseReleaseEvent); +canvas.addEventListener("mousedown",mousePressEvent); +//window.addEventListener("key",keyEvent); +window.addEventListener("keydown",keyPressEvent); +window.addEventListener("keyup",keyReleaseEvent); + +drawSetFont("16px Tahoma"); +setGameSpeed(GAMESPEED); +setBackgroundColor("black"); +resetTransform(); +/* +drawSetFont("20px Tahoma"); +drawSetHAlign("left"); + +drawSetColor("#FFFFFF"); +drawLine(0,0,50,50); +drawCircle(150,150,30); +drawText(256,64,"Hello World!"); +drawSetColor("yellow"); +drawRectangle(640,480,660,540,false); +*/ + +var frame=0; + +var gameObjs = []; + +instance_create(new DebugObj(0,0,null)); +instance_create(new IronPlate(48,48,ironplate)); + + +function onGameUpdate() { + setBackgroundColor("black"); + gameObjs.forEach(stepEvent); + gameObjs.forEach(drawObject); +} + +function stepEvent(item,index) { + item.stepEvent(); +} + +function drawObject(item,index) { + //drawText(64,32*(index+1),"Draw Object: "+item+" ("+item.visible+") / ("+item.x+","+item.y+")"); + item.drawEvent(); +} + +function mouseMoveEvent(e) { + for (i=0;i=16) {buttonamt-=16;mouseDown.push("MOUSE5");} + if (buttonamt>=8) {buttonamt-=8;mouseDown.push("MOUSE4");} + if (buttonamt>=4) {buttonamt-=4;mouseDown.push("MIDDLE");} + if (buttonamt>=2) {buttonamt-=2;mouseDown.push("RIGHT");} + if (buttonamt>=1) {buttonamt-=1;mouseDown.push("LEFT");} + for (i=0;i=16) {buttonamt-=16;mouseDown.push("MOUSE5");} + if (buttonamt>=8) {buttonamt-=8;mouseDown.push("MOUSE4");} + if (buttonamt>=4) {buttonamt-=4;mouseDown.push("MIDDLE");} + if (buttonamt>=2) {buttonamt-=2;mouseDown.push("RIGHT");} + if (buttonamt>=1) {buttonamt-=1;mouseDown.push("LEFT");} + for (i=0;i