Commands Or Functions - Arshiatmi/jsha GitHub Wiki

There Is Lots Of Commands For You !


print(str [ An String That You Want To Log ] )

    Equals console.log(str) Command ! Example :

    print("This Is A Test Log !")

    Output On Browser Console :

    This Is A Test Log !


$(id [ id Of Element That You Want To Find ] )

    Returns The Object With Your Specific HTML ID. Example :

    $("test")

    Returns :

    <div id='test' ... > ... </div>


_( name [ Name Of Elements That You Want To Find ] )

    Returns All Of The Objects With Your Specific HTML Name.Example :

    _("test")

    For Example Returns :

    Node List [2]


collision( obj1 [ The Html Object ] ,obj2 [ The Html Object ] )

    Check If Two Objects Have Collision Or Not In The Page. Example :

    collision($("test"),$("test2"))

    For Example Returns :

    true


setInMiddle( object ( gameObject Or boardObject ) )

    You Can Set A gameObject Or boardObject At Middle Of Your Screen !


setImg( obj1 [The Html Object(Img Tag)] , img [Image Source] )

    Set Image Source Of An Img Tag To (img) {What You Send Here}. Example :

    setImg($("test"),"./test.jpg")

    Returns Nothing But Image Of (test) Changed !


sendEvent( which_event [ The Event That You Want To Send ] , func [ The Function That Runs When Event Called ] , id = "")

    Send An Event To All Of The Body. For Example If Your Event Is Key And You Didnt Gave An Id Event Will Be Happend In All Of Page. Means Everywhere In Page Clicked This Function Should Run. If You Want To Send To An Element You Can Give ID At The Last Argument Else You Can Leave It Empty. Example :

sendEvent("keypress",myFunc)
function myFunc(event){
    print(event.key)
}

    For Example Output In Browser Console Is :

a
w
e
r
f
s

randInt( to = 10 )

    Gives You A Random Number Between 1 and 10. If You Want More You Can Set First Argument To Something Else. Example :

    randInt(12)

    For Example Returns :

    8


moveX( obj1 [ The Html Object ] , how_many [ How Many Pixels You Want To Move ? Example 10 Or -10 ] )

    It Will Move An Object In Body (Just X Or Horizontal). Example :

    moveX($("test"),20)

    Nothing Returns But The (test) Object Moved In 20px In Horizontal.

    Notice : You Have To Use init(id) Before Using This Command.


moveY( obj1 [ The Html Object ] , how_many [ How Many Pixels You Want To Move ? Example 10 Or -10 ] )

    It Will Move An Object In Body (Just Y Or Vertical). Example :

    moveY($("test"),20)

    Nothing Returns But The (test) Object Moved In 20px In Vertical.

    Notice : You Have To Use init(id) Before Using This Command.


setX( obj1 [ The Html Object ] , how_many [ What X You Wanted To Set To This Element ? ] )

    It Will Set An Object's X In Body. Example :

    setX($("test"),20)

    Nothing Returns But The (test) Object X Now Is 20px .

    Notice : You Have To Use init(id) Before Using This Command.


setY( obj1 [ The Html Object ] , how_many [ What Y You Wanted To Set To This Element ? ] )

    It Will Set An Object's Y In Body. Example :

    setY($("test"),20)

    Nothing Returns But The (test) Object Y Now Is 20px .

    Notice : You Have To Use init(id) Before Using This Command.


setL( obj1 [ The Html Object ] , x [ X Of Element In Page ] , y [ Y Of Element In Page ] )

    It Will Set Location Of An Element In Body. Example :

    setL($("test"),20,30)

    Nothing Returns But The (test) Object X Now Is 20px And Y Is 30px .

    Notice : You Have To Use init(id) Before Using This Command.


remove( obj1 [ The Html Object ] )

    Remove An Object From The Page . Example :

    remove($("test"))

    Nothing Returns But The (test) Object Is Removed From The Screen .


getDirection( obj1 [ The Html Object ] , obj2 [ The Html Object ] )

    It Will Return A JSON Object That Contains X and Y . Calculated Like That :

   {x : (x2 - x1), y : (y2 - y1)}

    Means Distance Between Two Object.


getDirectionS( obj1 [ The Html Object ] , obj2 [ The Html Object ] )

    It Will Return An String That Contains Direction . Example :

   "U"

    That Means Up. All Directions Are Here :

U : UP
D : DOWN
L : LEFT
R : RIGHT
UR : UP-RIGHT
DR : DOWN-RIGHT
UL : UP-LEFT
DL : DOWN-LEFT

getDirectionG( obj1 [ The Html Object ] , obj2 [ The Html Object ] )

    It Will Return An String That Contains Geographical Direction . Example :

   "N"

    That Means North. All Geographical Directions Are Here :

N : NORTH
S : SOUTH
E : EAST
W : WEST
NE : NORTH-EAST
SE : SOUTH-EAST
NW : NORTH-WEST
SW : SOUTH-WEST

getLocation( obj1 [ The Html Object ] )

    Returns A JSON Object Contains X and Y Of Object In Body.

     Example : { x: "12", y: "200" }


playAudio( Source [ The Audio Source ] )

    Play The Source That You Gave. ( Because Of Some Rules You Cant Play It Auto And You Have To Do It After One Event. For Example When Key 'a' Pressed !


pourX( obj, how_many, y )

    This Is Dopest Thing That I Personally Love ! You Can pour a jshaObject In Screen As Many As You Want And In Specific y Of Page. ( y Is Distance To Up Of Page ).You Can Run Like pourX(enemy,10,100). It Will Make 10 Enemies With 100px Distance From up In Equal Distance Between Them ! You Can See Example Of This Thing In Quick Start.


collision( obj1, obj2 )

    You Can Check That If 2 Objects Have Collision Or Not. Objects Must Be Simple HTML Objects ( Like document.getElementById("id") object ) .


sleep( ms )

    This Function Just Works On async Functions And You Need To Run This Function Like await sleep(1000); That Will Wait 1 Second.


getMiddle( obj, mode )

    obj Must Be gameObject, boardObject Or A Simple HTML Object. It Will Return Center Of object If mode is "object" And It Will Return Center Of Page Depends On Object If Mode Is "page". Data That Return Is an JSIN Like {"x":width,"y":height}.


collisionCheck( mainobject,name,func )

    mainobject Must Be Id Of An Object That You Want To Check. name Must Be name Of Object That You Want To Check If Its collisions To Anything Else And func Is Function That Will Be Execute If a collision Happend.


restart( )

    Just Restart The Game. ( Refresh Page )


setTreshold( object_name, func, x, y )

    This Will Set A Treshold That When An Object Pass From An Specific Are, Something Happend.object_name Must Be The name Of Objects, For Example "bullets". func Must Be The Function That Will Run When Conditions Are True. x And y Must Be An Array Like [min,max]. Default func Is remove That removes Objects And x And y Defaults Are [0,maxOfScreen].


checkXO(board)

    This Function Is A Function That Checks If X Wins Or O Wins In A boardObject.

⚠️ **GitHub.com Fallback** ⚠️