当前位置: 首页 > news >正文

俄罗斯方块——C语言实践(Dev-Cpp)

目录

1、创建项目(尽量不使用中文路径)

2、项目复制

3、项目配置

​1、调整编译器

2、在配置窗口选择参数标签

3、添加头文件路径和库文件路径

 4、代码实现

4.1、main.c

4.2、draw.h

4.3、draw.c

4.4、shape.h

4.5、shape.c

4.6、board.h

4.7、board.c

4.8、control.h

4.9、control.c


这个是在Dev-Cpp里实现的,在别的编译器,可能有些配置不一定能用

1、创建项目(尽量不使用中文路径)

第一次在Dev-Cpp里创建项目,真的难受,所以不得不讲一下

1、新建项目

 2、点击Console Application ,C项目,我的名称取为day7_first

3、右击,新建文件夹(在自己平时建项目的文件夹里),取名为day7_first(一般与项目名相同)

 再点击day7_first,打开

保存 

2、项目复制

项目复制,我认为有必要讲一下,

可以,保存前一次的代码,然后在前一次的代码上进行改写,方便代码的管理

就是把上一次的.c,.h文件(及项目里要用到的应用程序扩展等,如果有的话),复制一份到day7_first文件夹里,但要把原来的main.c删掉(关闭,不保存),防止覆盖之前的main.c,

然后添加这些文件

3、项目配置

用了SDL2里的两个文件,在我的资源有

1、调整编译器

以支持C99标准,方便使用更多语言特性

2、在配置窗口选择参数标签

在链接处,输入三行

这里要注意两点:

减号-后面是小写L,不是数字 1 ,也不是i。

这三个库的顺序不可变。 

之后再添加两个链接

-lmingw32
-lsdl2main
-lsdl2
-limm32
-sdl2_ttf

3、添加头文件路径和库文件路径

 一共添加这两个

同样的方法,在包含文件目录,添加这个两个

4、将两个应用程序扩展,复制到项目所在的文件夹

 4、代码实现

4.1、main.c

#include "draw.h"
#include "shape.h"
#include "board.h"
#include "control.h"///* run this program using the console pauser or add your own getch, system("pause") or input loop */
//
//int main(int argc, char *argv[]) {
//	return 0;
//}
int main(int argc, char* argv[]) {draw_init();//初始化shape_init();//图形初始化board_init();//板初始化 control_gameloop();//游戏循环draw_free();// 清理资源return 0;
}

4.2、draw.h

#ifndef DRAW_H
#define DRAW_H#include <stdio.h>
#include <stdlib.h>
#include <SDL.h>
#include <stdbool.h>
#include <SDL_ttf.h>#if 1 
//苹果系统 1改0 
#include <SDL_syswm.h>
#include <windows.h>
#include <imm.h>
#endif#define WINDOW_W 640
#define WINDOW_H 510#define INTERVAL 30//网格间隔
#define HEIGHT 16//网格高 
#define WIDTH 10//网格宽 typedef struct
{SDL_Window* window;SDL_Renderer* renderer;TTF_Font* font;SDL_Texture* background;
}Renderer;bool draw_init();
bool draw_free();void draw_rect(const SDL_Rect* rect,const SDL_Color* color);//绘制矩形
void draw_update();//界面更新
void draw_string(int x,int y,const char* str,SDL_Color* color);//在窗口打印字符串#endif

4.3、draw.c

#include "draw.h"
#include "shape.h"
#include "board.h"static Renderer R;//一个存储信息的中间变量, 如果放到main()中,每个函数都要传参#if 1
//苹果系统 1改0
void disableIME(SDL_Window *window) {//防止输入法自己改变SDL_SysWMinfo wmInfo;SDL_VERSION(&wmInfo.version);//初始化 wmInfo结构体的版本信息if (SDL_GetWindowWMInfo(window, &wmInfo)) {HWND hwnd = wmInfo.info.win.window;//禁用 IMEImmAssociateContext(hwnd, NULL);}
}
#endifbool draw_free() { // 清理资源if(R.font) {TTF_CloseFont(R.font);TTF_Quit();}SDL_DestroyRenderer(R.renderer);SDL_DestroyWindow(R.window);SDL_Quit();
}bool draw_init() {// 初始化 SDLif (SDL_Init(SDL_INIT_VIDEO) < 0) {SDL_Log("SDL could not initialize! SDL_Error: %s\n",SDL_GetError());return false;}
// 创建窗口R.window = SDL_CreateWindow("SDL2 Square",SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, WINDOW_W, WINDOW_H,SDL_WINDOW_SHOWN);if (!R.window) {SDL_Log("Window could not be created! SDL_Error: %s\n",SDL_GetError());SDL_Quit();return false;}
// 创建渲染器R.renderer = SDL_CreateRenderer(R.window, -1,SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); if (!R.renderer) {SDL_Log("Renderer could not be created! SDL_Error: %s\n",SDL_GetError());SDL_DestroyWindow(R.window);SDL_Quit();return false;}
#if 1disableIME(R.window); //苹果系统 1改0
#endifif(TTF_Init()<0) {printf("Failed to initialize SDL_ttf\n");draw_free();return false;}R.font = TTF_OpenFont("bahnschrift.ttf",24);//添加一种字体,必须是.ttf后缀if(!R.font) {printf("Failde to load font\n",TTF_GetError());TTF_Quit();draw_free();return false;}//Load the background BMP imageSDL_Surface* bgSurface = SDL_LoadBMP("background1.bmp");//添加背景,必须是.bmp后缀if(!bgSurface) {printf("Failed to load background image: %s\n",SDL_GetError());return false;}R.background = SDL_CreateTextureFromSurface(R.renderer,bgSurface);SDL_FreeSurface(bgSurface);//Free the surface after creating the textureif(!R.background) {printf("Failed to create background texture: %s\n",SDL_GetError());return false;}printf("draw init() success\n");return true;
}void draw_string(int x,int y,const char* str,SDL_Color* color) {SDL_Surface* surface = TTF_RenderText_Solid(R.font,str, *color);if(!surface) {printf("TTF_RenderText_Solid error: %s\n",TTF_GetError());return;}SDL_Texture* texture = SDL_CreateTextureFromSurface(R.renderer,surface);if(!texture) {printf("SDL_CreateTextureFromSurface error:%s\n",SDL_GetError());return;}SDL_Rect rect = {x,y,surface->w,surface->h};SDL_FreeSurface(surface);SDL_RenderCopy(R.renderer,texture,NULL,&rect);SDL_DestroyTexture(texture);}//const SDL_Rect rect = {100,100,30,30};// 矩形的位置  x  y  w宽度  h高度void draw_rect_grid() {//绘制网格SDL_SetRenderDrawColor(R.renderer, 255,255,255,255);//白色for(int i = 0; i<=HEIGHT; i++) {SDL_RenderDrawLine(R.renderer,0,INTERVAL*i,INTERVAL*WIDTH,INTERVAL*i);//(x1,y1,x2,y2)if(i == 0)SDL_RenderDrawLine(R.renderer,0,INTERVAL*i+1,INTERVAL*WIDTH,INTERVAL*i+1);if(i == HEIGHT)SDL_RenderDrawLine(R.renderer,0,INTERVAL*i-1,INTERVAL*WIDTH,INTERVAL*i-1);}for(int i = 0; i<=WIDTH; i++) {SDL_RenderDrawLine(R.renderer,INTERVAL*i,0,INTERVAL*i,INTERVAL*HEIGHT);if(i == 0)SDL_RenderDrawLine(R.renderer,INTERVAL*i+1,0,INTERVAL*i+1,INTERVAL*HEIGHT);if(i == WIDTH)SDL_RenderDrawLine(R.renderer,INTERVAL*i-1,0,INTERVAL*i-1,INTERVAL*HEIGHT);}
}void draw_rect_border(const SDL_Rect* rect) {//绘制矩形边框SDL_SetRenderDrawColor(R.renderer, 255,255,255,255);//白色SDL_RenderDrawRect(R.renderer, rect);
}void draw_rect(const SDL_Rect* rect,const SDL_Color* color) {//绘制矩形SDL_SetRenderDrawColor(R.renderer, color->r, color->g, color->b, color->a);SDL_RenderFillRect(R.renderer, rect);draw_rect_border(rect);
}void draw_update() {//颜色更新
// 用颜色 清空渲染器,覆盖SDL_SetRenderDrawColor(R.renderer, 0, 0, 255, 255);SDL_RenderClear(R.renderer); //背景填充 蓝色SDL_RenderCopy(R.renderer,R.background,NULL,NULL);//背景
//界面的更新数据draw_rect_grid();//绘制网格board_draw();//绘制底部的图形shape_draw();//绘制图形// 呈现渲染结果SDL_RenderPresent(R.renderer);
}

4.4、shape.h

#ifndef _SHAPE_H
#define _SHAPE_H
#include <SDL.h>
#include <stdio.h>
#include <stdbool.h>typedef enum{MOVE_DOWN,MOVE_LEFT,MOVE_RIGHT,MOVE_UP
}Movedir;typedef struct {bool matrix[4][4];int x;int y;int size;//打印,旋转矩阵的一种标记SDL_Color color;
}Shape;void shape_init();
void shape_draw();
void shape_move(Movedir dir);
void shape_rotate();//图形旋转 #endif

4.5、shape.c

#include "shape.h"
#include "draw.h"
#include <stdlib.h>
#include <time.h>
#include "board.h"
#include "control.h"//所有形状的定义
const Shape ALL_SHAPES[7] = {{{{0,1,0,0},{0,1,1,0},{0,0,1,0},{0,0,0,0}},3,0,3,{200,200,200,255}},{{{0,1,0,0},{0,1,1,0},{0,1,0,0},{0,0,0,0}},3,0,3,{180,180,100,255}},{{{0,0,1,0},{0,1,1,0},{0,1,0,0},{0,0,0,0}},3,0,3,{160,180,10,255}},{{{1,1,0,0},{1,1,0,0},{0,0,0,0},{0,0,0,0}},3,0,2,{80,160,100,255}},{{{0,1,0,0},{0,1,0,0},{0,1,1,0},{0,0,0,0}},3,0,3,{100,180,160,255}},{{{0,1,1,0},{0,1,0,0},{0,1,0,0},{0,0,0,0}},3,0,3,{10,160,60,255}},{{{0,0,1,0},{0,0,1,0},{0,0,1,0},{0,0,1,0}},3,0,4,{180,10,160,255}}
};Shape cur_shape;
Shape next_shape;
Shape rotate_shape;
int delay_cnt;void shape_init() {//更新图形后,有回到之前的位置srand((unsigned int)time(NULL));cur_shape = ALL_SHAPES[rand()%7];next_shape = ALL_SHAPES[rand()%7];
}void matrix_rotate(int m) {rotate_shape = cur_shape;for(int i = 0; i<m; i++) {for(int j = 0; j<m; j++) {rotate_shape.matrix[j][m-i-1] = cur_shape.matrix[i][j];}}if(board_check_collision(rotate_shape.x,rotate_shape.y,&rotate_shape))//旋转后越界,就不变return;cur_shape = rotate_shape;
}void shape_rotate() {if(cur_shape.size != 2) {matrix_rotate(cur_shape.size);return;} elsereturn;
}void shape_move(Movedir dir) {switch(dir) {case MOVE_DOWN:if(!board_check_collision(cur_shape.x,cur_shape.y+1,&cur_shape))cur_shape.y++;else {board_place_shape(&(cur_shape));//记录底部的图形board_clear_fulllines();//清空满行cur_shape = next_shape;srand((unsigned int)time(NULL));next_shape = ALL_SHAPES[rand()%7];if(board_check_collision(cur_shape.x,cur_shape.y,&cur_shape)) {control_setstate(STATE_GAME_OVER);updatemaxscore();updatemaxlevel();printf("Game Over!\n");}}break;case MOVE_LEFT:if(!board_check_collision(cur_shape.x-1,cur_shape.y,&cur_shape)) {cur_shape.x--;}break;case MOVE_RIGHT:if(!board_check_collision(cur_shape.x+1,cur_shape.y,&cur_shape)) {cur_shape.x++;}break;case MOVE_UP:shape_rotate();break;}}static void shape_draw_matrix(int x,int y,Shape* shape) {SDL_Rect r = {0,0,30,30};for(int i=0; i<shape->size; i++) {for(int j=0; j<shape->size; j++) {if(shape->matrix[i][j]) {r.x = (x+j+shape->x)*30;r.y = (y+i+shape->y)*30;//显示全draw_rect(&r,&(shape->color));}}}
}void shape_draw() {shape_draw_matrix(0,0,&cur_shape);shape_draw_matrix(10,2,&next_shape);//界面预览if(control_getstate() == STATE_RUNNING) {if(delay_cnt++>30-board_getlevel()*3) {delay_cnt = 0;shape_move(MOVE_DOWN);}}
}

4.6、board.h

#ifndef __BOARD_H_
#define __BOARD_H_#include <SDL.h>
#include <stdbool.h> 
#include "shape.h"#define BOARD_H 16
#define BOARD_W 10
#define BLOCKSIZE 30//level++,所需要消的行数 
#define INCREASE_LEVEL_LINES 2typedef struct
{SDL_Color color;bool active;
}Block;typedef struct
{Block matrix[BOARD_H][BOARD_W];int score;int level;int clearlines; int maxscore;int maxlevel;
}Gameboard;void board_init();
void board_draw();//绘制底部的图形
bool board_check_collision(int newx,int newy,Shape* shape);//检查碰撞
void board_place_shape(Shape* cur_shape);//记录底部的图形
void board_clear_fulllines();
int board_getlevel();
void updatemaxscore();
void updatemaxlevel();#endif

4.7、board.c

#include "board.h"
#include "draw.h"static Gameboard gb;int board_getlevel() {return gb.level;
}void getmaxscore() {FILE* fp = fopen("俄罗斯方块最高分.txt","r");if(fp == NULL) {fp = fopen("俄罗斯方块最高分.txt","w");if(fp == NULL) {perror("getmaxscore()::fopen(w)");return;}gb.maxscore = gb.score;fprintf(fp,"%d",gb.maxscore);//初始化max为0fclose(fp);return;}fscanf(fp,"%d",&(gb.maxscore));fclose(fp);
}void updatemaxscore() {FILE* fp = fopen("俄罗斯方块最高分.txt","w");if(fp == NULL) {perror("updatemaxscore()::fopen(w)");return;}if(gb.score>gb.maxscore)gb.maxscore = gb.score;fprintf(fp,"%d",gb.maxscore);fclose(fp);
}void getmaxlevel() {FILE* fp = fopen("俄罗斯方块最高难度.txt","r");if(fp == NULL) {fp = fopen("俄罗斯方块最高难度.txt","w");if(fp == NULL) {perror("getmaxlevel()::fopen(w)");return;}gb.maxlevel = gb.level;fprintf(fp,"%d",gb.maxlevel);//初始化level为1fclose(fp);return;}fscanf(fp,"%d",&(gb.maxlevel));fclose(fp);
}void updatemaxlevel() {FILE* fp = fopen("俄罗斯方块最高难度.txt","w");if(fp == NULL) {perror("updatemaxlevel()::fopen(w)");return;}if(gb.level>gb.maxlevel)gb.maxlevel = gb.level;fprintf(fp,"%d",gb.maxlevel);fclose(fp);
}void board_init() {//板初始化gb.level = 1;gb.clearlines = 0;gb.score = 0;getmaxscore();getmaxlevel();for(int i = 0; i<BOARD_H; i++) {for(int j = 0; j<BOARD_W; j++) {gb.matrix[i][j] = (Block) {{160,160,160,255},false};}}
}void board_draw() {SDL_Rect rect = {0,0,BLOCKSIZE,BLOCKSIZE};for(int i = 0; i<BOARD_H; i++) {for(int j = 0; j<BOARD_W; j++) {if(gb.matrix[i][j].active) {draw_rect(&rect,&(gb.matrix[i][j].color));}rect.x += rect.w;}rect.x = 0;rect.y += rect.h;}char tempstring[32];SDL_Color color = {200,0,0,255};snprintf(tempstring,sizeof(tempstring),"Score: %d",gb.score);draw_string((BOARD_W+4)*BLOCKSIZE,7*BLOCKSIZE,tempstring,&color);color = (SDL_Color) {0,200,0,255};snprintf(tempstring,sizeof(tempstring),"Level: %d",gb.level);draw_string((BOARD_W+4)*BLOCKSIZE,8*BLOCKSIZE,tempstring,&color);color = (SDL_Color) {100,100,200,255};snprintf(tempstring,sizeof(tempstring),"Pause game press p");draw_string((BOARD_W+2)*BLOCKSIZE,10*BLOCKSIZE,tempstring,&color);color = (SDL_Color) {100,100,200,255};snprintf(tempstring,sizeof(tempstring),"Restart game press r");draw_string((BOARD_W+2)*BLOCKSIZE,11*BLOCKSIZE,tempstring,&color);color = (SDL_Color) {200,200,200,255};snprintf(tempstring,sizeof(tempstring),"maxscore:>%d",gb.maxscore);draw_string(0,16*BLOCKSIZE,tempstring,&color);color = (SDL_Color) {200,200,200,255};snprintf(tempstring,sizeof(tempstring),"maxlevel:>%d",gb.maxlevel);draw_string((BOARD_W)*BLOCKSIZE,16*BLOCKSIZE,tempstring,&color);
}bool board_check_collision(int newx,int newy,Shape* shape) { for(int i = 0; i<shape->size; i++) {for(int j = 0; j<shape->size; j++) {if(shape->matrix[i][j]) {int x = newx + j;int y = newy + i;if(x<0||x>=BOARD_W||y>=BOARD_H)//碰边return true;if(y>0&&gb.matrix[y][x].active) //碰到已有图形return true;}}}return false;
}void board_place_shape(Shape* cur_shape) {for(int i = 0; i < cur_shape->size; i++) {for(int j = 0; j < cur_shape->size; j++) {if(cur_shape->matrix[i][j]) {gb.matrix[cur_shape->y+i][cur_shape->x+j].active = true;gb.matrix[cur_shape->y+i][cur_shape->x+j].color = cur_shape->color;}}}
}void board_clear_fulllines() {int lines = 0;for(int y = 0; y < BOARD_H; y++) {bool isfull = true;for(int i = 0; i < BOARD_W; i++) {if(!gb.matrix[y][i].active) {isfull = false;break;}}if(isfull) { //满行lines++;for(int i = y; i > 0; i--) {//满行以上的所有的图形向下移动一行 for(int j = 0; j < BOARD_W; j++) {gb.matrix[i][j] = gb.matrix[i-1][j];}}for(int j = 0; j < BOARD_W; j++) {//清空最顶行 gb.matrix[0][j].active = false;}}}switch(lines) {case 1:gb.score += 1;break;case 2:gb.score += 4;break;case 3:gb.score += 9;break;case 4:gb.score += 16;break;}gb.clearlines += lines;while(gb.clearlines>=INCREASE_LEVEL_LINES) {gb.clearlines -= INCREASE_LEVEL_LINES;gb.level++;}printf("Score: %d\nLevel: %d\nClear: %d\n",gb.score,gb.level,gb.clearlines+INCREASE_LEVEL_LINES*(gb.level-1));
}

4.8、control.h

#pragma once #ifndef __CONTROL_H_
#define __CONTROL_H_typedef enum
{STATE_UNKOWN,STATE_RUNNING,STATE_PAUSE,STATE_STOP,STATE_GAME_OVER,STATE_MANUAL
}GameState;void control_gameloop();
GameState control_getstate();
void control_setstate(GameState st);#endif

4.9、control.c

#include "control.h"
#include "shape.h"
#include "draw.h"
#include "board.h"static GameState state;GameState control_getstate() {return state;
}void control_setstate(GameState st) {state = st;
}void control_gameloop() {// 主循环标志bool running = true;SDL_Event event;state = STATE_RUNNING;while (running) {
// 处理事件while (SDL_PollEvent(&event)) {if (event.type == SDL_QUIT) {running = false;}if(event.type == SDL_KEYDOWN) {switch(event.key.keysym.sym) {case SDLK_ESCAPE:case SDLK_q:running = false;break;case SDLK_p://暂停if(state == STATE_RUNNING) {state = STATE_PAUSE;break;}if(state == STATE_PAUSE) {state = STATE_RUNNING;break;}case SDLK_m://自动与手动if(state == STATE_RUNNING) {state = STATE_MANUAL;break;}if(state == STATE_MANUAL) {state = STATE_RUNNING;break;}case SDLK_r:control_setstate(STATE_RUNNING);board_init();//板初始化 shape_init();//图形初始化,图形回到初始位置 break;case SDLK_UP:if(state == STATE_RUNNING||state == STATE_MANUAL)shape_move(MOVE_UP);break;case SDLK_DOWN:if(state == STATE_RUNNING||state == STATE_MANUAL)shape_move(MOVE_DOWN);break;case SDLK_LEFT:if(state == STATE_RUNNING||state == STATE_MANUAL)shape_move(MOVE_LEFT);break;case SDLK_RIGHT:if(state == STATE_RUNNING||state == STATE_MANUAL)shape_move(MOVE_RIGHT);break;}}}draw_update();//颜色更新,覆盖,更新图形颜色SDL_Delay(16);//60Hz}
}

相关文章:

俄罗斯方块——C语言实践(Dev-Cpp)

目录 1、创建项目(尽量不使用中文路径) 2、项目复制 3、项目配置 ​1、调整编译器 2、在配置窗口选择参数标签 3、添加头文件路径和库文件路径 4、代码实现 4.1、main.c 4.2、draw.h 4.3、draw.c 4.4、shape.h 4.5、shape.c 4.6、board.h 4.7、board.c 4.8、cont…...

关于wp网站出现的问题

问题1 问题1&#xff1a;如果出现这个界面的问题 说明是根目录的index.php编码出了问题&#xff0c;用备份的源文件退换一下即可。 问题2 问题2&#xff1a;如果出现页面错位现象&#xff0c;可能是某个WP插件引起的问题&#xff0c;这里需要逐步排查插件&#xff0c;或者你刚…...

为什么H.266未能普及?EasyCVR视频编码技术如何填补市场空白

H.266&#xff0c;也被称为Versatile Video Coding&#xff08;VVC&#xff09;&#xff0c;是近年来由MPEG&#xff08;Moving Picture Experts Group&#xff09;和ITU&#xff08;International Telecommunication Union&#xff09;联合开发并发布的新一代国际视频编码标准…...

最全 高质量 大模型 -评估基准数据集(不定期更新)

评估基准是推动人工智能领域技术进步和应用落地的关键工具&#xff0c;通过这些基准&#xff0c;我们可以更全面地理解LLMs的能力&#xff0c;并指导未来的研究和实践。 评估基准&#xff0c;是一套衡量标准&#xff0c;就像老师用考试来检查学生学得怎么样。在大模型的世界里…...

react 中, navigate 跳转链接 2种写法

react 中&#xff0c; navigate 下面2种写法&#xff0c; 有什么区别, import { useNavigate } from "react-router-dom"; const navigate useNavigate(""); onClick{() > navigate("/signup")}import { Navigate } from "react-route…...

k8s Service 服务

文章目录 一、为什么需要 Service二、Kubernetes 中的服务发现与负载均衡 -- Service三、用例解读1、Service 语法2、创建和查看 Service 四、Headless Service五、集群内访问 Service六、向集群外暴露 Service七、操作示例1、获取集群状态信息2、创建 Service、Deployment3、创…...

安全建设当中的冷门知识

今天说点有趣的话题&#xff0c;也是因为在安全建设过程中&#xff0c;安全员也不太可能都按照最理想的状态去工作&#xff0c;有资源的问题&#xff0c;有管理惰性问题&#xff0c;当然也有管理者本身决策的问题。 安全行业起步较晚&#xff0c;16年才施行网络安全法&#xff…...

python画图|极坐标下的3D surface

前述学习过程中&#xff0c;我们已经掌握了3D surface的基本绘制技巧&#xff0c;详见链接&#xff1a; python画图|3D surface基础教程-CSDN博客 基础教程中的3D surface绘制位于笛卡尔坐标系&#xff0c;但有时候会用到极坐标绘图。虽然我们已经学过简单的极坐标绘图技巧&a…...

html+css+js网页设计 旅游 大理旅游7个页面

htmlcssjs网页设计 旅游 大理旅游7个页面 网页作品代码简单&#xff0c;可使用任意HTML辑软件&#xff08;如&#xff1a;Dreamweaver、HBuilder、Vscode 、Sublime 、Webstorm、Text 、Notepad 等任意html编辑软件进行运行及修改编辑等操作&#xff09;。 获取源码 1&#…...

Day 29~42 JavaWeb

Java Web 1、基本概念 1.1、前言 web开发&#xff1a; web&#xff0c;网页的意思&#xff0c;www.baidu.com静态web html&#xff0c;css 提供给所有人看的数据始终不会发生变化动态web 淘宝&#xff0c;几乎是所有的网站 提供给所有人看的数据始终会发生变…...

小程序开发设计-第一个小程序:创建小程序项目④

上一篇文章导航&#xff1a; 小程序开发设计-第一个小程序&#xff1a;安装开发者工具③-CSDN博客https://blog.csdn.net/qq_60872637/article/details/142219152?spm1001.2014.3001.5501 须知&#xff1a;注&#xff1a;不同版本选项有所不同&#xff0c;并无大碍。 一、创…...

C++设计模式——Mediator中介者模式

一&#xff0c;中介者模式的定义 中介者模式是一种行为型设计模式。它通过一个中介者对象将多个对象之间的交互关系进行封装&#xff0c;使得对象之间的交互需要通过中介者对象来完成。该设计模式的结构很容易理解&#xff0c;以中介者为中心。 中介者模式的设计思想侧重于在…...

微服务之间远程调用实现思路

项目使用的Spring Cloud Alibaba框架&#xff0c;微服务之间远程调用使用OpenFeign&#xff0c;具体实现步骤如下&#xff1a; &#xff08;1&#xff09;在api工程定义OpenFeign接口&#xff0c;使用FeignClient注解进行定义。 &#xff08;2&#xff09;服务提供方定义Open…...

获取STM32 MCU的唯一ID

STM32每个系列都会有唯一的一个芯片序列号&#xff08;96位bit&#xff09; STM32F10X 的起始地址是 0x1FFFF7E8 STM32F20X 的起始地址是 0x1FFF7A10 STM32F30X 的起始地址是 0x1FFFF7AC STM32F40X 的起始地址是 0x1FFF7A10 STM32L0XX 的起始地址是 0x1FF80050 STM32L1XX 的起…...

Debian项目实战——环境搭建篇

Debian系统安装 准备工作 1、系统镜像&#xff1a;根据自己的需要选择合适的版本格式&#xff1a;x86 / arm 架构 | 最好下载离线安装版本 | 清华镜像源 2、制作工具&#xff1a;balenaEtcher 3、系统媒介&#xff1a;16G以上U盘最佳 烧录镜像 打开balenaEtcher进行烧录&am…...

CenterNet官方代码—目标检测模型推理部分解析与项目启动

CenterNet模型推理部分解析 CenterNet官方代码环境部署 CenterNet作为2019年CVPR推出的论文&#xff0c;论文中给出了官方代码所在的github仓库地址。https://github.com/xingyizhou/CenterNet。 整个代码的代码量并不是特别大&#xff0c;但整个项目的难点在于使用了老版本的…...

测试开发基础——测试用例的设计

三、测试用例的设计 1. 什么是测试用例 测试用例(Test Case)是为了实施测试而向被测试的系统提供的一组集合&#xff0c;这组集合包含&#xff1a;测试环境、操作步骤、测试数据、预期结果等要素。 设计测试用例原则一&#xff1a;测试用例中一个必需部分是对预期输出或结果进…...

C++第五十一弹---IO流实战:高效文件读写与格式化输出

✨个人主页&#xff1a; 熬夜学编程的小林 &#x1f497;系列专栏&#xff1a; 【C语言详解】 【数据结构详解】【C详解】 目录 1. C语言的输入与输出 2. 流是什么 3. CIO流 3.1 C标准IO流 3.2 C文件IO流 3.2.1 以写方式打开文件 3.2.1 以读方式打开文件 4 stringstre…...

C++中使用分治法求最大值

在C++中使用分治法(Divide and Conquer)来求一个数组中的最大值是一个经典的问题。分治法是一种通过将原问题分解为若干个小规模相似子问题,递归地求解这些子问题,然后将子问题的解合并成原问题的解的方法。 以下是使用分治法求数组中最大值的步骤: 分解(Divide):将数…...

数据集 CULane 车道线检测 >> DataBall

数据集 CULane 车道线检测 自动驾驶 无人驾驶目标检测 CULane是用于行车道检测学术研究的大规模具有挑战性的数据集。它由安装在六辆由北京不同驾驶员驾驶的不同车辆上的摄像机收集。收集了超过55小时的视频&#xff0c;并提取了133,235帧。数据示例如上所示。我们将数据集分为…...

二、【ESP32开发全栈指南:ESP32 GPIO深度使用】

GPIO&#xff08;通用输入输出&#xff09; 是ESP32最基础却最核心的功能。本文将带你深入ESP32的GPIO操作&#xff0c;通过按键读取和LED控制实现物理按键→ESP32→LED的完整信号链路。 一、ESP32 GPIO核心特性速览 34个可编程GPIO&#xff08;部分引脚受限&#xff09;输入模…...

STM32标准库-TIM输出比较

文章目录 一、输出比较二、PWM2.1简介2.2输出比较通道&#xff08;高级&#xff09;2.3 输出比较通道&#xff08;通用&#xff09;2.4输出比较模式2.5 PWM基本结构1、时基单元2、输出比较单元3、输出控制&#xff08;绿色右侧&#xff09;4、右上波形图&#xff08;以绿色脉冲…...

5.Nginx+Tomcat负载均衡群集

Tomcat服务器应用场景&#xff1a;tomcat服务器是一个免费的开放源代码的Web应用服务器&#xff0c;属于轻量级应用服务器&#xff0c;在中小型系统和并发访问用户不是很多的场合下被普遍使用&#xff0c;是开发和调试JSP程序的首选。一般来说&#xff0c;Tomcat虽然和Apache或…...

11.MySQL事务管理详解

MySQL事务管理详解 文章目录 MySQL事务管理 事务的概念 事务的版本支持 事务的提交方式 事务的相关演示 事务的隔离级别 查看与设置隔离级别 读未提交&#xff08;Read Uncommitted&#xff09; 读提交&#xff08;Read Committed&#xff09; 可重复读&#xff08;Repeatabl…...

App/uni-app 离线本地存储方案有哪些?最推荐的是哪种方案?

以下是 UniApp 离线本地存储方案的详细介绍及推荐方案分析&#xff1a; 一、UniApp 离线本地存储方案分类 1. 基于 uni.storage 系列 API&#xff08;跨端基础方案&#xff09; API 及特点&#xff1a; 提供 uni.setStorage&#xff08;异步存储&#xff09;、uni.getStorag…...

Electron Fiddle使用笔记

文章目录 下载界面示意图保存和打开项目save 和 save as forge project 其他文档打包报错 RequestError: read ECONNRESET 想要打包前端程序&#xff0c;奈何本地环境总是报错&#xff0c;意外发现可以通过electron fiddle直接调试代码。 下载 百度网盘地址&#xff1a; 首次…...

LINUX 66 FTP 2 ;FTP被动模式;FTP客户服务系统

19&#xff0e; 在vim中将所有 abc 替换为 def&#xff0c;在底行模式下执行©&#xff1f;D A、s/abc/def B、s/abc/def/g C、%s/abc/def D、%s/abc/def/g FTP连接 用户名应该填什么 [rootcode ~]# grep -v ^# /etc/vsftpd/vsftpd.conf anonymous_enableNO local_enab…...

智慧货运飞船多维度可视化管控系统

图扑搭建智慧货运飞船可视化系统&#xff0c;借数字孪生技术&#xff0c;高精度复刻货运飞船外观、结构与运行场景。整合多维度数据&#xff0c;实时呈现飞行状态、设备参数等信息&#xff0c;助力直观洞察货运飞船运行逻辑&#xff0c;为航天运维、任务推演及决策提供数字化支…...

Spring框架学习day7--SpringWeb学习(概念与搭建配置)

SpringWeb1.SpringWeb特点2.SpringWeb运行流程3.SpringWeb组件4.搭建项目结构图&#xff1a;4.1导入jar包4.2在Web.xml配置**4.2.1配置统一拦截分发器 DispatcherServlet**4.2.2开启SpringWeb注解&#xff08;spring.xml&#xff09; 5.处理类的搭建6.SpringWeb请求流程(自己理…...

AI大模型学习三十二、飞桨AI studio 部署 免费Qwen3-235B与Qwen3-32B,并导入dify应用

一、说明 ‌Qwen3-235B 和 Qwen3-32B 的主要区别在于它们的参数规模和应用场景。‌ 参数规模 ‌Qwen3-235B‌&#xff1a;总参数量为2350亿&#xff0c;激活参数量为220亿‌。‌Qwen3-32B‌&#xff1a;总参数量为320亿‌。 应用场景 ‌Qwen3-235B‌&#xff1a;作为旗舰模型&a…...