|
| 1 | +# Dudes |
| 2 | + |
| 3 | +> Animated dudes for chatters in your stream |
| 4 | +
|
| 5 | +> [!WARNING] |
| 6 | +> Permantly moved to [twirapp/dudes](https://github.com/twirapp/dudes) |
| 7 | +
|
| 8 | +## Install |
| 9 | + |
| 10 | +```bash |
| 11 | +pnpm add @twirapp/dudes |
| 12 | +``` |
| 13 | + |
| 14 | +## Usage |
| 15 | + |
| 16 | +```vue |
| 17 | +<script setup lang="ts"> |
| 18 | +import DudesOverlay, { DudesLayers } from '@twirapp/dudes' |
| 19 | +import { onMounted, ref } from 'vue' |
| 20 | +
|
| 21 | +import type { |
| 22 | + DudesStyles, |
| 23 | + AssetsLoaderOptions, |
| 24 | + SoundAsset |
| 25 | +} from '@twirapp/dudes/types' |
| 26 | +
|
| 27 | +const soundAssets: SoundAsset[] = [ |
| 28 | + { |
| 29 | + alias: 'Jump', |
| 30 | + src: './sounds/jump.mp3' |
| 31 | + } |
| 32 | +] |
| 33 | +
|
| 34 | +const assetsLoaderOptions: AssetsLoaderOptions = { |
| 35 | + basePath: location.href + 'sprites/', |
| 36 | + defaultSearchParams: { |
| 37 | + ts: Date.now() |
| 38 | + } |
| 39 | +} |
| 40 | +
|
| 41 | +const settings = ref<DudesStyles>({ |
| 42 | + // override default settings |
| 43 | +}) |
| 44 | +
|
| 45 | +const dudesRef = ref<DudesMethods | null>(null) |
| 46 | +
|
| 47 | +onMounted(async () => { |
| 48 | + if (!dudesRef.value) return |
| 49 | + await dudesRef.value.initDudes() |
| 50 | +
|
| 51 | + const dudeName = 'Twir' |
| 52 | + const dude = await dudesRef.value.createDude({ |
| 53 | + id: dudeName, |
| 54 | + name, |
| 55 | + sprite: { |
| 56 | + name: 'dude', |
| 57 | + layers: [ |
| 58 | + { |
| 59 | + layer: DudesLayers.Body, |
| 60 | + // http://localhost:5173/sprites/body.png |
| 61 | + src: 'body.png' |
| 62 | + }, |
| 63 | + { |
| 64 | + layer: DudesLayers.Eyes, |
| 65 | + // http://localhost:5173/sprites/eyes.png |
| 66 | + src: 'eyes.png' |
| 67 | + } |
| 68 | + ] |
| 69 | + } |
| 70 | + }) |
| 71 | +}) |
| 72 | +</script> |
| 73 | +
|
| 74 | +<template> |
| 75 | + <dudes-overlay |
| 76 | + ref="dudesRef" |
| 77 | + :assets-loader-options="assetsLoaderOptions" |
| 78 | + :sounds="soundAssets" |
| 79 | + :settings="settings" |
| 80 | + /> |
| 81 | +</template> |
| 82 | +
|
| 83 | +<style> |
| 84 | +* { |
| 85 | + margin: 0; |
| 86 | + box-sizing: border-box; |
| 87 | +} |
| 88 | +
|
| 89 | +body { |
| 90 | + overflow: hidden; |
| 91 | + background: #000; |
| 92 | +} |
| 93 | +</style> |
| 94 | +``` |
| 95 | + |
| 96 | +## Creating new sprites |
| 97 | + |
| 98 | +It's really easy to create sprites with [Aseprite](https://github.com/aseprite/aseprite) |
| 99 | + |
| 100 | +Sprite size is 32x32. |
| 101 | + |
| 102 | +Example can be found in [sprites](apps/playground/public/sprites) folder. |
| 103 | + |
| 104 | +## Useful links |
| 105 | + |
| 106 | +- [https://0x72.itch.io/pixeldudesmaker](https://0x72.itch.io/pixeldudesmaker) |
| 107 | +- [https://masterpose.itch.io/pixelduuuuudesmaker](https://masterpose.itch.io/pixelduuuuudesmaker) |
0 commit comments