Giter VIP home page Giter VIP logo

lib3ds's Introduction

About

What's this?

lib3DS is a tiny JavaScript library to help you write games and applications that run on the Nintendo 3DS Web Browser. It can set up three different display modes and handle D-pad and A button input.

Who made it?

Me, Andrea Faulds. I admittedly took some ideas on how to deal with positioning from Andy Smith's jFox demo and the 3DSPlaza Sidescroller Demo. However all the code contained within this library was written by me.

What license is it under?

The MIT license, see the header of lib3DS.js

How do I use it?

There are three display mode functions, and the intention is that only one is called. Your page's body should be entirely empty except for your script includes. The mode function will set things up for you, returning one or two DOM elements (depending on the mode). You should display everything inside those one or two elements and not append anything to the body yourself.

The button handling will overwrite existing .onkeydown and .onkeyup handlers for document.body, if any, but you can otherwise use it in any page.

API

The "bouncing" mentioned is due to the left, right, up or down keys moving the page. In some modes, due to the page's size and positioning, the browser will not let the page move in that direction. However, in the cases where it will, lib3DS will move the page back. This is unfortunately not always instant, leading to the page shifting briefly while it "bounces" back. It won't break your button event handlers or anything like that, but it will be annoying, so if you wish to use a mode where pressing a certain button causes "bouncing", you should probably avoid using that button in your control scheme.

  • lib3DS.initMode320()

    Sets up display mode and returns object containing one key:

    • bottomScreen - DOM element of div showing on bottom screen of 3DS In this mode, there is no top screen. The bottom screen is 320x212px. No keys cause bouncing by being pressed in this mode.
  • lib3DS.initModeDual320()

    Sets up display mode and returns object containing two keys:

    • topScreen - DOM element of div showing on top screen of 3DS
    • bottomScreen - DOM element of div showing on bottom screen of 3DS In this mode, top screen is 320x214px and the bottom screen is 320x212px. Pressing the up key may cause bouncing.
  • lib3DS.handleButtons([onkeydown[, onkeyup]])

    Registers event handlers for buttons. onkeydown and onkeyup will be called when a button is depressed or released, respectively. The name of the button ("A", "left", "up", "right" or "down") will be passed as the first parameter when calling them. Both parameters are optional and if a falsey value (null, false, undefined, etc.) is passed instead, the function will not be called.

lib3ds's People

Contributors

hikari-no-yume avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

nicolaze

lib3ds's Issues

New Nintendo 3DS compatibility?

See the issue for PictoSwap: hikari-no-yume/PictoSwap#19

From what I have heard, PictoSwap works fine on the New 3DS, so I assume this library (which PictoSwap uses) does. There might be minor issues I'm unaware of, though. Maybe the New 3DS's browser allows us to do things we couldn't before?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.