-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Ronan Bastos edited this page Dec 5, 2021
·
11 revisions
Welcome to the Nandraki.js!
[Alfa documentação 1.4.0 ultima versão ante do hard rest do codigo para Beta]
Verficar Version
Nandraki.version();
Criar obj com Class Nandraki
//constructor(id,grav,vel,mas)
//create_obj(id,width,height,top,left,debug)
//create_ui(id,txt,width,height,top,left)
Nandraki.create_obj("text",100,100,50,50,true);
const txt = new Nandraki("text",0,0,0);
Nandraki.create_ui(txt.id," Hello, world!","100px","100px","50px","50px");
Detectar colisão Nandraki.js
Nandraki.create_obj("chao",100,100,50,50,true);
const chao = new Nandraki("text",0,0,0);
Nandraki.create_obj("item",100,100,50,50,true);
const item = new Nandraki("item",0,0,0);
//game.coord(chao.body) = getBoundingClientRect() -> this.body=document.getElementById(this.id);
chaolocal=game.coord(chao.body);
powerlocal=game.coord(item.body);
// check_item_in_chao = true ou false dentro do update
check_item_in_chao = game.colidir(chaolocal, powerlocal);
if(check_item_in_chao == true){
game.print("check true");
}
Start game
Nandraki.create_obj("text",100,100,50,50,true);
const txt = new Nandraki("text",0,0,0);
myjogo = {
start : function(){
Nandraki.create_ui(txt.id," Hello, world!","100px","100px","50px","50px");
},
}
fps=60;
game.update(myjogo.start,fps);
Criar canvas
game.canvas_start(id,width,height);
Canvas Text
game.canvas_text(text,font,cor,x,y);
Canvas Arc
game.canvas_arc(x,y,font,b,p);
Criar barra de life
Nandraki.create_obj("barra1",100,10,100,50,true);
const barra1 = new Nandraki("barra1",0,0,0);
Nandraki.create_obj("barra2",50,10,100,50,true);
const barra2 = new Nandraki("barra2",0,0,0);
barra2.body.style.background = "red";
Game Print
game.print("ola mundo");
force_obj function(id,x,y,rotate)
// rotate true = translate3d("+x+"px,"+y+"px, 0px) rotateY(180deg)
// rotate false = translate3d("+x+"px,"+y+"px, -0px) rotateY(0deg)
game.force_obj(item1.id,0,item1.gravidade,true)
Simples gravidade div dom
const item1 = new Nandraki("div","power1","test",0,5.5,10);
Nandraki.create_obj(item1.id,"30px","50px","50px","150px",true);
const chao = new Nandraki("div","power1","test",0,5.5,10);
Nandraki.create_obj(item1.id,"30px","50px","50px","150px",true);
item1.gravidade+=item1.velocidade;
game.force_obj(item1.id,0,item1.gravidade,false);
pulo=false;
if(item1.up>=450){
pulo=false;
item1.up=item1.up;
}
else{
pulo=true;
if(pulo==true){
item1.up+=10;
}
}
Click Mouse
function click(){
game.print("click");
}
game.click_start("id do obj",click);
Move Mouse
game.move_mouse(id do obj);
Touch Move
game.touch_move("id do obj");
Touch start e and
function click(){
game.print("touch start ative");
}
game.touch_end("id do obj",click);
// or
game.touch_start("id do obj",click);
Add obj dentro de outro obj
game.obj_in_obj(id do obj1,id do obj2);
Set Text
game.set_text(id do obj,"texto");
game.set_text(id do obj,1+1);
Teclado log keydown keyup
game.log_key;
game.log_down(logKey1);
function logKey1(e) {
if( e.code == "KeyS") {
game.print("Test log key down ok!");
}
}
game.log_up(logKey2);
function logKey2(e) {
if( e.code == "KeyS") {
game.print("Test log key up ok!");
}
}
Scale X
game.scaleX("id player ou obj","-1");
Random Math
random_m(max,min,variante);
Random Math floor
random_mf(max,min,variante);
Opacity
opacity(id,value);
kill_free
kill_free(id);
som_play
game.som_play(id,path som);
touchpad virtual
html{
<div id="joy">
</div>
}
game.touchpad("joy" ,set left,set top);
stick=game.get_obj("stick");
base=game.get_obj("base-stick");
if(stick.offsetLeft == 32){
anim="parado";
di=di;
}else if(stick.offsetLeft >= -10){
anim="corre";
di+=5;
scala=1;
game.force_obj("player",di,up,false);
}
else if(stick.offsetLeft < 50){
anim="corre";
di-=5;
scala=-1;
game.force_obj("player",di,up,true);
}
if(stick.offsetTop <= -1 ){
up-=0;
}
Create sprite
//create_sprite(id,img,width,height,left,top)
Nandraki.create_sprite("player","player.png",64,64,32,50);
img frame
//img_frame(img_id,width,height,math frame,start frame,end frame,rest frame)
anim="run";
if(anim=="run"){
game.img_frame("img_player",64,64,6,frame++,13,10);
if(frame==15)frame=10
}
bd_save: function(variavel,value)
localStorage.setItem(variavel, value);
bd_load: function(variavel)
game.bd_load(variavel)
bd_remove: function(variavel)
game.bd_remove(variavel)
bd_clear: function()
game.bd_clear();