用cmd编辑一个超级简单的小游戏,求代码
cmd吧
全部回复
仅看楼主
level 3
用cmd编辑一个超级简单的小游戏,求代码
2018年09月27日 11点09分 1
level 3
要最最简单,学习
2018年09月27日 11点09分 2
level 5
五子棋?贪吃蛇?俄罗斯方块?
2018年09月28日 00点09分 3
两个小时内能编完么
2018年09月28日 08点09分
level 5
扫雷?
2018年09月28日 00点09分 4
求代码。两小时内能编完么?
2018年09月28日 08点09分
@nice猫爪一伸 网上很多现成的,我记得批处理之家版主就写了个五子棋
2018年09月28日 08点09分
level 1
dfgtmg jdlkfjgdfgfgbff rgphdr0-4w854ruehfesirp3oq8322 ryb2q38u492u47034123o4ienbqyhsdaeq48721'
847129re'nq3c48hjgdidfjeifudoqa843'
qruwewiq;wr
2019年11月15日 08点11分 5
怕不是乱打一通吧,exe程序绝不是这样编的,也不是bat
2020年03月02日 08点03分
“ jdlkfjgdfgfgbff ”这明显就是在擦键盘嘛[哈哈]
2021年04月27日 15点04分
我的世界
2020年01月15日 09点01分
怎么用
2020年01月22日 11点01分
level 1
int a;int fajfj;
ifgh i9034 83403258784 hie pull 34vbd ;se;
ghjie
2020年02月26日 06点02分 6
这不会是乱打一气吧?在我的印象当中,不是这样的
2020年04月15日 08点04分
2020年11月04日 02点11分
不是吧,C语言也不是这样的啊!
2021年07月02日 13点07分
level 1
在哪个软件上
2020年03月03日 12点03分 7
微软[滑稽]
2020年03月03日 12点03分
level 1
贪吃蛇:
import java.awt.*;
import java.util.LinkedList;
import java.util.Scanner;
/**
* @Author aachen0
* @date 2018/3/27 13:56
* IDE:IntelliJ IDEA
*/
public class SnakeGame {
static final int WIDTH = 40, HEIGHT = 10;
static char[][] map = new char[HEIGHT][WIDTH];
public static void main(String[] args) {
SnakeGame snakeGame = new SnakeGame();
snakeGame.initBackground();//初始化背景,放只虫子
SnakeLine snakeLine = new SnakeLine();
snakeLine.initSnake();//初始化一条蛇
snakeGame.putSnakeInMap(snakeLine);
snakeGame.show();//显示一下
//键盘移动蛇进行游戏
Scanner scanner = new Scanner(System.in);
int move;
while (true) {
System.out.println("输入AWSD控制蛇的移动,Q退出游戏");
String choice = scanner.next();
switch (choice) {
case "a":
case "A":
move = 2;
break;
case "s":
case "S":
move = 1;
break;
case "w":
case "W":
move = 3;
break;
case "d":
case "D":
move = 0;
break;
case "q":
case "Q":
int points=snakeLine.snakePoints.size();
snakeGame.putGameOverInMap(points);
default:
System.out.println("输入有误,请重试");
continue;
}
if (snakeLine.move(move) == -1) {
snakeGame.putGameOverInMap(snakeLine.snakePoints.size());
snakeGame.show();
break;
}
snakeGame.putSnakeInMap(snakeLine);
snakeGame.show();
}
}
//用字符画背景
private void initBackground() {
for (int i = 0; i < HEIGHT; i++) {//外围控制行
for (int j = 0; j < WIDTH; j++) {//内循环控制各行的第几个
this.map[i][j] = (j == 0 || (j == WIDTH - 1) || i == 0 || (i == HEIGHT - 1)) ? '*' : ' ';
}
}
}
//显示背景
public void show() {
int height = map.length;
int width = map[0].length;
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
System.out.print(map[i][j]);
}
System.out.println();
}
}
//把加到地图
void putSnakeInMap(SnakeLine snakeLine) {
Point p;
this.initBackground();
map[SnakeLine.food.y][SnakeLine.food.x] = SnakeLine.worm;
for (int i = 0; i < snakeLine.snakePoints.size(); i++) {
p = snakeLine.snakePoints.get(i);
if (p.y > 0 && p.y < HEIGHT - 1 && p.x > 0 && p.x < WIDTH - 1) {
map[p.y][p.x] = (i == 0) ? snakeLine.head : snakeLine.body;
} else {
putGameOverInMap(snakeLine.snakePoints.size());
}
}
}
void putGameOverInMap(int points) {
char[] gameOver = ("GameOver Score:"+(points-3)).toCharArray();
for (int i = 0; i < gameOver.length; i++) {
map[HEIGHT / 2 - 1][i + (WIDTH - gameOver.length) / 2] = gameOver[i];
}
show();
System.exit(1);
}
}
class SnakeLine {
static final int RIGHT = 0, DOWN = 1, LEFT = 2, UP = 3;
static final char head = 'O', body = 'o', worm = '~';//头和身体表示
static Point food = new Point((int) (Math.random() * (SnakeGame.WIDTH - 2)) + 1, (int) (Math.random() * (SnakeGame.HEIGHT - 2)) + 1);
private void newFood() {
food = new Point((int) (Math.random() * (SnakeGame.WIDTH - 2)) + 1, (int) (Math.random() * (SnakeGame
.HEIGHT - 2)) + 1);
}
LinkedList<Point> snakePoints = new LinkedList<>();//蛇的身体内容
void initSnake() {
Point head = new Point(SnakeGame.WIDTH / 2, SnakeGame.HEIGHT / 2);
snakePoints.addFirst(head);//头
snakePoints.addLast(new Point(head.x - 1, head.y));
snakePoints.addLast(new Point(head.x - 2, head.y));
}
int move(int orient) {
Point p = snakePoints.getFirst();
Point np = null;
switch (orient) {
case SnakeLine.RIGHT:
np = new Point(p.x + 1, p.y);
break;
case SnakeLine.LEFT:
np = new Point(p.x - 1, p.y);
break;
case SnakeLine.DOWN:
np = new Point(p.x, p.y + 1);
break;
case SnakeLine.UP:
np = new Point(p.x, p.y - 1);
break;
}
if (snakePoints.contains(np)) {
return -1;//咬到自己了
}
snakePoints.addFirst(np);
if (np.equals(food)) {//吃到食物了
newFood();
return 2;
}
snakePoints.removeLast();
return 1;
}
}
自己写的
最后的txt改成cmd就行了,可以复制。
贪吃蛇
———————————————
版权声明:本文为CSDN博主「aachen0」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/aachen0/java/article/details/79721547
2020年05月11日 13点05分 10
人家跟你说纯CMD你发个JAVA是我有问题还是你有问题
2024年04月01日 01点04分
这不是java?[滑稽]
2020年08月16日 02点08分
老哥做java的?[滑稽][滑稽]
2020年09月02日 07点09分
真的假的在哪里运行
2021年03月26日 07点03分
level 1
hacknet
2020年08月12日 14点08分 11
level 1
#include<iostream>
#include<cstdio>
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
int main(){
int a=0,sheng=20,gong=10,fang=10,b,shengm=20,yao=0;
int guais,guaig,qian=0,c;
while(a==0){
cout<<"1.勇者商店"<<endl;
cout<<"2.讨伐魔物"<<endl;
cout<<"3.角色资料"<<endl;
cout<<"请选择..."<<endl;
cout<<endl;
cin>>b;
if(b==1){
cout<<"1.装备"<<endl;
cout<<"2.药品"<<endl;
cout<<"输入0退出"<<endl;
cout<<endl;
cin>>b;
if(b==1){
while(b!=0){
cout<<"1.武器"<<endl;
cout<<"2.盾牌"<<endl;
cout<<"3.盔甲"<<endl;
cout<<"输入0退出"<<endl;
cout<<endl;
cin>>b;
if(b==1){
cout<<"1.骑士长剑(+10) 价值:20"<<endl;
cout<<"2.石中剑(+20) 价值40"<<endl;
cout<<"3.魔王的右手(+90) 价值150"<<endl;
cout<<"输入4退出"<<endl;
cout<<endl;
cin>>b;
if(b==1&&qian>=20){
gong=20;
qian-=20;
cout<<"自身攻击"<<gong<<endl;
}
if(b==2&&qian>=40){
gong=30;
qian-=40;
cout<<"自身攻击"<<gong<<endl;
}
if(b==3&&qian>=150){
gong=100;
qian-=150;
cout<<"自身攻击"<<gong<<endl;
}
}
if(b==2){
cout<<"1.皇家盾牌(+10) 价值:20"<<endl;
cout<<"2.永恒堡垒(+20) 价值40"<<endl;
cout<<"3.魔王的左手(+90) 价值150"<<endl;
cout<<"输入4退出"<<endl;
cout<<endl;
cin>>b;
if(b==1&&qian>=20){
fang=20;
qian-=20;
cout<<"自身防御"<<fang<<endl;
}
if(b==2&&qian>=40){
fang=30;
qian-=40;
cout<<"自身防御"<<fang<<endl;
}
if(b==3&&qian>=150){
fang=100;
qian-=150;
cout<<"自身防御"<<fang<<endl;
}
}
if(b==3){
cout<<"1.战争盔甲(+10) 价值:20"<<endl;
cout<<"2.不灭龙甲(+20) 价值40"<<endl;
cout<<"3.魔王的精华(+90) 价值150"<<endl;
cout<<"输入4退出"<<endl;
cout<<endl;
cin>>b;
if(b==1&&qian>=20){
shengm=20;
qian-=20;
cout<<"自身生命"<<shengm<<endl;
}
if(b==2&&qian>=40){
shengm=30;
qian-=40;
cout<<"自身生命"<<shengm<<endl;
}
if(b==3&&qian>=150){
shengm=100;
qian-=150;
cout<<"自身生命"<<shengm<<endl;
}
}
}
}
if(b==2){
cout<<"1.快速回复(花费1)"<<endl;
cout<<"2.恢复药剂(花费5)*5"<<endl;
cout<<"输入0退出"<<endl;
cout<<endl;
cin>>b;
if(b==1&&qian>=1){
sheng=shengm;
qian--;
cout<<"自身生命"<<sheng<<endl;
}
if(b==2&&qian>=5){
yao=yao+5;
cout<<"药品数量"<<yao<<endl;
}
}
}
else if(b==2){
cout<<"1.小怪"<<endl;
if(gong>=15){
cout<<"2.魔头"<<endl;
if(gong>=20){
cout<<"3.大魔王"<<endl;
cout<<"输入0退出"<<endl;
cout<<endl;
cin>>b;
}
else{
cout<<"输入0退出"<<endl;
cout<<endl;
cin>>b;
}
}
else{
cout<<"输入0退出"<<endl;
cout<<endl;
cin>>b;
}
if(b==1){
guais=30;
guaig=5;
c=5;
while(guais>0&&sheng>0){
cout<<"1.攻击"<<endl;
cout<<"2.防御(次数"<<c<<")"<<endl;
cout<<"3.回复(闪避)"<<endl;
cout<<endl;
cin>>b;
if(b==1){
guais=guais-gong;
sheng=sheng-guaig;
cout<<"怪物生命"<<"-"<<gong<<"="<<guais<<endl;
cout<<"自身生命"<<"-"<<guaig<<"="<<sheng<<endl;
}
if(b==2&&c!=0){
if(fang>=guaig){
guais=guais-(fang-guaig);
cout<<"怪物生命"<<"-"<<fang-guaig<<"="<<guais<<endl;
}
else{
sheng=sheng-(guaig-fang);
cout<<"自身生命"<<"-"<<guaig-fang<<"="<<sheng<<endl;
}
c--;
}
if(b==3&&yao>0){
yao--;
sheng=sheng+20;
if(sheng>shengm)sheng=shengm;
cout<<"药品数量"<<yao<<endl;
cout<<"自身生命+20("<<sheng<<")"<<endl;
}
if(sheng<=0){
cout<<"你死了"<<endl;
break;
}
}
if(sheng>0){
qian=qian+2;
cout<<"金币"<<"+2"<<endl;
}
cout<<endl;
}
if(b==2){
guais=50;
guaig=10;
c=7;
while(guais>0&&sheng>0){
cout<<"1.攻击"<<endl;
cout<<"2.防御(次数"<<c<<")"<<endl;
cout<<"3.回复(闪避)"<<endl;
cout<<endl;
cin>>b;
if(b==1){
guais=guais-gong;
sheng=sheng-guaig;
cout<<"怪物生命"<<"-"<<gong<<"="<<guais<<endl;
cout<<"自身生命"<<"-"<<guaig<<"="<<sheng<<endl;
}
if(b==2&&c!=0){
if(fang>=guaig){
guais=guais-(fang-guaig);
cout<<"怪物生命"<<"-"<<fang-guaig<<"="<<guais<<endl;
}
else{
sheng=sheng-(guaig-fang);
cout<<"自身生命"<<"-"<<guaig-fang<<"="<<sheng<<endl;
}
c--;
}
if(b==3&&yao>0){
yao--;
sheng=sheng+20;
if(sheng>shengm)sheng=shengm;
cout<<"药品数量"<<yao<<endl;
cout<<"自身生命+20("<<sheng<<")"<<endl;
}
if(sheng<=0){
cout<<"你死了"<<endl;
break;
}
}
if(sheng>0){
qian=qian+10;
cout<<"金币"<<"+10"<<endl;
}
cout<<endl;
}
if(b==3){
guais=100;
guaig=20;
c=15;
while(guais>0&&sheng>0){
cout<<"1.攻击"<<endl;
cout<<"2.防御(次数"<<c<<")"<<endl;
cout<<"3.回复(闪避)"<<endl;
cout<<endl;
cin>>b;
if(b==1){
guais=guais-gong;
sheng=sheng-guaig;
cout<<"怪物生命"<<"-"<<gong<<"="<<guais<<endl;
cout<<"自身生命"<<"-"<<guaig<<"="<<sheng<<endl;
}
if(b==2&&c!=0){
if(fang>=guaig){
guais=guais-(fang-guaig);
cout<<"怪物生命"<<"-"<<fang-guaig<<"="<<guais<<endl;
}
else{
sheng=sheng-(guaig-fang);
cout<<"自身生命"<<"-"<<guaig-fang<<"="<<sheng<<endl;
}
c--;
}
if(b==3&&yao>0){
yao--;
sheng=sheng+20;
if(sheng>shengm)sheng=shengm;
cout<<"药品数量"<<yao<<endl;
cout<<"自身生命+20("<<sheng<<")"<<endl;
}
if(sheng<=0){
cout<<"你死了"<<endl;
break;
}
}
if(sheng>0){
qian=qian+100;
cout<<"金币"<<"+100"<<endl;
}
cout<<endl;
}
}
else if(b==3){
printf("请稍后");
for(int i=1;i<=5;i++){
printf(".");
Sleep(500);
}
printf("\n自身资料\n");
printf("----------------------------------------------\n");
printf("生命: %d ",sheng);
printf("攻击: %d\n\n",gong);
printf("防御: %d ",fang);
printf("生命上限: %d\n\n",shengm);
printf("金币: %d ",qian);
cout<<endl<<endl;
}
}
return 0;
}
2021年11月28日 05点11分 13
首先,输入BAT文件里没有任何反应
2024年04月01日 01点04分
level 10
lz
要的是批处理代码啊……简单的小游戏的话可以试试猜数字
2021年11月28日 15点11分 14
level 1
import turtle
turtle.speed('fastest')
turtle.pensize(1)
for y in range(200)
turtle.forward(3*y)
turtle.left(20)
turtle.right(175)
最后把后缀名改为.py
2022年02月01日 12点02分 15
level 1
楼主根本没有java或者python的环境,你们给他这些不是在逗他?运行程序都是需要环境的,cmd命令行运行 **.exe文件是运行打包好的环境
2022年02月23日 08点02分 16
level 1
看到@woxk-的代码,我突然想到了以前我写的伪代码:
run dhfnrf.pp {
# 高科技
jxejx 6
Efhvfhn 888
udfheurh java.bat
rem java.bat是附属程序。
java.bat ednfnjed/?
End Efhvfhn
End jxejx
}
#批处理
hefhruh echo 999 (
***** hfrhf
jfjefje
)
ueunriot /11111 b.gg
hfhgth fffff
coloe 1f
ehf4htb hfwhdh
{ ejrhejfnjr 1111&ehrhfrjjh}
tasklist|more
rem ↑唯一一句正常的↑
韩国艺人.exe ehhtbrthgrh 艺人 hwyueuh /a
8.ppp rdigjkfff
cls
echg ihrj4c
rvjrjucuj @' vjvrjhj
'vkgtjhj
exit
2023年02月05日 10点02分 19

2024年04月01日 01点04分
1