Skip to content

Commit

Permalink
add block image
Browse files Browse the repository at this point in the history
  • Loading branch information
da-in committed Jan 20, 2024
1 parent d0fa0a1 commit 7dca7e5
Show file tree
Hide file tree
Showing 18 changed files with 71 additions and 17 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"vue-router": "^4.2.5"
},
"devDependencies": {
"@types/node": "^20.11.5",
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.15.0",
"@vitejs/plugin-vue": "^4.5.2",
Expand Down
20 changes: 17 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added src/assets/block/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/block/10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/block/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/block/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/block/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/block/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/block/6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/block/7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/block/8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/block/9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 11 additions & 11 deletions src/pages/play/_components/NextBlock.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
</div>
</template>
<script setup lang="ts">
import {computed} from "vue";
import n1 from '/src/assets/next/n1.png'
import n2 from '/src/assets/next/n2.png'
import n3 from '/src/assets/next/n3.png'
import n4 from '/src/assets/next/n4.png'
import n5 from '/src/assets/next/n5.png'
import n6 from '/src/assets/next/n6.png'
import n7 from '/src/assets/next/n7.png'
import n8 from '/src/assets/next/n8.png'
import n9 from '/src/assets/next/n9.png'
import n10 from '/src/assets/next/n10.png'
import {computed} from "vue"
import n1 from '@/assets/next/n1.png'
import n2 from '@/assets/next/n2.png'
import n3 from '@/assets/next/n3.png'
import n4 from '@/assets/next/n4.png'
import n5 from '@/assets/next/n5.png'
import n6 from '@/assets/next/n6.png'
import n7 from '@/assets/next/n7.png'
import n8 from '@/assets/next/n8.png'
import n9 from '@/assets/next/n9.png'
import n10 from '@/assets/next/n10.png'
const props = defineProps({
nextIndex: {
Expand Down
24 changes: 24 additions & 0 deletions src/pages/play/setting.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
import b1 from '../../assets/block/1.png'
import b2 from '../../assets/block/2.png'
import b3 from '../../assets/block/3.png'
import b4 from '../../assets/block/4.png'
import b5 from '../../assets/block/5.png'
import b6 from '../../assets/block/6.png'
import b7 from '../../assets/block/7.png'
import b8 from '../../assets/block/8.png'
import b9 from '../../assets/block/9.png'
import b10 from '../../assets/block/10.png'

type Block = {
size: number;
color: string;
Expand All @@ -19,3 +30,16 @@ const blocks: { [key: number]: Block } = {
};

export {lineColor, blocks}

export const Background: {[key: number]: any} = {
1: b1,
2: b2,
3: b3,
4: b4,
5: b5,
6: b6,
7: b7,
8: b8,
9: b9,
10: b10
}
4 changes: 4 additions & 0 deletions src/types/images.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module '*.png' {
const value: any;
export default value;
}
10 changes: 8 additions & 2 deletions src/utils/create-block.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import {Bodies} from "matter-js";
import {blocks, lineColor} from "../pages/play/setting.ts";
import {Bodies} from "matter-js"
import {Background, blocks, lineColor} from "../pages/play/setting.ts"

export const createBlock = (index: number, x:number, y:number, isStatic:boolean=false) => {
const block = blocks[index]
const background = Background[index]
const circle = Bodies.circle(x, y, block.size/2, {
isStatic,
label: String(index),
render: {
fillStyle: block.color,
lineWidth: 2.5,
strokeStyle: lineColor,
sprite: {
texture: background,
xScale: 1/3,
yScale: 1/3,
}
}
})
return circle
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
"noFallthroughCasesInSwitch": true,
"typeRoots": ["/src/types/images.d.ts"],
},
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"],
"references": [{ "path": "./tsconfig.node.json" }]
Expand Down
4 changes: 4 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
base: '/watermelon',
resolve: {
alias: [{ find: "@", replacement: resolve(__dirname, "./src") }]
}
})

0 comments on commit 7dca7e5

Please sign in to comment.