Muni Rotates Things
This commit is contained in:
parent
b8a03d651c
commit
bc9b273481
@ -51,12 +51,24 @@ function drawSprite(x,y,sprite) {
|
||||
con.drawImage(sprite,x,y);
|
||||
}
|
||||
|
||||
function drawSpriteExt(x,y,sprite,w,h) {
|
||||
con.drawImage(sprite,x,y,w*sprite.width,h*sprite.height);
|
||||
function drawSpriteExt(x,y,sprite,w,h,image_angle) {
|
||||
transformTranslate(x,y);
|
||||
transformRotate(image_angle);
|
||||
//con.globalCompositeOperation = 'multiply';
|
||||
con.drawImage(sprite,-(w*sprite.width)/2,-(h*sprite.height)/2,w*sprite.width,h*sprite.height);
|
||||
/*con.fillStyle = image_blend;
|
||||
con.fillRect(0,0, w*sprite.width, h*sprite.height);
|
||||
con.globalCompositeOperation = 'destination-atop';
|
||||
con.drawImage(sprite,-(w*sprite.width)/2,-(h*sprite.height)/2,w*sprite.width,h*sprite.height);
|
||||
con.globalCompositeOperation = 'normal';*/
|
||||
resetTransform();
|
||||
}
|
||||
|
||||
function drawSpritePart(x,y,sprite,spritex,spritey,spritew,spriteh,w,h) {
|
||||
con.drawImage(sprite,spritex,spritey,spritew,spriteh,x,y,w,h);
|
||||
function drawSpritePart(x,y,sprite,spritex,spritey,spritew,spriteh,w,h,image_angle) {
|
||||
transformTranslate(x,y);
|
||||
transformRotate(image_angle);
|
||||
con.drawImage(sprite,spritex,spritey,spritew,spriteh,-(w*spritew)/2,-(h*spriteh)/2,spritew*w,spriteh*h);
|
||||
resetTransform();
|
||||
}
|
||||
|
||||
function drawText(x,y,text) {
|
||||
@ -117,3 +129,17 @@ function drawCircle(x,y,r,outline) {
|
||||
con.fill();
|
||||
}
|
||||
}
|
||||
|
||||
function toDataURL(url, callback) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.onload = function() {
|
||||
var reader = new FileReader();
|
||||
reader.onloadend = function() {
|
||||
callback(reader.result);
|
||||
}
|
||||
reader.readAsDataURL(xhr.response);
|
||||
};
|
||||
xhr.open('GET', url);
|
||||
xhr.responseType = 'blob';
|
||||
xhr.send();
|
||||
}
|
18
objects.js
18
objects.js
@ -10,23 +10,26 @@ class Object {
|
||||
this.image_angle=0;
|
||||
}
|
||||
stepEvent() {
|
||||
|
||||
this.image_angle+=0.5;
|
||||
}
|
||||
drawEvent() {
|
||||
if (!this.visible) {
|
||||
return;
|
||||
} else {
|
||||
resetTransform();
|
||||
transformRotate(this.image_angle);
|
||||
drawSetColor("white");
|
||||
if (typeof this.sprite!=="undefined" && this.sprite!=null) {
|
||||
drawSpriteExt(this.x,this.y,this.sprite,this.image_xscale,this.image_yscale);
|
||||
drawSpriteExt(this.x,this.y,this.sprite,this.image_xscale,this.image_yscale,this.image_angle);
|
||||
//drawSpritePart(this.x,this.y,this.sprite,3,3,20,20,this.image_xscale,this.image_yscale,this.image_angle)
|
||||
}
|
||||
resetTransform();
|
||||
}
|
||||
}
|
||||
mouseMoveEvent(e) {
|
||||
|
||||
}
|
||||
touchMoveEvent(e) {
|
||||
|
||||
}
|
||||
keyPressEvent(e) {
|
||||
|
||||
@ -116,13 +119,16 @@ class DebugObj extends Object{
|
||||
super.keyReleaseEvent(e);
|
||||
this.lastMessage="Key Release Event: "+e.key+"";
|
||||
}
|
||||
touchMoveEvent(e) {
|
||||
this.eventCount++;
|
||||
super.touchMoveEvent(e);
|
||||
this.lastMessage="Key Release Event: "+e.key+"";
|
||||
}
|
||||
}
|
||||
|
||||
class IronPlate extends Object{
|
||||
constructor(x,y,sprite) {
|
||||
super(sprite,true,x,y);
|
||||
this.image_xscale=0.5;
|
||||
this.image_yscale=0.5;
|
||||
}
|
||||
stepEvent() {
|
||||
super.stepEvent();
|
||||
@ -131,4 +137,4 @@ class IronPlate extends Object{
|
||||
drawEvent() {
|
||||
super.drawEvent();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user