Skip to content

Commit

Permalink
add a grid system
Browse files Browse the repository at this point in the history
  • Loading branch information
nakasyou committed Dec 26, 2022
1 parent 295e6e9 commit 58357e4
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 39 deletions.
87 changes: 55 additions & 32 deletions dist/kagura.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/kagura.min.js

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions src/api/grid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(function(){
function Grid(n,w,h){
this.n=n;
this.w=w;
this.h=h;
this.vw=w/(2*n);
this.vh=h/(2*n);
this.xy=function(x,y){
return {
x:(this.vw*x)+this.w/2,
y:(this.vh*y)+this.h/2
};
};
this.x=function(x){return (this.vw*x)+this.w/2};
this.y=function(y){return (this.vh*y)+this.h/2};

this.c={
x:w/2,y:h/2
};
}
return Grid;
})();
6 changes: 3 additions & 3 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ const kagura=function(){
shape:{
isNewTest:"",
},
Group:{{!obj/group.js!}}

},
Boxer:{{!api/boxer.js!}},
FullScreen:{{!api/fullscreen.js!}},
pixi:PIXI,
};
kagura.exitFullscreen=Document.exitFullscreen;

kagura.Grid={{!api/grid.js!}}
kagura.browser={{!browsercheck.js!}}(window.navigator.userAgent)

kagura.obj.Object={{!obj/object.js!}}

kagura.obj.Text={{!obj/text.js!}}

kagura.obj.Group={{!obj/group.js!}}
kagura.obj.shape.GraphicsProto={{!obj/shape/graphicsproto.js!}};
kagura.obj.shape.GraphicsFill={{!obj/shape/graphicsfill.js!}};
kagura.obj.shape.Circle={{!obj/shape/circle.js!}}
Expand Down
8 changes: 5 additions & 3 deletions src/kaguraapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ class{
scaleToWindow(this.app.view);
});
}

this.view=this.app.view;
this.grid=new kagura.Grid(32,this.view.width,this.view.height);
this.keyboard=new kagura.Keyboard(document);
this.touchs=new kagura.Touches(this.view);

if(options.autoFpsControl)this.fpsHistory=[];
this.backgroundColor=options.backgroundColor;
this.view=this.app.view;

this.backFlameTime=new Date();


Expand All @@ -61,7 +62,7 @@ class{
deltaFlame:deltaTime/(1000/this.options.fps),

keyboard:this.keyboard,
pointers:this.touchs.get
pointers:this.touchs.get,
});

// Chenge Scene
Expand Down Expand Up @@ -98,6 +99,7 @@ class{
Class.prototype.width=this.app.renderer.width;
Class.prototype.height=this.app.renderer.height;
Class.prototype.backgroundColor=this.options.backgroundColor;
Class.prototype.grid=this.grid;
return new Class();
}
mainroop(){
Expand Down

0 comments on commit 58357e4

Please sign in to comment.