2 | {{ spriteData.position.x }}, {{ spriteData.position.y }}
3 |
4 |
5 |
--------------------------------------------------------------------------------
/packages/sample2/main/maps/map.ts:
--------------------------------------------------------------------------------
1 | import { RpgPlayer } from '@rpgjs/server'
2 | import { MapData, RpgMap } from '@rpgjs/server'
3 |
4 | @MapData({
5 | id: 'map',
6 | file: require('../worlds/maps/map.tmx')
7 | })
8 | export default class TownMap extends RpgMap {
9 | onInit() {
10 | console.log('Map loaded')
11 | }
12 |
13 | onJoin(player: RpgPlayer) {
14 | console.log('enter', player.id)
15 | }
16 |
17 | // When the player leaves the map
18 | onLeave(player: RpgPlayer) {
19 | super.onLeave(player)
20 | console.log('leave', player.id)
21 | }
22 | }
--------------------------------------------------------------------------------
/packages/sample2/main/scene-map.ts:
--------------------------------------------------------------------------------
1 | import { RpgSceneMapHooks, RpgSceneMap, RpgGui } from '@rpgjs/client'
2 |
3 | const sceneMap: RpgSceneMapHooks = {
4 | onAfterLoading(scene) {
5 | scene.on('click', (ev) => {
6 | console.log('scene', ev)
7 | })
8 | },
9 | }
10 |
11 | export default sceneMap;
--------------------------------------------------------------------------------
/packages/sample2/main/server.ts:
--------------------------------------------------------------------------------
1 | import { RpgServerEngine } from "@rpgjs/server"
2 |
3 | export default {
4 | auth(engine: RpgServerEngine, socket) {
5 |
6 | },
7 | onStart(engine: RpgServerEngine) {
8 |
9 | }
10 | }
--------------------------------------------------------------------------------
/packages/sample2/main/sounds/theme.ogg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RSamaium/RPG-JS/7ae3df045566b595a8bdca60e2b2ea411e620868/packages/sample2/main/sounds/theme.ogg
--------------------------------------------------------------------------------
/packages/sample2/main/sounds/theme.ts:
--------------------------------------------------------------------------------
1 | import { Sound } from '@rpgjs/client'
2 |
3 | @Sound({
4 | sounds: {
5 | town: require('./theme.ogg'),
6 | },
7 | loop: true
8 | })
9 | export default class Musics {}
--------------------------------------------------------------------------------
/packages/sample2/main/sprite.ts:
--------------------------------------------------------------------------------
1 | import { RpgSprite, RpgSpriteHooks } from '@rpgjs/client'
2 |
3 | const sprite: RpgSpriteHooks = {
4 | onInit(sprite: RpgSprite) {
5 | sprite.eventMode = 'static'
6 | sprite.on('click', (event) => {
7 | console.log('ok')
8 | //console.log(event)
9 | })
10 | }
11 | }
12 |
13 | export default sprite
--------------------------------------------------------------------------------
/packages/sample2/main/spritesheets/animations/animation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RSamaium/RPG-JS/7ae3df045566b595a8bdca60e2b2ea411e620868/packages/sample2/main/spritesheets/animations/animation.png
--------------------------------------------------------------------------------
/packages/sample2/main/spritesheets/animations/animation.ts:
--------------------------------------------------------------------------------
1 | import { Spritesheet } from '@rpgjs/client'
2 |
3 | const to = () => {
4 | const array: any = []
5 | let k = 0
6 | for (let i=0 ; i < 4 ; i++) {
7 | for (let j=0 ; j < 5 ; j++) {
8 | array.push({ time: k * 5, frameX: j, frameY: i })
9 | k++
10 | }
11 | }
12 | return array
13 | }
14 |
15 | @Spritesheet({
16 | framesWidth: 5,
17 | framesHeight: 4,
18 | opacity: 1,
19 | anchor: [0.5],
20 | textures: {
21 | default: {
22 | animations: [ to() ]
23 | }
24 | }
25 | })
26 | export default class ShieldAnimations {}
--------------------------------------------------------------------------------
/packages/sample2/main/spritesheets/npc/female.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RSamaium/RPG-JS/7ae3df045566b595a8bdca60e2b2ea411e620868/packages/sample2/main/spritesheets/npc/female.png
--------------------------------------------------------------------------------
/packages/sample2/main/spritesheets/npc/male.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RSamaium/RPG-JS/7ae3df045566b595a8bdca60e2b2ea411e620868/packages/sample2/main/spritesheets/npc/male.png
--------------------------------------------------------------------------------
/packages/sample2/main/spritesheets/npc/spritesheet.ts:
--------------------------------------------------------------------------------
1 | import { Spritesheet, Presets } from '@rpgjs/client'
2 |
3 | const { RMSpritesheet } = Presets
4 |
5 | @Spritesheet(
6 | RMSpritesheet(3, 4)
7 | )
8 | export default class Characters { }
--------------------------------------------------------------------------------
/packages/sample2/main/worlds/maps/base.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RSamaium/RPG-JS/7ae3df045566b595a8bdca60e2b2ea411e620868/packages/sample2/main/worlds/maps/base.png
--------------------------------------------------------------------------------
/packages/sample2/main/worlds/world.world:
--------------------------------------------------------------------------------
1 | {
2 | "maps": [
3 | {
4 | "fileName": "maps/map.tmx",
5 | "height": 640,
6 | "width": 640,
7 | "x": 288,
8 | "y": 64
9 | },
10 | {
11 | "fileName": "maps/map2.tmx",
12 | "height": 640,
13 | "width": 640,
14 | "x": -352,
15 | "y": 65
16 | }
17 | ],
18 | "onlyShowAdjacentMaps": false,
19 | "type": "world"
20 | }
21 |
--------------------------------------------------------------------------------
/packages/sample2/plugin/index.ts:
--------------------------------------------------------------------------------
1 | import server from 'server!./server'
2 |
3 | export default {
4 | client: null,
5 | server
6 | }
--------------------------------------------------------------------------------
/packages/sample2/plugin/server/index.ts:
--------------------------------------------------------------------------------
1 | import { RpgServer, RpgModule } from '@rpgjs/server'
2 | import player from './player.js';
3 |
4 | /** @ts-ignore */
5 | @RpgModule