找到
3
篇与
Kahaer
相关的结果
-
简单的前端网页搭建教程 1.需要准备一台服务器 可以自行购买 2.打开 服务器 创建一个站点 域名 可以用服务器IP地址 比如:154.12.88.213 3.创建完成之后 先访问 站点 看看能不能 正常 访问 恭喜, 站点创建成功! 出现这个字 说明 站点 创建 成功了 4.随便找一个 网站 做测试 比如:https://news.sina.com.cn/ 新闻中心首页 5.需要 获取 新闻中心首页 源码 鼠标右键 点击查看页面源代码 就行 6.复制 源代码 打开 服务器 进入 站点目录 然后 打开 index.html 这个 文件 里面的代码 删除 7.把我们 复制的源代码 粘贴进去 然后 保存 退出 8.打开 我们 创建的网页 刷新 9.我们 创建的网页 跟 https://news.sina.com.cn/ 新闻中心首页 这个网页 一样 那说明 我们创建网站 成功了! 10.这个是 最基础的网站 搭建的 方法 ! 本次教程结束 下去 可以自己 多练练 其他网页 也可以 同样的 操作 搭建!!!
-
简单的射击游戏 #include <stdio.h> #include <stdlib.h> #include <conio.h> #include <windows.h> #include <time.h> // 游戏区域尺寸 #define WIDTH 50 #define HEIGHT 20 #define ENEMY_COUNT 5 #define MAX_BULLETS 10 // 颜色定义 #define BLACK 0 #define BLUE 1 #define GREEN 2 #define CYAN 3 #define RED 4 #define MAGENTA 5 #define BROWN 6 #define LIGHTGRAY 7 #define DARKGRAY 8 #define LIGHTBLUE 9 #define LIGHTGREEN 10 #define LIGHTCYAN 11 #define LIGHTRED 12 #define LIGHTMAGENTA 13 #define YELLOW 14 #define WHITE 15 // 游戏元素结构定义 typedef struct { int x, y; // 位置 char shape; // 显示字符 int color; // 颜色 int active; // 是否活跃 } Player; typedef struct { int x, y; // 位置 int dx, dy; // 移动方向 char shape; // 显示字符 int color; // 颜色 int active; // 是否活跃 } Enemy; typedef struct { int x, y; // 位置 int dy; // 移动方向 char shape; // 显示字符 int color; // 颜色 int active; // 是否活跃 } Bullet; // 全局变量 Player player; Enemy enemies[ENEMY_COUNT]; Bullet bullets[MAX_BULLETS]; int score = 0; int lives = 3; int gameOver = 0; // 设置控制台文本颜色 void setColor(int color) { HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleTextAttribute(hConsole, color); } // 设置光标位置 void setCursorPosition(int x, int y) { COORD coord; coord.X = x; coord.Y = y; SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord); } // 隐藏光标 void hideCursor() { HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); CONSOLE_CURSOR_INFO cursorInfo = { 1, 0 }; SetConsoleCursorInfo(hConsole, &cursorInfo); } // 初始化游戏 void initGame() { // 初始化玩家 player.x = WIDTH / 2; player.y = HEIGHT - 2; player.shape = '^'; player.color = GREEN; player.active = 1; // 初始化敌人 srand(time(NULL)); for (int i = 0; i < ENEMY_COUNT; i++) { enemies[i].x = rand() % (WIDTH - 2) + 1; enemies[i].y = rand() % 5 + 1; enemies[i].dx = (rand() % 2 == 0) ? 1 : -1; enemies[i].dy = 0; enemies[i].shape = 'V'; enemies[i].color = RED; enemies[i].active = 1; } // 初始化子弹 for (int i = 0; i < MAX_BULLETS; i++) { bullets[i].x = 0; bullets[i].y = 0; bullets[i].dy = -1; // 向上移动 bullets[i].shape = '|'; bullets[i].color = YELLOW; bullets[i].active = 0; } score = 0; lives = 3; gameOver = 0; hideCursor(); } // 发射子弹 void shoot() { // 找到第一个不活跃的子弹 for (int i = 0; i < MAX_BULLETS; i++) { if (!bullets[i].active) { bullets[i].x = player.x; bullets[i].y = player.y - 1; bullets[i].active = 1; break; } } } // 绘制游戏元素 void drawGame() { // 清屏 system("cls"); // 绘制边界 setColor(WHITE); for (int i = 0; i <= WIDTH; i++) { setCursorPosition(i, 0); printf("-"); setCursorPosition(i, HEIGHT); printf("-"); } for (int i = 0; i <= HEIGHT; i++) { setCursorPosition(0, i); printf("|"); setCursorPosition(WIDTH, i); printf("|"); } // 绘制玩家 if (player.active) { setColor(player.color); setCursorPosition(player.x, player.y); printf("%c", player.shape); } // 绘制敌人 for (int i = 0; i < ENEMY_COUNT; i++) { if (enemies[i].active) { setColor(enemies[i].color); setCursorPosition(enemies[i].x, enemies[i].y); printf("%c", enemies[i].shape); } } // 绘制子弹 for (int i = 0; i < MAX_BULLETS; i++) { if (bullets[i].active) { setColor(bullets[i].color); setCursorPosition(bullets[i].x, bullets[i].y); printf("%c", bullets[i].shape); } } // 显示分数和生命 setColor(YELLOW); setCursorPosition(2, HEIGHT + 1); printf("分数: %d | 生命: %d", score, lives); // 重置颜色 setColor(WHITE); } // 更新游戏状态 void updateGame() { // 移动子弹 for (int i = 0; i < MAX_BULLETS; i++) { if (bullets[i].active) { bullets[i].y += bullets[i].dy; // 子弹超出屏幕范围 if (bullets[i].y <= 1) { bullets[i].active = 0; } } } // 移动敌人 for (int i = 0; i < ENEMY_COUNT; i++) { if (enemies[i].active) { enemies[i].x += enemies[i].dx; // 敌人碰到边界改变方向 if (enemies[i].x <= 1 || enemies[i].x >= WIDTH - 1) { enemies[i].dx = -enemies[i].dx; enemies[i].y++; // 向下移动一步 } // 敌人到达底部 if (enemies[i].y >= HEIGHT - 1) { enemies[i].active = 0; lives--; // 检查游戏是否结束 if (lives <= 0) { gameOver = 1; } } } } // 检测子弹击中敌人 for (int i = 0; i < MAX_BULLETS; i++) { if (bullets[i].active) { for (int j = 0; j < ENEMY_COUNT; j++) { if (enemies[j].active && bullets[i].x == enemies[j].x && bullets[i].y == enemies[j].y) { // 击中敌人 bullets[i].active = 0; enemies[j].active = 0; score += 10; // 生成新敌人 enemies[j].x = rand() % (WIDTH - 2) + 1; enemies[j].y = 1; enemies[j].dx = (rand() % 2 == 0) ? 1 : -1; enemies[j].active = 1; } } } } // 检测敌人是否与玩家碰撞 for (int i = 0; i < ENEMY_COUNT; i++) { if (enemies[i].active && enemies[i].x == player.x && enemies[i].y == player.y) { enemies[i].active = 0; lives--; // 生成新敌人 enemies[i].x = rand() % (WIDTH - 2) + 1; enemies[i].y = 1; enemies[i].dx = (rand() % 2 == 0) ? 1 : -1; enemies[i].active = 1; // 检查游戏是否结束 if (lives <= 0) { gameOver = 1; } } } } // 处理用户输入 void handleInput() { if (_kbhit()) { char key = _getch(); switch (key) { case 'a': case 'A': if (player.x > 1) { player.x--; } break; case 'd': case 'D': if (player.x < WIDTH - 1) { player.x++; } break; case ' ': // 空格键射击 shoot(); break; case 'q': case 'Q': gameOver = 1; break; } } } // 显示游戏结束画面 void showGameOver() { setCursorPosition(WIDTH / 2 - 6, HEIGHT / 2); setColor(RED); printf("游戏结束!"); setCursorPosition(WIDTH / 2 - 10, HEIGHT / 2 + 2); printf("最终分数: %d", score); setCursorPosition(WIDTH / 2 - 15, HEIGHT / 2 + 4); setColor(YELLOW); printf("按任意键退出..."); setColor(WHITE); _getch(); } // 显示游戏说明 void showInstructions() { system("cls"); setColor(CYAN); printf("\n\n"); printf(" 射击游戏说明 \n"); printf("---------------------------\n"); printf("使用 A 和 D 键左右移动\n"); printf("按空格键发射子弹\n"); printf("击中敌人获得分数\n"); printf("敌人到达底部或碰到你会减少生命\n"); printf("生命耗尽游戏结束\n"); printf("按 Q 键退出游戏\n"); printf("\n"); printf(" 按任意键开始 \n"); setColor(WHITE); _getch(); } // 主函数 int main() { showInstructions(); initGame(); while (!gameOver) { drawGame(); handleInput(); updateGame(); Sleep(80); // 控制游戏速度 } showGameOver(); return 0; }
-
欢迎使用喀哈尔科技博客 喀哈尔科技博客网站定位与核心价值 喀哈尔科技博客聚焦编程语言学习与软件开发领域,是面向编程学习者(从入门新手到进阶开发者)的垂直类学习平台,核心价值在于“以实用为导向,连接技术理论与开发实践”。 一、核心内容板块 编程语言学习:覆盖主流语言(Python/Java/JavaScript等)及特色方向(如国产仓颉语言、嵌入式开发语言),内容从基础语法精讲(如“Python列表推导式实战案例”)到进阶特性解析(如“Java并发编程中的线程安全问题”),配套代码示例与在线调试指引。 软件开发实战:按开发领域分类(Web开发、移动端开发、后端服务、AI应用开发等),提供“需求分析→技术选型→编码实现→部署优化”全流程教程,例如“基于OpenHarmony开发简易天气APP”“用Spring Boot搭建RESTful API服务”。 技术干货与避坑指南:分享开发者真实踩坑经验(如“数据库索引失效的8种常见场景”)、行业前沿技术解读(如“低代码平台开发趋势与实践”),以及工具使用技巧(如“Git进阶操作:分支管理与冲突解决”)。 二、目标用户与平台优势 目标用户:编程入门者(零基础想系统学开发)、在校计算机相关专业学生(需补充实践经验)、职场初级开发者(想提升技术栈或转型新领域)。 平台优势:内容贴近实际开发需求,避免纯理论堆砌;部分教程配套“阶段性项目作业”,支持用户上传成果交流;设有开发者社区板块,可提问答疑、分享学习笔记,形成“学-练-问”闭环。