C#控制方块的移动windows
//使用键盘控制方块的左右上下移动
using System;
namespace 方块移动
{
struct Vector2
{
public int x, y;
public Vector2(int x, int y)
{
this.x = x;
this.y = y;
}
}
class GameObject
{
private Vector2 position;
private Vector2 size;
private ConsoleColor color;
public GameObject(Vector2 position, Vector2 size, ConsoleColor color){this.position = position;this.size = size;this.color = color;}public GameObject(int pos_x, int pos_y, int size_x, int size_y, ConsoleColor color): this(new Vector2(pos_x, pos_y), new Vector2(size_x, size_y), color){}/// <summary>/// 绘制一个图形/// </summary>public void Draw(){Console.ForegroundColor = color;for (int i = 0; i < size.x; i++){for (int j = 0; j < size.y; j++){Console.SetCursorPosition((position.x + i) * 2, position.y + j);Console.Write("■");}}}/// <summary>/// 定点擦除图形/// </summary>public void Remove(){// Console.Clear(); for (int i = 0; i < size.x; i++){for (int j = 0; j < size.y; j++){Console.SetCursorPosition((position.x + i) * 2, position.y + j);Console.Write(" ");}}}public void Move(char dir){Remove();switch (dir){case 'w':position.y -= 1;break;case 's':position.y += 1;break;case 'a':position.x -= 1;break;case 'd':position.x += 1;break;}Draw();}}
class Program
{static void Main(string[] args){GameObject go = new GameObject(20, 10, 5, 5, ConsoleColor.Red);go.Draw();while (true){char c = Console.ReadKey().KeyChar;//Console.WriteLine(c);go.Move(c);}}
}
}
C#控制方块的移动windows相关推荐
- U盘加载硬盘控制卡驱动安装Windows 2003 指南
U盘加载硬盘控制卡驱动安装Windows 2003 指南 http://www.dell.com/Support/Article/cn/zh/cnbsd1/SLN263067 posted on 20 ...
- 回归前端学习第23天-实现俄罗斯方块小游戏6(实现单机版2——键盘控制方块移动)
界面出现对应方块后,可自行控制其左右或快速下降的移动,上键可以实现方块形状的改变 调整代码结构 实现键盘控制方块移动 game.js中代码 注意这里在SquareFactory中又写了个make函数, ...
- python通过键盘方向键移动_移动python教程!python中怎么用键盘方向键控制方块的移动...
python中怎么用键盘方向键控制方块的移动 感象是在用TKinter绘图.在tkinter里有一键射表.左键也在其中. KeyPress-xx 这个xx是键盘的号码.不在button.tcl里.需己 ...
- JS实战之使用键盘方向键控制方块的上下左右移动
使用键盘方向键控制方块的上下左右运动 <!DOCTYPE html> <html> <head><meta charset="UTF-8" ...
- 计算机的用户控制,我的电脑我做主——Windows账户家长控制-用户账户控制设置...
用Ghost安装的系统,通常默认只有一个超级管理员(Administrator)用户,拥有任意更改系统密码.设置,安装卸载软件等权限,但是出于安全或其它因素考虑,有些场景我们并不希望用户拥有太多权限, ...
- 远程管理计算机用户账户限制,用户帐户控制和远程限制 - Windows Server | Microsoft Docs...
Vista 中的用户帐户控制和远程Windows说明 09/08/2020 本文内容 本文介绍了用户帐户控制 (UAC) 和远程限制. 适用于: WindowsVista 原始 KB 编号: 9 ...
- windows家长时长控制_如何在Windows 7中使用家长控制
windows家长时长控制 The Parental Controls feature is a valuable tool for controlling the amount of time yo ...
- windows家长时长控制_如何在Windows 7上使用家长控制
windows家长时长控制 Without some layer of protection, your kids are exposed to all kinds of risks and dang ...
- JS控制方块自动移动
通过JS的setTimeout事件来控制一个小方块绕屏幕移动: <html> <style type="text/css"></style>&l ...
- windows家长时长控制_如何在Windows 10上使用家长控制
windows家长时长控制 Parental controls on any digital system or service are important, both for protecting ...
最新文章
- python游戏最简单代码-如何利用Python开发一个简单的猜数字游戏
- 微信jssdk ajax 获取签名,【Golang版】微信access_token、jsapi_ticket、signature签名算法生成示例,开箱即用...
- webbrowser实现input tab事件_如何合理构造一个Uploader工具类(设计到实现)
- python读取坐标文本文件_Python 实现文件读写、坐标寻址、查找替换功能
- onvif学习笔记4:Windows环境使用gsoap生成onvif框架代码
- Springboot细节挖掘(对web的支持之数据校验)
- 通过开放重定向接管 GitHub Gist 账户,获奖$1万(GitHub $6.1万奖金系列之三)
- java代码使用Get请求或者Post请求获取网络内容
- 机器视觉检测:电阻电容的二次筛选提高效率及达成环保目的
- sem与seo的区别
- easyPOI之动态导出word模板
- 连续词袋模型(Continous bag of words, CBOW)
- Dynamips路由模拟器使用心得
- 身份证号码校验java
- 浙大版《C语言程序设计(第3版)》题目集
- 推荐3篇 如何建立自己的知识体系
- 群晖 6.1 重置 mysql,重置群晖Synology NAS
- 【每日新闻】国内首个3D缝纫机器人研制成功
- 使用JS实现俄罗斯方块游戏
- plc怎么与服务器无线通讯,两台PLC之间如何实现远程通讯