GithubHelp home page GithubHelp logo

joey-wong / nes-vue Goto Github PK

View Code? Open in Web Editor NEW

This project forked from taiyuuki/nes-vue

0.0 0.0 0.0 394 KB

A NES(FC) emulator component for Vue 3.

License: MIT License

TypeScript 16.36% HTML 2.54% Vue 81.10%

nes-vue's Introduction

nes-vue

A NES(FC) emulator component for Vue 3.

🇨🇳中文

Demo

🚀Demo

Demo is in the example/ directory of this repository.

How to use

install

npm install nes-vue --save

global component

import { createApp } from "vue";
import App from "./App.vue";
import eux from "nes-vue";

createApp(App).use(eux).mount("#app");

Then:

<template>
    <nes-eux url="example.com/xxx.nes" autoStart :width="512" :height="480" />
</template>

local component

<template>
  <nes-eux url="example.com/xxx.nes" autoStart :width="512" :height="480" />
</template>
<script setup>
  import { NesEux } from 'nes-vue';
</script>

API

props

Property Description Type Default
url URL of the nes ROM. Required!!! string
width Game screen width number 256
height Game screen height number 240
label Text of the game screen, show only before running string ‘Game Start’
autoStart Auto start when the component on mounted boolean false
Controller_P1 player 1 controller object see below
Controller_P2 player 2 controller object see below

The values of the controller keys are KeyboardEvent.code, default values:

Controller_P1 = {
    UP: 'KeyW',
    DOWN: 'KeyS',
    LEFT: 'KeyA',
    RIGHT: 'KeyD',
    A: 'KeyK',
    B: 'KeyJ',
    SELECT: 'Digit2',
    START: 'Digit1'
}
Controller_P2 = {
    UP: 'ArrowUp',
    DOWN: 'ArrowDown',
    LEFT: 'ArrowLeft',
    RIGHT: 'ArrowRight',
    A: 'Numpad2',
    B: 'Numpad1'
}

events

events Description
@fpsPerSecond -> function(fps: number) Emitted per second when the game is running.
@success -> function() Emitted when the ROM is loaded successfully.
@error -> funciont(message: string) Emitted when ROM load error occurs.
<template>
    <nes-eux url="example.com/xxx.nes" @fpsPerSecond="getFPS" />
</template>
<script setup>
function getFPS(fps){
    console.log(fps.toFixed(2))
}
</script>

Methods

Method
gameStart(url: string) => void
gameReset() => void
gameStop() => void

nes-vue's People

Contributors

taiyuuki avatar

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.