vue3+threejs新手从零开发卡牌游戏(九):添加抽卡逻辑和动效

首先优化下之前的代码,把game/deck/p1.vue中修改卡组方法和渲染卡组文字方法提到公共方法中,此时utils/common.ts完整代码如下:


import { nextTick } from 'vue';
import * as THREE from 'three';
import * as TWEEN from '@tweenjs/tween.js'
import { TextGeometry } from 'three/addons/geometries/TextGeometry.js';

// 坐标归一化
const transPos = (x: any, y: any) => {
  let pointer = new THREE.Vector2()
  
  pointer.x = ( x / window.innerWidth ) * 2 - 1;
  pointer.y = - ( y / window.innerHeight ) * 2 + 1;

  return pointer
}
export { transPos }

// 修改卡组
const editDeckCard = (group:any, mesh: any, type: any) => {
  return new Promise((resolve, reject) => {
    let text = group.children.find((v: any) => v.name === "卡组数量")
    let shadowText = group.children.find((v: any) => v.name === "卡组数量阴影")
    // console.log(22, group.children, commonStore.$state.p1Deck)
    if (type === "remove") { // 删除卡组中的卡牌
      let child = group.children.find((v: any) => v.name === mesh.name)
      if (child) {
        group.remove(child)
      }
    }
    group.remove(text)
    group.remove(shadowText)
    group.children.forEach((v: any, i: any) => {
      v.position.set(0, 0.005 * i, 0)
    })
    resolve(true)
  })
}
export { editDeckCard }

// 渲染卡组文字
const renderText = (group: any, text: any, font: any, position: any) => {
  return new Promise((resolve, reject) => {
    const geometry = new TextGeometry( `${text}`, {
      font,
      size: 0.4,
      height: 0,
      curveSegments: 4,
      bevelEnabled: true,
      bevelThickness: 0,
      bevelSize: 0,
      bevelSegments: 0
    });
    geometry.center()
    const material = new THREE.MeshBasicMaterial({ 
      color: new THREE.Color("white"),
      alphaHash: true
    })
    const mesh = new THREE.Mesh( geometry, material ) ;
    mesh.position.set(position.x, position.y + 0.01, position.z)
    // mesh.position.set(0, 0.005 * commonStore.$state.p1Deck.length + 0.01, 0)
    mesh.rotateX(-90 * (Math.PI / 180)) // 弧度
    mesh.name = "卡组数量"
  
    // 阴影
    let shadowGeometry = geometry.clone()
    shadowGeometry.translate(0.02, 0.02, 0);
    let shadowMaterial = new THREE.MeshBasicMaterial({
      color: new THREE.Color("black"),
      alphaHash: true
    });
    let shadowMesh = new THREE.Mesh(shadowGeometry, shadowMaterial);
    shadowMesh.position.set(position.x, position.y, position.z)
    // shadowMesh.position.set(0, 0.005 * commonStore.$state.p1Deck.length, 0)
    shadowMesh.rotateX(-90 * (Math.PI / 180)) // 弧度
    shadowMesh.name = "卡组数量阴影"
  
    group.add(mesh)
    group.add(shadowMesh)

    resolve(true)
  })
}
export { renderText }

同步修改game/index.vue中对修改卡组方法的使用:


import { transPos, editDeckCard, renderText } from "@/utils/common.ts"

// 初始化手牌
const initHand = () => {
  let cardNumber = 4
  let _number = 0
  let p1Deck = JSON.parse(JSON.stringify(commonStore.$state.p1Deck))
  let deckGroup = scene.getObjectByName("p1_deckGroup")
  let position = new THREE.Vector3(0, 0.005 * p1Deck.length, 0)
  let _interval = setInterval(async() => {
    // console.log(123, p1Deck)
    if (_number < cardNumber) {
      let obj = p1Deck[p1Deck.length - 1]
      p1Deck.splice(p1Deck.length-1, 1)
      commonStore.updateP1Deck(p1Deck)
      // 修改卡组
      await editDeckCard(deckGroup, obj, "remove")
      await renderText(deckGroup, `${commonStore.$state.p1Deck.length}`, commonStore.$state._font, position)
      // 手牌区添加手牌
      handRef.value.addHandCard(obj, deckGroup)
    } else {
      clearInterval(_interval)
    }
    _number++
  }, 200)

}

之后我们思考下抽卡逻辑:
1.点击卡组,将卡组平移到页面中心位置(0, 0, 0)(y轴可以适当调高一点,这里点击事件只是为了测试抽卡,之后可以删掉)
2.然后卡组上展示“点击抽卡”的文字(文字用的是div+css的形式)

3.点击抽卡,执行抽卡动画

4.抽卡结束后,卡组移回到原位

首先我们在game/index.vue中添加点击事件,用raycaster射线进行鼠标拾取,当点击在卡组上时,执行onP1DeckEvent,这里由于是移动端所以只监听了touch事件,pc端则需要额外监听click事件:

// 鼠标按下
window.addEventListener('touchstart', onMousedown)

// 鼠标按下事件
const onMousedown = (ev: any) => {
  // console.log(222, ev.target)
  // 判断是否点击到canvas上
  if(!(ev.target instanceof HTMLCanvasElement)){
    return;
  }
  // 将鼠标位置归一化为设备坐标。x 和 y 方向的取值范围是 (-1 to +1)
  let clientX = ev.clientX || ev.changedTouches[0].pageX
  let clientY = ev.clientY || ev.changedTouches[0].pageY
  // pointer.x = ( clientX / window.innerWidth ) * 2 - 1;
  // pointer.y = - ( clientY / window.innerHeight ) * 2 + 1;

  let point = transPos(clientX, clientY) // 卡组起始位置的屏幕坐标

  // 通过摄像机和鼠标位置更新射线
  raycaster.setFromCamera( point, camera );

  // 点击卡组事件
  onP1DeckEvent()
}

// 点击卡组事件
const onP1DeckEvent = () => {
  if (commonStore.$state.p1Deck.length <= 0) {
    return
  }
  let p1_deckGroup = scene.getObjectByName("p1_deckGroup")
  let arr = raycaster.intersectObject(p1_deckGroup, true)
  if (arr.length <= 0) {
    return
  }
  let pos1 = p1_deckGroup.userData.position
  let pos2 = new THREE.Vector3(0, 2, 0)
  // console.log(444, pos1, pos2)
  if (p1_deckGroup.position.x !== pos2.x) {
    drawCardRef.value.drawCardAnimate1(p1_deckGroup, pos1, pos2)
  }
}

然后我们在src下新建一个抽卡组件:

这个组件其实是用div+css画了一个透明的蒙层,卡组移到中央后,展示蒙层和“点击抽卡”字样,然后卡组动画我们分为两步,第一步是卡组飞到页面中心,用户点击抽卡后,执行之前的修改卡组和添加手牌方法,然后隐藏蒙层,执行第二步卡组移回原文动画,components/DrawCard.vue完整代码如下:

<!-- 抽卡 -->
<template>
  <div v-if="state.visible" ref="maskRef" class="mask">
    <div class="box" @click="onDrawCard">
      <p>点击抽卡</p>
    </div>
  </div>
</template>

<script setup lang="ts">
import { reactive, ref, onMounted, onBeforeUnmount, watch, defineComponent, getCurrentInstance, nextTick } from 'vue'
import { useCommonStore } from "@/stores/common.ts"
import { TextGeometry } from 'three/addons/geometries/TextGeometry.js';
import { transPos, editDeckCard, renderText } from "@/utils/common.ts"

const props: any = defineProps({
  handRef: {},
  deckRef: {}
})

// 引入threejs变量
const {proxy} = getCurrentInstance()
const THREE = proxy['THREE']
const scene = proxy['scene']
const camera = proxy['camera']
const renderer = proxy['renderer']
const TWEEN = proxy['TWEEN']

const commonStore = useCommonStore()
const maskRef = ref()

const state = reactive({
  visible: false
})

// 卡组抽卡动画1-卡组移到页面中央
const drawCardAnimate1 = (deckGroup: any, startPos: any, endPos: any) => {
  // 隐藏卡组数量和卡组数量阴影几何体
  let textMesh = deckGroup.children.find((v: any) => v.name === "卡组数量")
  let textShadowMesh = deckGroup.children.find((v: any) => v.name === "卡组数量阴影")

  const tw = new TWEEN.Tween({
    x: startPos.x,
    y: startPos.y,
    z: startPos.z,
    opacity: 1.0,
    group: deckGroup
  })
  tw.to({
    x: endPos.x,
    y: endPos.y,
    z: endPos.z,
    opacity: 0.0,
  }, 200)
  tw.easing(TWEEN.Easing.Quadratic.Out)
  tw.onUpdate((obj: any) => {
    obj.group.position.set(obj.x, obj.y, obj.z)
    textMesh.material.opacity = obj.opacity
    textShadowMesh.material.opacity = obj.opacity
  })
  tw.onComplete(function() {
    state.visible = true
    TWEEN.remove(tw)
  })
  tw.start();
}

// 卡组抽卡动画2-卡组回到原位
const drawCardAnimate2 = (deckGroup: any, startPos: any, endPos: any) => {
  // 隐藏卡组数量和卡组数量阴影几何体
  let textMesh = deckGroup.children.find((v: any) => v.name === "卡组数量")
  let textShadowMesh = deckGroup.children.find((v: any) => v.name === "卡组数量阴影")
  // textMesh.material.opacity = 1
  // textShadowMesh.material.opacity = 1

  const tw = new TWEEN.Tween({
    x: startPos.x,
    y: startPos.y,
    z: startPos.z,
    opacity: 0,
    group: deckGroup
  })
  tw.to({
    x: endPos.x,
    y: endPos.y,
    z: endPos.z,
    opacity: 1,
  }, 200)
  tw.easing(TWEEN.Easing.Quadratic.Out)
  tw.onUpdate((obj: any) => {
    obj.group.position.set(obj.x, obj.y, obj.z)
    textMesh.material.opacity = obj.opacity
    textShadowMesh.material.opacity = obj.opacity
  })
  tw.onComplete(function() {
    TWEEN.remove(tw)
  })
  tw.start();
}

// 抽卡
const onDrawCard = async () => {
  let p1_deckGroup = scene.getObjectByName("p1_deckGroup")
  let p1Deck = JSON.parse(JSON.stringify(commonStore.$state.p1Deck))
  let position = new THREE.Vector3(0, 0.005 * p1Deck.length, 0)

  let obj = p1Deck[p1Deck.length - 1]
  p1Deck.splice(p1Deck.length-1, 1)
  commonStore.updateP1Deck(p1Deck)
  // 修改卡组
  await editDeckCard(p1_deckGroup, obj, "remove")
  await renderText(p1_deckGroup, `${commonStore.$state.p1Deck.length}`, commonStore.$state._font, position)
  // 手牌区添加手牌
  props.handRef.addHandCard(obj, p1_deckGroup)
  state.visible = false
  setTimeout(() => {
    nextTick(() => {
      drawCardAnimate2(p1_deckGroup, p1_deckGroup.position, p1_deckGroup.userData.position)
    })
  }, 500)
}


defineExpose({
  drawCardAnimate1,
  drawCardAnimate2
})
</script>

<style lang="scss" scoped>
.mask {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100vh;
  // background-color: white;
  .box {
    width: 50vh;
    // height: 100px;
    text-align: center;
    font-size: 20px;
    color: #fff;
  }
}
</style>

注意:由于点击事件会穿透蒙层,所以我们在onMousedown方法中添加了ev.target instanceof HTMLCanvasElement进行判断是否点击到了canvas上。

最后还优化了下卡组,给卡组添加了线框,game/deck/p1.vue完整代码如下:

<template>
  <div></div>
</template>

<script setup lang="ts">
import { reactive, ref, onMounted, onBeforeUnmount, watch, defineComponent, getCurrentInstance, nextTick } from 'vue'
import { useCommonStore } from "@/stores/common.ts"
import { TextGeometry } from 'three/addons/geometries/TextGeometry.js';
import { Card } from "@/views/game/Card.ts"
import { CARD_DICT } from "@/utils/dict/card.ts"
import { transPos, renderText } from "@/utils/common.ts"

// 引入threejs变量
const {proxy} = getCurrentInstance()
const THREE = proxy['THREE']
const scene = proxy['scene']
const camera = proxy['camera']
const renderer = proxy['renderer']
const TWEEN = proxy['TWEEN']

const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();

const commonStore = useCommonStore()

// 卡组group
const deckGroup = new THREE.Group()
deckGroup.name = "p1_deckGroup"
scene.add(deckGroup)

const init = () => {
  setDeckPos()
  addDeckWireframe()
  commonStore.$state.p1Deck.forEach((v: any, i: any) => {
    let obj = CARD_DICT.find((b: any) => b.card_id === v.card_id)
    if (obj) {
      let card = new Card(obj)
      let mesh = card.init()
      mesh.position.set(0, 0.005 * i, 0)
      mesh.rotateX(180 * (Math.PI / 180)) // 弧度
      mesh.name = v.name
      deckGroup.add( mesh );
    }
  })

  let position = new THREE.Vector3(0, 0.005 * commonStore.$state.p1Deck.length, 0)
  renderText(deckGroup, `${commonStore.$state.p1Deck.length}`, commonStore.$state._font, position)

}

// 设置卡组位置
const setDeckPos = () => {
  nextTick(() => {
    let plane = scene.getObjectByName("地面")
    let point = transPos(window.innerWidth - 15, window.innerHeight - 15) // 卡组起始位置的屏幕坐标
    // 
    raycaster.setFromCamera( point, camera );
    const intersects1 = raycaster.intersectObject( plane );
    if (intersects1.length > 0) {
      let point = intersects1[0].point
      // deckGroup.position.set(point.x, point.y, point.z)
      deckGroup.position.set(point.x - 0.5, point.y, point.z - 0.7)
      // 记录卡组位置
      let position = new THREE.Vector3(point.x - 0.5, point.y, point.z - 0.7)
      deckGroup.userData["position"] = position
    }
  })
}

// 绘制卡组区域线框
const addDeckWireframe = () => {
  nextTick(() => {
    const edges = new THREE.EdgesGeometry( deckGroup.children[0].geometry );
    const line = new THREE.LineSegments( edges, new THREE.LineBasicMaterial( { color: 0xffffff } ) );
    deckGroup.add(line);
  })
}

defineExpose({
  init,
})
</script>

<style lang="scss" scoped>
</style>

最后看下抽卡效果:

至此基本完成了抽卡逻辑和简单动效的开发。

附录:

game/index.vue完整代码如下:

<template>
  <div ref="sceneRef" class="scene"></div>
  <!-- 手牌 -->
  <Hand ref="handRef"/>
  <!-- 卡组 -->
  <Deck ref="deckRef"/>
  <!-- 抽卡逻辑 -->
  <DrawCard ref="drawCardRef" :handRef="handRef" :deckRef="deckRef"/>
</template>

<script setup lang="ts">
import { reactive, ref, onMounted, onBeforeUnmount, watch, defineComponent, getCurrentInstance, nextTick } from 'vue'
import { OrbitControls } from 'three/addons/controls/OrbitControls.js'; // 轨道控制器
import { FontLoader } from 'three/addons/loaders/FontLoader.js';
import { useCommonStore } from "@/stores/common.ts"
import { transPos, editDeckCard, renderText } from "@/utils/common.ts"
import { Card } from "./Card.ts"
import { CARD_DICT } from "@/utils/dict/card.ts"
import Hand from "./hand/index.vue"
import Deck from "./deck/index.vue"
import DrawCard from "@/components/DrawCard.vue"

// 引入threejs变量
const {proxy} = getCurrentInstance()
const THREE = proxy['THREE']
const scene = proxy['scene']
const camera = proxy['camera']
const renderer = proxy['renderer']
const TWEEN = proxy['TWEEN']

const raycaster = new THREE.Raycaster();
const pointer = new THREE.Vector2();

const commonStore = useCommonStore()

// 场景ref
const sceneRef = ref()
const handRef = ref()
const deckRef = ref()
const drawCardRef = ref()

// 坐标轴辅助
const axesHelper = new THREE.AxesHelper(5);
// 创建轨道控制器
// const controls = new OrbitControls( camera, renderer.domElement );
// 字体加载器
const fontLoader = new FontLoader();

onMounted(async () => {
  await initResource()
  initScene()
  initGame()

  // 鼠标按下
  window.addEventListener('touchstart', onMousedown)
  // window.addEventListener('click', onMousedown)

  // 监听浏览器窗口变化进行场景自适应
  window.addEventListener('resize', onWindowResize, false);
})

// 资源加载
const initResource = () => {
  // 字体加载
  return new Promise((resolve, reject) => {
    fontLoader.load('fonts/helvetiker_regular.typeface.json', (font: any) => {
      commonStore.loadFont(font)
      resolve(true)
    });
  })
}

// 初始化场景
const initScene = () => {
  renderer.setSize( window.innerWidth, window.innerHeight );
  sceneRef.value.appendChild( renderer.domElement );
  scene.add(axesHelper)

  // camera.position.set( 5, 5, 5 );
  camera.position.set( 0, 6.5, 0 );
  camera.lookAt(0, 0, 0)

  addPlane()

  animate();
}

// scene中添加plane几何体
const addPlane = () => {
  const geometry = new THREE.PlaneGeometry( 20, 20);
  const material = new THREE.MeshBasicMaterial( {
    color: new THREE.Color("gray"), 
    side: THREE.FrontSide, 
    alphaHash: true,
    // alphaTest: 0,
    opacity: 0
  } );
  const plane = new THREE.Mesh( geometry, material );
  plane.rotateX(-90 * (Math.PI / 180)) // 弧度
  plane.name = "地面"
  scene.add( plane );
}

// 用requestAnimationFrame进行渲染循环
const animate = () => {
  requestAnimationFrame( animate );
  TWEEN.update()
  renderer.render( scene, camera );
}

// 场景跟随浏览器窗口大小自适应
const onWindowResize = () => {
  camera.aspect = window.innerWidth / window.innerHeight;
  camera.updateProjectionMatrix();
  renderer.setSize(window.innerWidth, window.innerHeight);
}

// 初始化游戏
const initGame = async () => {
  // 初始化卡组
  await initDeck()
  // 初始化手牌
  initHand()
}

// 初始化卡组
const initDeck = () => {
  return new Promise((resolve, reject) => {
    let p1Deck = [
      "YZ-01",
      "YZ-02",
      "YZ-03",
      "YZ-04",
      "YZ-01",
      "YZ-02",
      // "YZ-03",
      // "YZ-04",
      // "YZ-01",
      // "YZ-02",
      // "YZ-03",
      // "YZ-04",
    ]
    // 洗牌
    p1Deck.sort(() => {
      return Math.random() - 0.5
    })
    let newDeck: any = []
    p1Deck.forEach((v: any, i: any) => {
      let obj = CARD_DICT.find((b: any) => b.card_id === v)
      if (obj) {
        newDeck.push({
          card_id: v,
          name: `${obj.name}_${i}`
        })
      }
    })
    // console.log("p1Deck", newDeck)
    commonStore.updateP1Deck(newDeck)
    
    nextTick(() => {
      handRef.value.init()
      deckRef.value.init()
      resolve(true)
    })
  })
}

// 初始化手牌
const initHand = () => {
  let cardNumber = 4
  let _number = 0
  let p1Deck = JSON.parse(JSON.stringify(commonStore.$state.p1Deck))
  let deckGroup = scene.getObjectByName("p1_deckGroup")
  let position = new THREE.Vector3(0, 0.005 * p1Deck.length, 0)
  let _interval = setInterval(async() => {
    // console.log(123, p1Deck)
    if (_number < cardNumber) {
      let obj = p1Deck[p1Deck.length - 1]
      p1Deck.splice(p1Deck.length-1, 1)
      commonStore.updateP1Deck(p1Deck)
      // 修改卡组
      await editDeckCard(deckGroup, obj, "remove")
      await renderText(deckGroup, `${commonStore.$state.p1Deck.length}`, commonStore.$state._font, position)
      // 手牌区添加手牌
      handRef.value.addHandCard(obj, deckGroup)
    } else {
      clearInterval(_interval)
    }
    _number++
  }, 200)

}

// 鼠标按下事件
const onMousedown = (ev: any) => {
  // console.log(222, ev.target)
  // 判断是否点击到canvas上
  if(!(ev.target instanceof HTMLCanvasElement)){
    return;
  }
  // 将鼠标位置归一化为设备坐标。x 和 y 方向的取值范围是 (-1 to +1)
  let clientX = ev.clientX || ev.changedTouches[0].pageX
  let clientY = ev.clientY || ev.changedTouches[0].pageY
  // pointer.x = ( clientX / window.innerWidth ) * 2 - 1;
  // pointer.y = - ( clientY / window.innerHeight ) * 2 + 1;

  let point = transPos(clientX, clientY) // 卡组起始位置的屏幕坐标

  // 通过摄像机和鼠标位置更新射线
  raycaster.setFromCamera( point, camera );

  // 点击卡组事件
  onP1DeckEvent()
}

// 点击卡组事件
const onP1DeckEvent = () => {
  if (commonStore.$state.p1Deck.length <= 0) {
    return
  }
  let p1_deckGroup = scene.getObjectByName("p1_deckGroup")
  let arr = raycaster.intersectObject(p1_deckGroup, true)
  if (arr.length <= 0) {
    return
  }
  let pos1 = p1_deckGroup.userData.position
  let pos2 = new THREE.Vector3(0, 2, 0)
  // console.log(444, pos1, pos2)
  if (p1_deckGroup.position.x !== pos2.x) {
    drawCardRef.value.drawCardAnimate1(p1_deckGroup, pos1, pos2)
  }
}
</script>

<style lang="scss" scoped>
.scene {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
}
</style>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/482452.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Springboot笔记-02

1.使用Spring Initializer快速创建Spring Boot项目 IDE都支持使用Spring的项目创建向导快速创建一个Spring Boot项目&#xff1b; 选择我们需要的模块&#xff1b; 向导会联网创建Spring Boot项目&#xff1b; 默认生成的Spring Boot项目&#xff1b; 主程序已经生成好了&#…

【黄啊码】如何用GPT和向量数据库做问答型AI

知识库服务依赖该数据库&#xff0c;Embedding 形式个性化训练 ChatGPT&#xff0c;必不可少的就是向量数据库 因为 qdrant 向量数据库只支持 Docker 部署&#xff0c;所以需要先安装好 Docker 服务。 命令行安装 拉取镜像 docker pull qdrant/qdrant 运行服务 docker run -…

java动态规划学习笔记

学习笔记目录&#xff0c;这里记录个大纲&#xff0c;详情点链接 背包问题 01背包问题综述 01背包问题&#xff08;二维数组&#xff09;https://blog.csdn.net/m0_73065928/article/details/136794406?spm1001.2014.3001.5501 01背包问题&#xff08;滚动数组&#xff09…

牛客NC111 最大数【中等 贪心、排序 Java,Go,PHP】

题目 题目链接&#xff1a; https://www.nowcoder.com/practice/fc897457408f4bbe9d3f87588f497729 思路 贪心解法对于 numsnums 中的任意两个值 aa 和 bb&#xff0c;我们无法直接从常规角度上确定其大小/先后关系。但我们可以根据「结果」来决定 aa 和 bb 的排序关系&#…

视觉信息处理和FPGA实现第6次作业-Matlab实现灰度图像的亮度调节

一、代码 close all;clear all;clc; pic imread("cameraman.tif"); [M,N] size(pic); disp("Contrast Ajust Demo"); value input("Please input number of value, range: 0~2\n"); while value>2 || value<0disp("The number is in…

15:00面试,15:06就出来了,问的问题有点变态了

从小厂出来&#xff0c;没想到在另一家公司又寄了。 到这家公司开始上班&#xff0c;加班是每天必不可少的&#xff0c;看在钱给的比较多的份上&#xff0c;就不太计较了。没想到3月一纸通知&#xff0c;所有人不准加班&#xff0c;加班费不仅没有了&#xff0c;薪资还要降30%…

比赛记录:Codeforces Round 936 (Div. 2) A~E

传送门:CF [前题提要]:赛时一小时过了A~D,E感觉也不是很难(甚至感觉思维难度是小于D的),感觉这回是自己不够自信了,要是自信一点深入想一下应该也能做出来,咱就是说,如果E和D换一下,结果也是一样的,虽上大分,但是心里很不服,故记录一下 A - Median of an Array 当时网卡加载了…

Winform数据绑定

简介# 在C#中提起控件绑定数据&#xff0c;大部分人首先想到的是WPF&#xff0c;其实Winform也支持控件和数据的绑定。 Winform中的数据绑定按控件类型可以分为以下几种&#xff1a; 简单控件绑定列表控件绑定表格控件绑定 绑定基类# 绑定数据类必须实现INotifyPropertyChanged…

GPT4.0

GPT4.0 支持官网所有功能以及所有第三方GPTS&#xff0c;完全同步官网。无需魔法&#xff0c;填写授权码直达官网。全天超18小时维护&#xff0c;无需担心不稳定。没有永久卡&#xff0c;3.5免费提供&#xff0c;4.0可以按需下单即可&#xff0c;不存在跑路。 需要的联系

B站python爬虫课程笔记(Q16-19结束)

下面是学习的网址&#xff1a; ​​​​​​【Python爬虫】 目录 16、捕捉异常try&except语句的一些问题 1&#xff09;一些常见的异常类型 2&#xff09;try&except的使用 17、测试Bug的一些问题 1&#xff09;assert断定函数的使用 2&#xff09;unittest单元…

2024年阿里云优惠活动整理_云服务器活动大全

2024阿里云优惠活动大全包括云服务器优惠价格、优惠券免费领取入口、域名优惠口令、域名优惠、云数据库优惠活动、对象存储OSS优惠活动、企业邮箱优惠、阿里云建站优惠、无影云电脑优惠价格、CDN特惠等&#xff0c;阿里云服务器网aliyunfuwuqi.com长期更新阿里云优惠活动大全&a…

哈希表(c++)

1、介绍 哈希表&#xff0c;也称为散列表&#xff0c;是一种非常高效的数据结构。它通过将键&#xff08;Key&#xff09;映射到数组的特定位置来快速查找、插入和删除数据。这个映射过程由哈希函数&#xff08;Hash Function&#xff09;完成&#xff0c;该函数将键转化为一个…

【浅尝C++】C++基础第三弹=>内联函数/auto关键字/范围for/nullptr(含如何查看内联函数展开效果)

&#x1f3e0;专栏介绍&#xff1a;浅尝C专栏是用于记录C语法基础、STL及内存剖析等。 &#x1f6a9;一些备注&#xff1a;之前的文章有点杂乱&#xff0c;这里将前面的知识点重新组织了&#xff0c;避免了过多冗余的废话。 &#x1f3af;每日努力一点点&#xff0c;技术变化看…

【已解决】MySQL(Navicat)中如何一次性执行多个sql脚本文件

目录 问题现象&#xff1a; 问题分析&#xff1a; 思路&#xff1a; 解决方法&#xff1a; 1、运行cmd命令窗口 2、执行文本文件内容合并命令 总结&#xff1a; 1、使用文本文件内容合并命令&#xff0c;将多个sql脚本文件的内容合并到一个新的sql文件中去。 2、然后在Nav…

《由浅入深学习SAP财务》:第2章 总账模块 - 2.1 基础知识

2.1.1 总账模块的基本功能 总账模块&#xff08;General Ledger&#xff0c;GL&#xff09;是“总分类账会计模块”的中文简称&#xff0c;它是财务会计&#xff08;FI&#xff09;模块的一个子模块&#xff0c;它是一切会计事务处理的核心模块。 它的基本功能有会计科…

3、Jenkins持续集成-Jenkins安装和插件管理

文章目录 一、Jenkins安装1. 安装JDK2. 获取jenkins安装包3. 安装包上传到服务器&#xff0c;进行安装4. 修改Jenkins配置&#xff08;1&#xff09;低版本Jenkins的rpm包&#xff08;2&#xff09;高版本Jenkins的rpm包 5. 启动Jenkins6. 打开浏览器访问7. 获取并输入admin账户…

1240. 完全二叉树的权值

给定一棵包含 N 个节点的完全二叉树&#xff0c;树上每个节点都有一个权值&#xff0c;按从上到下、从左到右的顺序依次是 A1,A2,⋅⋅⋅AN&#xff0c;如下图所示&#xff1a; 现在小明要把相同深度的节点的权值加在一起&#xff0c;他想知道哪个深度的节点权值之和最大&#x…

在抖音上开店,运营什么产品好卖?市场才是关键点!

大家好&#xff0c;我是电商小布。 很多来加入抖音小店的新手朋友&#xff0c;都是看到了这个项目的发展情况&#xff0c;并认为未来的发展也是不错的。 但是很多朋友在入驻的时候&#xff0c;是并没有搞清楚自己要来玩什么&#xff0c;要卖什么的。 而这个是我们在开店之前…

c++的学习之路:3、入门(2)

一、引用 1、引用的概念 引用不是新定义一个变量&#xff0c;而是给已存在变量取了一个别名&#xff0c;编译器不会为引用变量开辟内存空 间&#xff0c;它和它引用的变量共用同一块内存空间。 怎么说呢&#xff0c;简单点理解就是你的小名&#xff0c;家里人叫你小名&#…

EI级!高创新原创未发表!VMD-TCN-BiGRU-MATT变分模态分解卷积神经网络双向门控循环单元融合多头注意力机制多变量时间序列预测(Matlab)

EI级&#xff01;高创新原创未发表&#xff01;VMD-TCN-BiGRU-MATT变分模态分解卷积神经网络双向门控循环单元融合多头注意力机制多变量时间序列预测&#xff08;Matlab&#xff09; 目录 EI级&#xff01;高创新原创未发表&#xff01;VMD-TCN-BiGRU-MATT变分模态分解卷积神经…