跳到主要内容 Paper Minecraft V3.0 下界更新:基于 C++ 的 2D 控制台版我的世界实现 | 极客日志
C++ 算法
Paper Minecraft V3.0 下界更新:基于 C++ 的 2D 控制台版我的世界实现 本文介绍了 Paper Minecraft v3.0 增强版的玩法指南与技术实现。该游戏是基于 C++ 开发的 2D 控制台版我的世界,支持创造模式、多维度探索(主世界与下界)及丰富的方块系统。文章详细说明了基本操控、世界生成与管理、方块系统、下界维度系统(含传送门机制)、工具互动、设置选项及存档功能。核心特性包括程序化地形生成、双世界数据维护、实时渲染及防误操作延迟。提供了完整的 C++ 源代码示例,涵盖游戏状态管理、输入处理、方块渲染及下界逻辑。
《Paper Minecraft v3.0 - 增强版》玩法指南
🎮 游戏概述
这是一个基于控制台的 2D 版《我的世界》游戏,具有创造模式、多维度探索和丰富的方块系统。游戏采用 ASCII 字符图形,支持完整的世界生成、物品系统和跨维度冒险。
🕹️ 基本操控
游戏内操控(创造模式)
W/A/S/D - 向上/左/下/右移动
X - 破坏当前所在的方块
空格键 - 放置方块(或使用物品,如打火石)
数字键 1-0 - 快速切换快捷栏
E - 打开物品栏界面
P - 打开设置菜单
F5 - 快速保存游戏
F6 - 快速加载游戏
ESC - 暂停游戏/返回菜单
菜单导航
W/S - 上下移动选择项
空格键 - 确认选择
ESC - 返回上一级菜单
A/D - 在某些设置中切换选项值
回车键 - 在输入框确认输入
🌍 游戏功能详解
1. 世界生成与管理
新建世界 :在主菜单选择"New World",输入世界名称和种子
种子可为空(随机生成)或输入特定数字
世界名称不能重复
加载世界 :在主菜单选择"Load World",从已保存的世界中选择
世界保存 :
通过暂停菜单的"Save Game"保存
或按 F5 快速保存(仅当世界已有名称)
世界类型 :
主世界(Overworld):蓝色天空,包含草地、树木、矿石等
下界(Nether):红色环境,包含熔岩、下界岩、石英矿等
2. 方块系统
游戏包含超过 35 种不同的方块,包括:
基础方块 :草方块、泥土、石头、木头
矿石 :煤矿石、铁矿石、金矿石、钻石矿石、红石矿石、绿宝石矿石
下界方块 :下界岩、灵魂沙、下界砖、石英矿、下界金矿
特殊方块 :水、熔岩、黑曜石、萤石、蘑菇
功能方块 :下界传送门、火、打火石
3. 创造模式物品栏系统
游戏只有创造模式,但具有完整的物品管理系统:
无限资源 :所有方块无限供应
物品栏界面(E 键) :
显示 10 个快捷栏槽位
可交换物品位置(用空格键选择后交换)
包含"创造模式菜单"选项,可访问所有方块
创造模式菜单 :
浏览所有可用方块
选择后自动放入当前选中的快捷栏槽位
4. 下界维度系统
游戏的核心特色:完整的跨维度冒险
建造下界传送门 :
用黑曜石(方块 ID 32)建造 4×5 的框架
用打火石(方块 ID 31)点击框架底部激活
传送门需要 4×5 的外框,内部 2×3 区域为空
跨维度旅行 :
站在激活的传送门中自动进入另一维度
传送门有 2 秒冷却时间
两边的传送门会自动生成或激活
下界特色 :
独特的红色环境
熔岩海、岩浆块、下界堡垒
下界石英矿、下界金矿
下界蘑菇、灵魂沙
萤石吊灯
5. 工具与互动
打火石(方块 ID 31) :
用于激活传送门
也可用于点燃火(点击黑曜石以外的地方)
水与熔岩 :
可像普通方块一样放置
不能破坏基岩(方块 ID 7)和传送门方块
6. 游戏设置
通过 P 键或暂停菜单进入设置:
帧率调整 :5fps、10fps、50fps
渲染距离 :5、10、15 格
游戏保存/加载
返回游戏
🗺️ 世界生成特色
主世界:
程序化生成的山丘、山谷
自然生成的水体
随机树木和森林
地下矿洞系统
基岩层作为世界底部
下界:
多层基岩天花板和地板
复杂的洞穴系统
熔岩海
蘑菇森林
随机生成的地狱堡垒结构
矿脉:石英矿和金矿
📁 存档系统
游戏自动创建"saves"文件夹
每个世界保存为独立的.dat 文件
包含:
种子和世界数据
玩家位置和状态
主世界和下界的所有方块
物品栏内容
当前所在维度信息
⚙️ 技术特性
实时渲染 :根据渲染距离动态显示周围环境
双世界系统 :同时维护主世界和下界的数据
防误操作延迟 :菜单切换有 1 秒延迟,防止误操作
输入缓冲 :支持世界名称和种子输入
🎯 游戏目标(创造模式)
虽然创造模式没有明确目标,但可以:
建造 :创建宏伟的建筑和结构
探索 :发现两个维度的所有特性
工程 :建造功能性结构(如下界传送门系统)
收集 :获得所有类型的方块
💡 实用技巧
快速建筑 :使用创造模式菜单直接获取任何方块
维度标记 :在传送门旁建造地标,防止迷路
安全第一 :在下界小心熔岩海和岩浆块
备份存档 :重要建筑前先备份世界文件
种子分享 :记录有趣的种子与朋友分享相同世界
🚨 注意事项
游戏不能破坏基岩和传送门方块
水在下界会蒸发(游戏中可能不可放置)
某些方块(如火)会随时间消失
世界名称区分大小写
祝你在《Paper Minecraft v3.0》的方块世界中玩得愉快!有任何问题,可以查看游戏内的"About"部分获取更多信息。
#include <bits/stdc++.h>
#include <conio.h>
#include <windows.h>
#include <time.h>
#include <fstream>
#include <direct.h>
#include <io.h>
#include <sys/stat.h>
#define key(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1 : 0)
using namespace std;
enum GameState { MAIN_MENU, IN_GAME, INVENTORY_MENU, SETTINGS_MENU, NEW_WORLD_MENU, LOAD_WORLD_MENU, NETHER_DIMENSION };
GameState gameState = MAIN_MENU;
string worldName;
bool isCreativeMode = true ;
int world[301 ][601 ] = {0 };
int netherWorld[301 ][601 ] = {0 };
int grass[601 ] = {0 };
int x = 300 , y = 150 ;
int seed = 0 ;
int fps = 100 , render = 10 ;
int currentBlock = ;
inventory[ ] = { };
inventoryCount[ ] = { };
menuSelection = ;
inventorySelection = ;
worldSelection = ;
vector<string> savedWorlds;
creativeSelection = ;
isSelectingItem = ;
selectedSlot = ;
inNether = ;
worldNameInput[ ] = ;
seedInput[ ] = ;
inputPos = ;
DWORD lastStateChangeTime = ;
STATE_CHANGE_DELAY = ;
DWORD lastPortalTime = ;
PORTAL_COOLDOWN = ;
_color( a) {
( (STD_OUTPUT_HANDLE), a);
}
{
color;
string appe;
string name;
maxStack = ;
} block[ ];
{
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].maxStack = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].maxStack = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].maxStack = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].maxStack = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].maxStack = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
block[ ].appe = ;
block[ ].color = ;
block[ ].name = ;
( i = ; i < ; i++) {
inventory[i] = ;
inventoryCount[i] = ;
}
}
{
(id >= && id < && block[id].color >= ) {
_color(block[id].color);
( , block[id].appe. ());
} {
_color( );
( );
}
}
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
{
(x < || x > || y < || y > ) ;
( i = ; i < ; i++) {
(netherWorld[y + i][x] != ) ;
(netherWorld[y + i][x + ] != ) ;
}
( i = ; i < ; i++) {
(netherWorld[y][x + i] != ) ;
(netherWorld[y + ][x + i] != ) ;
}
( i = ; i <= ; i++) {
( j = ; j <= ; j++) {
(netherWorld[y + j][x + i] != && netherWorld[y + j][x + i] != ) ;
}
}
;
}
{
( i = ; i <= ; i++) {
( j = ; j <= ; j++) {
netherWorld[y + j][x + i] = ;
}
}
}
{
(inventory[currentBlock] != ) ;
(!inNether) {
(world[y][x] == ) {
( offsetX = ; offsetX <= ; offsetX++) {
( offsetY = ; offsetY <= ; offsetY++) {
portalX = x + offsetX;
portalY = y + offsetY;
(portalX >= && portalX <= && portalY >= && portalY <= ) {
( (portalX, portalY)) {
(portalX, portalY);
_color( );
( );
( );
;
}
}
}
}
world[y][x] = ;
_color( );
( );
( );
}
} {
(netherWorld[y][x] == ) {
( offsetX = ; offsetX <= ; offsetX++) {
( offsetY = ; offsetY <= ; offsetY++) {
portalX = x + offsetX;
portalY = y + offsetY;
(portalX >= && portalX <= && portalY >= && portalY <= ) {
( (portalX, portalY)) {
(portalX, portalY);
_color( );
( );
( );
;
}
}
}
}
netherWorld[y][x] = ;
_color( );
( );
( );
}
}
}
{
DWORD currentTime = ();
(currentTime - lastPortalTime < PORTAL_COOLDOWN) {
;
}
(!inNether) {
(world[y][x] == ) {
lastPortalTime = currentTime;
();
}
} {
(netherWorld[y][x] == ) {
lastPortalTime = currentTime;
();
}
}
}
{
(inNether) ;
inNether = ;
gameState = NETHER_DIMENSION;
lastStateChangeTime = ();
_color( );
( );
( );
netherEmpty = ;
( i = ; i <= ; i++) {
( j = ; j <= ; j++) {
(netherWorld[i][j] != && netherWorld[i][j] != ) {
netherEmpty = ;
;
}
}
(!netherEmpty) ;
}
(netherEmpty) {
();
}
portalX = ( (x, ), );
portalY = ( (y, ), );
(portalX > ) portalX = ;
(portalX < ) portalX = ;
( i = ; i < ; i++) {
netherWorld[portalY + i][portalX] = ;
netherWorld[portalY + i][portalX + ] = ;
}
( i = ; i < ; i++) {
netherWorld[portalY][portalX + i] = ;
netherWorld[portalY + ][portalX + i] = ;
}
( i = ; i <= ; i++) {
( j = ; j <= ; j++) {
netherWorld[portalY + j][portalX + i] = ;
}
}
x = portalX + ;
y = portalY + ;
}
{
(!inNether) ;
inNether = ;
gameState = IN_GAME;
lastStateChangeTime = ();
_color( );
( );
( );
portalX = ( (x, ), );
portalY = ( (y, ), );
(! (portalX, portalY)) {
( i = ; i < ; i++) {
world[portalY + i][portalX] = ;
world[portalY + i][portalX + ] = ;
}
( i = ; i < ; i++) {
world[portalY][portalX + i] = ;
world[portalY + ][portalX + i] = ;
}
}
(portalX, portalY);
x = portalX + ;
y = portalY + ;
}
{
(netherWorld, , (netherWorld));
( j = ; j <= ; j++) {
netherWorld[ ][j] = ;
netherWorld[ ][j] = ;
(j % == ) {
netherWorld[ ][j] = ;
netherWorld[ ][j] = ;
}
}
heightMap[ ];
noise = ;
heightMap[ ] = + () % ;
( j = ; j <= ; j++) {
change = () % - ;
heightMap[j] = ( , ( , heightMap[j ] + change * ( () % + )));
}
( j = ; j < ; j++) {
heightMap[j] = (heightMap[j ] + heightMap[j] + heightMap[j ]) / ;
}
( j = ; j <= ; j++) {
groundHeight = heightMap[j];
ceilingHeight = groundHeight - + () % ;
( i = ; i <= ; i++) {
(i <= ceilingHeight) {
netherWorld[i][j] = ;
} (i <= groundHeight) {
netherWorld[i][j] = ;
} {
netherWorld[i][j] = ;
}
}
}
lavaSeaLevel = ;
( j = ; j <= ; j++) {
( i = lavaSeaLevel - ; i <= lavaSeaLevel + ; i++) {
(i >= && i <= && netherWorld[i][j] == ) {
netherWorld[i][j] = ;
}
}
}
( cave = ; cave < ; cave++) {
cave_x = () % + ;
cave_y = + () % ;
cave_size = () % + ;
( i = -cave_size; i <= cave_size; i++) {
( jj = -cave_size; jj <= cave_size; jj++) {
(i*i + jj*jj <= cave_size*cave_size) {
nx = cave_x + i;
ny = cave_y + jj;
(nx >= && nx <= && ny >= && ny <= ) {
(netherWorld[ny][nx] == ) {
netherWorld[ny][nx] = ;
}
}
}
}
}
}
( j = ; j <= ; j++) {
( i = ; i <= ; i++) {
(netherWorld[i][j] == && netherWorld[i ][j] == ) {
( () % < ) {
glowstoneHeight = () % + ;
( k = ; k < glowstoneHeight; k++) {
(i + k <= && netherWorld[i + k][j] == ) {
netherWorld[i + k][j] = ;
}
}
}
}
}
}
( mushroom = ; mushroom < ; mushroom++) {
mush_x = () % + ;
mush_y = ;
( i = ; i <= ; i++) {
(netherWorld[i][mush_x] == && netherWorld[i ][mush_x] == ) {
mush_y = i + ;
;
}
}
(mush_y > && mush_y <= ) {
mush_size = () % + ;
( i = -mush_size; i <= mush_size; i++) {
( jj = -mush_size; jj <= mush_size; jj++) {
(i*i + jj*jj <= mush_size*mush_size) {
nx = mush_x + i;
ny = mush_y + jj;
(nx >= && nx <= && ny >= && ny <= ) {
(netherWorld[ny][nx] == && () % == ) {
netherWorld[ny][nx] = ;
}
}
}
}
}
}
}
( j = ; j <= ; j++) {
( i = ; i <= ; i++) {
(netherWorld[i][j] == ) {
( () % < ) {
netherWorld[i][j] = ;
}
(i > && () % < ) {
netherWorld[i][j] = ;
}
}
}
}
( j = ; j <= ; j++) {
( i = lavaSeaLevel - ; i <= lavaSeaLevel + ; i++) {
(i >= && i <= && netherWorld[i][j] == ) {
( () % < ) {
netherWorld[i][j] = ;
}
}
}
}
quartzCount = ;
( q = ; q < quartzCount; q++) {
qx = () % + ;
qy = + () % ;
(qx >= && qx <= && qy >= && qy <= ) {
(netherWorld[qy][qx] == ) {
netherWorld[qy][qx] = ;
( () % == ) {
veinSize = () % + ;
( dx = -veinSize; dx <= veinSize; dx++) {
( dy = -veinSize; dy <= veinSize; dy++) {
( (dx) + (dy) <= veinSize) {
nx = qx + dx;
ny = qy + dy;
(nx >= && nx <= && ny >= && ny <= ) {
(netherWorld[ny][nx] == ) {
netherWorld[ny][nx] = ;
}
}
}
}
}
}
}
}
}
goldCount = ;
( g = ; g < goldCount; g++) {
gx = () % + ;
gy = ;
locationType = () % ;
(locationType == ) {
( i = ; i <= ; i++) {
(netherWorld[i][gx] == && netherWorld[i ][gx] == ) {
gy = i;
;
}
}
} (locationType == ) {
( i = ; i <= ; i++) {
(netherWorld[i][gx] == && netherWorld[i ][gx] == ) {
gy = i;
;
}
}
} {
gy = lavaSeaLevel - ( () % + );
}
(gy > && gy <= && netherWorld[gy][gx] == ) {
netherWorld[gy][gx] = ;
( () % == ) {
veinSize = () % + ;
( dx = -veinSize; dx <= veinSize; dx++) {
( dy = -veinSize; dy <= veinSize; dy++) {
( (dx) + (dy) <= veinSize) {
nx = gx + dx;
ny = gy + dy;
(nx >= && nx <= && ny >= && ny <= ) {
(netherWorld[ny][nx] == ) {
netherWorld[ny][nx] = ;
}
}
}
}
}
}
}
}
( structure = ; structure < ; structure++) {
sx = () % + ;
sy = ;
( i = ; i <= ; i++) {
(netherWorld[i][sx] == && netherWorld[i ][sx] == ) {
sy = i;
;
}
}
(sy > && sy <= ) {
structureHeight = () % + ;
structureWidth = () % + ;
( i = ; i < structureHeight; i++) {
( jj = -structureWidth/ ; jj <= structureWidth/ ; jj++) {
nx = sx + jj;
ny = sy - i;
(nx >= && nx <= && ny >= && ny <= ) {
(i == || i == structureHeight || jj == -structureWidth/ || jj == structureWidth/ ) {
( () % == ) {
netherWorld[ny][nx] = ;
}
}
}
}
}
}
}
}
{
(x < || x > || y < || y > ) ;
( i = ; i < ; i++) {
(world[y + i][x] != ) ;
(world[y + i][x + ] != ) ;
}
( i = ; i < ; i++) {
(world[y][x + i] != ) ;
(world[y + ][x + i] != ) ;
}
( i = ; i <= ; i++) {
( j = ; j <= ; j++) {
(world[y + j][x + i] != ) ;
}
}
;
}
{
( i = ; i <= ; i++) {
( j = ; j <= ; j++) {
world[y + j][x + i] = ;
}
}
}
{
a = ;
( i = ; i <= x; i++) {
a = ();
}
a;
}
{
height= (x)% ;
treesize= +( (x)% );
i,j;
(grass[x] *treesize-height >= ){
(i= ;i<=height;i++){
world[grass[x]-i][x]= ;
}
(i=grass[x] *treesize-height ;i<grass[x]-height;i++){
(j=x-treesize;j<=x+treesize;j++){
world[i][j]= ;
}
}
}
}
{
vector<pair< , >> lowPoints;
( j = ; j < ; j++) {
(grass[j] > grass[j ] && grass[j] > grass[j ]) {
valleyDepth = (grass[j] - grass[j ], grass[j] - grass[j ]);
(valleyDepth >= ) {
lowPoints. ({j, grass[j]});
}
}
}
( & point : lowPoints) {
startX = point.first;
waterLevel = point.second + ;
leftX = startX;
(leftX > && grass[leftX] <= waterLevel) {
leftX--;
}
rightX = startX;
(rightX < && grass[rightX] <= waterLevel) {
rightX++;
}
waterLevel = (waterLevel, grass[startX] + );
( xx = leftX; xx <= rightX; xx++) {
( yy = waterLevel; yy <= waterLevel + ; yy++) {
(yy <= && world[yy][xx] == ) {
world[yy][xx] = ;
}
}
}
}
}
{
i, j, k;
grass[ ] = (seed) % + ;
(k = ; k <= ; k++) {
r = (seed + k - ) % ;
(r == ) grass[k] = grass[k - ] + ;
(r == ) grass[k] = grass[k - ] - ;
grass[k] = grass[k - ];
(grass[k] < ) grass[k] = ;
(grass[k] > ) grass[k] = ;
}
(j = ; j <= ; j++) {
(i = ; i < grass[j]; i++) {
world[i][j] = ;
}
world[grass[j]][j] = ;
(i = grass[j] + ; i <= grass[j] + ; i++) {
(i <= ) world[i][j] = ;
}
(i = grass[j] + ; i <= ; i++) {
(i <= ) world[i][j] = ;
}
world[ ][j] = ;
}
();
( cave = ; cave < ; cave++) {
cave_x = (seed + cave * ) % + ;
cave_y = (seed + cave * ) % + grass[cave_x] + ;
cave_size = (seed + cave * ) % + ;
( i = -cave_size; i <= cave_size; i++) {
( jj = -cave_size; jj <= cave_size; jj++) {
(i*i + jj*jj <= cave_size*cave_size) {
nx = cave_x + i;
ny = cave_y + jj;
(nx >= && nx <= && ny >= && ny <= ) {
(world[ny][nx] == ) world[ny][nx] = ;
}
}
}
}
}
(i = ; i <= ; i++){
( (grass[i]) % == ){
(i);
}
}
}
{
_color( );
( );
( i = ; i < ; i++) {
(i == currentBlock) {
_color( );
} {
_color( );
}
( );
(inventory[i] > && inventoryCount[i] > ) {
(inventory[i]);
_color( );
} {
( );
_color( );
}
( );
}
_color( );
( );
(inventory[currentBlock] > && inventoryCount[currentBlock] > ) {
(inventory[currentBlock]);
_color( );
( , block[inventory[currentBlock]].name. ());
} {
( );
}
}
{
( );
lastStateChangeTime = ();
creativeItems[] = { , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , };
itemCount = ;
( ) {
( () - lastStateChangeTime < STATE_CHANGE_DELAY) {
( );
;
}
( );
_color( );
( );
_color( );
( );
( i = ; i < itemCount; i++) {
(i == creativeSelection) {
_color( );
} {
_color( );
}
( , i );
(creativeItems[i]);
( , block[creativeItems[i]].name. ());
(i == creativeSelection) ( );
( );
}
( ( ) && creativeSelection > ) {
creativeSelection--;
( );
}
( ( ) && creativeSelection < itemCount ) {
creativeSelection++;
( );
}
( (VK_SPACE)) {
(currentBlock >= && currentBlock < ) {
inventory[currentBlock] = creativeItems[creativeSelection];
inventoryCount[currentBlock] = ;
;
}
}
( (VK_ESCAPE)) {
;
}
( );
}
}
{
( );
lastStateChangeTime = ();
( ) {
( () - lastStateChangeTime < STATE_CHANGE_DELAY) {
( );
;
}
( );
_color( );
( );
_color( );
( );
( i = ; i < ; i++) {
(i == inventorySelection) {
_color( );
} {
_color( );
}
( , i);
(inventory[i] > && inventoryCount[i] > ) {
(inventory[i]);
_color(i == inventorySelection ? : );
( , block[inventory[i]].name. ());
} {
( );
}
(i == currentBlock) ( );
(isSelectingItem && selectedSlot == i) ( );
( );
}
( );
(inventorySelection == ) {
_color( );
( );
_color( );
} {
( );
}
( ( ) && inventorySelection > ) {
inventorySelection--;
( );
}
( ( ) && inventorySelection < ) {
inventorySelection++;
( );
}
( (VK_SPACE)) {
(inventorySelection == ) {
();
inventorySelection = ;
} {
(!isSelectingItem) {
isSelectingItem = ;
selectedSlot = inventorySelection;
} {
(selectedSlot != inventorySelection) {
(inventory[selectedSlot], inventory[inventorySelection]);
(inventoryCount[selectedSlot], inventoryCount[inventorySelection]);
}
isSelectingItem = ;
selectedSlot = ;
}
}
}
( (VK_ESCAPE)) {
isSelectingItem = ;
selectedSlot = ;
;
}
( );
}
}
{
(blockId == || blockId == || blockId == || blockId == || blockId == ) ;
( i = ; i < ; i++) {
(inventory[i] == blockId && inventoryCount[i] < ) {
inventoryCount[i]++;
;
}
}
( i = ; i < ; i++) {
(inventory[i] == ) {
inventory[i] = blockId;
inventoryCount[i] = ;
;
}
}
}
{
(inventory[currentBlock] > && inventoryCount[currentBlock] > ) {
(!inNether) {
(world[y][x] == || world[y][x] == || world[y][x] == ) {
world[y][x] = inventory[currentBlock];
}
} {
(netherWorld[y][x] == || netherWorld[y][x] == || netherWorld[y][x] == || netherWorld[y][x] == ) {
netherWorld[y][x] = inventory[currentBlock];
}
}
}
}
{
string path = + filename + ;
buffer;
( (path. (), &buffer) == );
}
{
_mkdir( );
string path = + worldName + ;
( (worldName) && worldName != ) {
_color( );
( );
( );
;
}
;
(!file. ()) {
_color( );
( );
( );
;
}
file. (( *)&seed, ( ));
file. (( *)&x, ( ));
file. (( *)&y, ( ));
file. (( *)&inNether, ( ));
file. (( *)&isCreativeMode, ( ));
( i = ; i <= ; i++) {
file. (( *)&world[i][ ], * ( ));
}
( i = ; i <= ; i++) {
file. (( *)&netherWorld[i][ ], * ( ));
}
file. (( *)inventory, * ( ));
file. (( *)inventoryCount, * ( ));
file. ();
_color( );
( , path. ());
( );
}
{
string path = + filename + ;
(! (filename)) {
_color( );
( , path. ());
( );
;
}
;
(!file. ()) {
_color( );
( );
( );
;
}
file. (( *)&seed, ( ));
file. (( *)&x, ( ));
file. (( *)&y, ( ));
file. (( *)&inNether, ( ));
file. (( *)&isCreativeMode, ( ));
( i = ; i <= ; i++) {
file. (( *)&world[i][ ], * ( ));
}
( i = ; i <= ; i++) {
file. (( *)&netherWorld[i][ ], * ( ));
}
file. (( *)inventory, * ( ));
file. (( *)inventoryCount, * ( ));
file. ();
worldName = filename;
_color( );
( , path. ());
( );
}
{
savedWorlds. ();
info;
( ( , &info) != ) {
_mkdir( );
;
}
WIN32_FIND_DATA findFileData;
HANDLE hFind = ( , &findFileData);
(hFind != INVALID_HANDLE_VALUE) {
{
string filename = findFileData.cFileName;
filename = filename. ( , filename. () - );
savedWorlds. (filename);
} ( (hFind, &findFileData) != );
(hFind);
}
}
{
i, j;
(*currentWorld)[ ] = inNether ? netherWorld : world;
startY = ( , y - render);
endY = ( , y + render);
startX = ( , x - render);
endX = ( , x + render);
(i = startY; i <= endY; i++) {
(j = startX; j <= endX; j++) {
(i == y && j == x) {
_color( );
( );
} {
(inNether && currentWorld[i][j] == ) {
( );
} {
(currentWorld[i][j]);
}
}
( );
}
}
_color( );
( , x, y);
_color( );
( , /fps);
_color( );
( , render);
(inNether) {
_color( );
( );
} {
_color( );
( );
}
_color( );
(!worldName. ()) {
( , worldName. ());
}
();
_color( );
( );
}
{
op = ;
newfps = fps, newrender = render;
( );
lastStateChangeTime = ();
( ) {
( () - lastStateChangeTime < STATE_CHANGE_DELAY) {
( );
;
}
( );
_color( );
( );
( i = ; i < ; i++) {
(i == op) {
_color( );
} {
_color( );
}
(i) {
: ( );
(newfps == ) ( );
(newfps == ) ( );
( );
;
: ( );
(newrender == ) ( );
(newrender == ) ( );
( );
;
: ( );
;
: ( );
;
: ( );
;
}
( );
}
_color( );
( );
( ( ) && op > ) {
op--;
( );
}
( ( ) && op < ) {
op++;
( );
}
( (VK_SPACE) || ( )) {
(op) {
:
(newfps == ) newfps = ;
(newfps == ) newfps = ;
newfps = ;
;
:
(newrender == ) newrender = ;
(newrender == ) newrender = ;
newrender = ;
;
:
();
;
:
gameState = LOAD_WORLD_MENU;
();
;
:
fps = newfps;
render = newrender;
gameState = IN_GAME;
;
}
( );
}
( ( )) {
(op) {
:
(newfps == ) newfps = ;
(newfps == ) newfps = ;
newfps = ;
;
:
(newrender == ) newrender = ;
(newrender == ) newrender = ;
newrender = ;
;
}
( );
}
( (VK_ESCAPE)) {
gameState = IN_GAME;
;
}
( );
}
}
{
menuSelection = ;
( );
lastStateChangeTime = ();
(gameState == MAIN_MENU) {
( () - lastStateChangeTime < STATE_CHANGE_DELAY) {
( );
;
}
( );
_color( );
( );
_color( );
( );
string menuItems[] = { , , , };
( i = ; i < ; i++) {
(i == menuSelection) {
_color( );
( , menuItems[i]. ());
_color( );
} {
_color( );
( , menuItems[i]. ());
}
}
_color( );
( );
( ( ) && menuSelection > ) {
menuSelection--;
( );
}
( ( ) && menuSelection < ) {
menuSelection++;
( );
}
( (VK_SPACE)) {
(menuSelection) {
:
(worldNameInput, , (worldNameInput));
inputPos = ;
gameState = NEW_WORLD_MENU;
lastStateChangeTime = ();
;
:
gameState = LOAD_WORLD_MENU;
();
lastStateChangeTime = ();
;
:
( );
_color( );
( );
_color( );
( );
( );
( );
( );
( );
( );
( );
( );
( );
( );
( );
( );
( );
( );
_color( );
( );
(!_kbhit());
_getch();
;
:
( );
}
( );
}
( );
}
}
{
(worldNameInput, , (worldNameInput));
(seedInput, , (seedInput));
currentInput = ;
( );
lastStateChangeTime = ();
(gameState == NEW_WORLD_MENU) {
( () - lastStateChangeTime < STATE_CHANGE_DELAY) {
( );
;
}
( );
_color( );
( );
_color( );
( , worldNameInput);
(currentInput == ) ( );
( );
_color( );
( , seedInput);
(currentInput == ) ( );
( );
_color( );
( );
( );
(_kbhit()) {
ch = _getch();
(ch == || ch == ) {
(currentInput == ) {
( (worldNameInput) == ) {
_color( );
( );
( );
;
}
worldName = worldNameInput;
( (worldName)) {
_color( );
( );
( );
;
}
currentInput = ;
} (currentInput == ) {
( (seedInput) > ) {
seed = (seedInput);
} {
seed = ( ( ) + ()) % ;
(seedInput, , seed);
}
( );
seed = (seed % );
(seed);
(world, , (world));
(netherWorld, , (netherWorld));
(grass, , (grass));
();
();
();
x = ;
y = grass[ ] > ? grass[ ] - : ;
inventory[ ] = ;
inventoryCount[ ] = ;
inventory[ ] = ;
inventoryCount[ ] = ;
inventory[ ] = ;
inventoryCount[ ] = ;
inventory[ ] = ;
inventoryCount[ ] = ;
inventory[ ] = ;
inventoryCount[ ] = ;
gameState = IN_GAME;
lastStateChangeTime = ();
;
}
} (ch == ) {
(currentInput == && (worldNameInput) > ) {
worldNameInput[ (worldNameInput) ] = ;
} (currentInput == && (seedInput) > ) {
seedInput[ (seedInput) ] = ;
}
} (ch == ) {
gameState = MAIN_MENU;
lastStateChangeTime = ();
;
} ( (ch)) {
(currentInput == && (worldNameInput) < ) {
len = (worldNameInput);
worldNameInput[len] = ch;
worldNameInput[len ] = ;
} (currentInput == && (seedInput) < ) {
( (ch) || ch == ) {
len = (seedInput);
seedInput[len] = ch;
seedInput[len ] = ;
}
}
}
}
( );
}
}
{
worldSelection = ;
( );
lastStateChangeTime = ();
(gameState == LOAD_WORLD_MENU) {
( () - lastStateChangeTime < STATE_CHANGE_DELAY) {
( );
;
}
( );
_color( );
( );
(savedWorlds. ()) {
_color( );
( );
} {
( i = ; i < savedWorlds. (); i++) {
(i == worldSelection) {
_color( );
( , savedWorlds[i]. ());
_color( );
} {
( , savedWorlds[i]. ());
}
}
}
( );
(worldSelection == savedWorlds. ()) {
_color( );
( );
_color( );
} {
( );
}
_color( );
( );
totalItems = savedWorlds. () + ;
( ( ) && worldSelection > ) {
worldSelection--;
( );
}
( ( ) && worldSelection < totalItems - ) {
worldSelection++;
( );
}
( (VK_SPACE)) {
(worldSelection < savedWorlds. ()) {
(savedWorlds[worldSelection]);
gameState = IN_GAME;
lastStateChangeTime = ();
;
} {
gameState = MAIN_MENU;
lastStateChangeTime = ();
;
}
}
( (VK_ESCAPE)) {
gameState = MAIN_MENU;
lastStateChangeTime = ();
;
}
( );
}
}
{
( );
( );
( ( ));
();
( ) {
(gameState) {
MAIN_MENU:
();
;
NEW_WORLD_MENU:
();
;
LOAD_WORLD_MENU:
();
;
IN_GAME:
NETHER_DIMENSION:
();
( () - lastStateChangeTime < STATE_CHANGE_DELAY) {
(fps);
( );
;
}
( ( )) y--;
( ( )) y++;
( ( )) x--;
( ( )) x++;
(x > ) x = ;
(x < ) x = ;
(y > ) y = ;
(y < ) y = ;
( i = ; i < ; i++) {
( ( + i)) {
currentBlock = i;
}
}
( ( )) {
destroyedBlock;
(!inNether) {
destroyedBlock = world[y][x];
(destroyedBlock != && destroyedBlock != && destroyedBlock != && destroyedBlock != ) {
world[y][x] = ;
(destroyedBlock);
}
} {
destroyedBlock = netherWorld[y][x];
(destroyedBlock != && destroyedBlock != && destroyedBlock != && destroyedBlock != && destroyedBlock != ) {
netherWorld[y][x] = ;
(destroyedBlock);
}
}
}
( (VK_SPACE)) {
(inventory[currentBlock] == ) {
(x, y);
} {
();
}
}
();
( ( )) {
();
}
( ( )) {
();
}
( (VK_F5)) {
(!worldName. ()) {
();
}
}
( (VK_F6)) {
( ( )) {
( );
}
}
( (VK_ESCAPE)) {
pauseSelection = ;
DWORD pauseStartTime = ();
( ) {
( () - pauseStartTime < ) {
( );
;
}
( );
_color( );
( );
string pauseItems[] = { , , , , };
( i = ; i < ; i++) {
(i == pauseSelection) {
_color( );
( , pauseItems[i]. ());
_color( );
} {
( , pauseItems[i]. ());
}
}
_color( );
( );
( ( ) && pauseSelection > ) {
pauseSelection--;
( );
}
( ( ) && pauseSelection < ) {
pauseSelection++;
( );
}
( (VK_SPACE)) {
(pauseSelection) {
:
;
:
();
;
:
gameState = LOAD_WORLD_MENU;
();
lastStateChangeTime = ();
;
:
();
;
:
gameState = MAIN_MENU;
lastStateChangeTime = ();
;
}
;
}
( (VK_ESCAPE)) {
;
}
( );
}
}
(fps);
( );
;
}
}
;
}
微信扫一扫,关注极客日志 微信公众号「极客日志」,在微信中扫描左侧二维码关注。展示文案:极客日志 zeeklog
相关免费在线工具 加密/解密文本 使用加密算法(如AES、TripleDES、Rabbit或RC4)加密和解密文本明文。 在线工具,加密/解密文本在线工具,online
Base64 字符串编码/解码 将字符串编码和解码为其 Base64 格式表示形式即可。 在线工具,Base64 字符串编码/解码在线工具,online
Base64 文件转换器 将字符串、文件或图像转换为其 Base64 表示形式。 在线工具,Base64 文件转换器在线工具,online
Markdown 转 HTML 将 Markdown(GFM)转为 HTML 片段,浏览器内 marked 解析;与 HTML 转 Markdown 互为补充。 在线工具,Markdown 转 HTML在线工具,online
HTML 转 Markdown 将 HTML 片段转为 GitHub Flavored Markdown,支持标题、列表、链接、代码块与表格等;浏览器内处理,可链接预填。 在线工具,HTML 转 Markdown在线工具,online
JSON 压缩 通过删除不必要的空白来缩小和压缩JSON。 在线工具,JSON 压缩在线工具,online
0
int
10
0
int
10
0
int
0
int
0
int
0
int
0
bool
false
int
-1
bool
false
char
50
""
char
20
""
int
0
0
const
int
1000
0
const
int
2000
void
int
SetConsoleTextAttribute
GetStdHandle
struct
item
int
int
999999
100
void init ()
0
" "
0
144
0
"Air"
1
"██"
1
8
1
"Stone"
2
" ̄"
2
47
2
"Grass"
3
" "
3
111
3
"Dirt"
4
"||"
4
96
4
"Wood"
5
"◆◆"
5
14
5
"Coal Ore"
6
"◆◆"
6
8
6
"Iron Ore"
7
"=="
7
1
7
"Bedrock"
8
"◆◆"
8
15
8
"Gold Ore"
9
"◆◆"
9
11
9
"Diamond Ore"
10
"◆◆"
10
12
10
"Redstone Ore"
11
"◆◆"
11
13
11
"Emerald Ore"
12
"◆◆"
12
10
12
"Copper Ore"
13
"██"
13
7
13
"Cobblestone"
14
"██"
14
6
14
"Bricks"
15
"□"
15
8
15
"Gravel"
16
"??"
16
143
16
"Sand"
17
"※"
17
15
17
"Sandstone"
18
"▓▓"
18
10
18
"Leaves"
19
"██"
19
130
19
"Planks"
20
"██"
20
136
20
"Stone Bricks"
21
"~~"
21
9
21
"Water"
21
9999
22
"~~"
22
12
22
"Lava"
22
9999
23
"-="
23
15
23
"Glass"
24
"##"
24
14
24
"Glowstone"
25
"██"
25
112
25
"Snow"
26
"██"
26
159
26
"Ice"
27
"██"
27
42
27
"Mossy Cobble"
28
"██"
28
124
28
"Netherrack"
29
"██"
29
128
29
"Soul Sand"
30
"██"
30
192
30
"Nether Brick"
31
"FL"
31
8
31
"Flint and Steel"
31
1
32
"██"
32
5
32
"Obsidian"
33
"##"
33
13
33
"Nether Portal"
33
0
34
"**"
34
12
34
"Fire"
34
0
35
"◆◆"
35
15
35
"Nether Quartz"
36
"◆◆"
36
14
36
"Nether Gold"
37
" "
37
204
37
"Nether Air"
38
"MM"
38
13
38
"Nether Mushroom"
39
"MM"
39
12
39
"Magma Block"
for
int
0
10
0
0
void print (int id)
if
0
100
0
printf
"%s"
c_str
else
15
printf
" "
bool checkNetherPortalOverworld (int x, int y)
bool checkNetherPortalNether (int x, int y)
void activateNetherPortalOverworld (int x, int y)
void activateNetherPortalNether (int x, int y)
void useFlintAndSteel (int x, int y)
void enterNether ()
void returnToOverworld ()
void generateNether ()
void checkAndEnterPortal ()
int ran (int x)
void spawn_tree (int x)
void generateWater ()
void maps ()
void showHotbar ()
void showCreativeInventory ()
void showInventoryMenu ()
void addToInventory (int blockId)
void placeBlock ()
bool worldExists (string filename)
void saveGame ()
void loadGame (string filename)
void getSavedWorlds ()
void screen ()
void setting ()
void showMainMenu ()
void showNewWorldMenu ()
void showLoadWorldMenu ()
bool checkNetherPortalNether (int x, int y)
if
1
597
1
296
return
false
for
int
0
5
if
32
return
false
if
3
32
return
false
for
int
0
4
if
32
return
false
if
4
32
return
false
for
int
1
2
for
int
1
3
if
0
37
return
false
return
true
void activateNetherPortalNether (int x, int y)
for
int
1
2
for
int
1
3
33
void useFlintAndSteel (int x, int y)
if
31
return
if
if
32
for
int
-3
0
for
int
-4
0
int
int
if
1
597
1
296
if
checkNetherPortalOverworld
activateNetherPortalOverworld
10
printf
"Nether Portal Activated!\n"
Sleep
500
return
34
12
printf
"Fire!\n"
Sleep
200
else
if
32
for
int
-3
0
for
int
-4
0
int
int
if
1
597
1
296
if
checkNetherPortalNether
activateNetherPortalNether
10
printf
"Nether Portal Activated!\n"
Sleep
500
return
34
12
printf
"Fire!\n"
Sleep
200
void checkAndEnterPortal ()
GetTickCount
if
return
if
if
33
enterNether
else
if
33
returnToOverworld
void enterNether ()
if
return
true
GetTickCount
12
printf
"Entering the Nether...\n"
Sleep
1000
bool
true
for
int
1
300
for
int
1
600
if
0
37
false
break
if
break
if
generateNether
int
min
max
2
597
int
min
max
2
296
if
597
597
if
1
1
for
int
0
5
32
3
32
for
int
0
4
32
4
32
for
int
1
2
for
int
1
3
33
1
2
void returnToOverworld ()
if
return
false
GetTickCount
11
printf
"Returning to Overworld...\n"
Sleep
1000
int
min
max
2
597
int
min
max
2
296
if
checkNetherPortalOverworld
for
int
0
5
32
3
32
for
int
0
4
32
4
32
activateNetherPortalOverworld
1
2
void generateNether ()
memset
0
sizeof
for
int
1
600
1
7
300
7
if
10
0
2
7
299
7
int
601
int
0
1
50
rand
50
for
int
2
600
int
rand
3
1
max
10
min
200
-1
rand
3
1
for
int
2
600
-1
+1
3
for
int
1
600
int
int
80
rand
40
for
int
2
299
if
37
else
if
28
else
37
int
200
for
int
1
600
for
int
5
5
if
2
299
28
22
for
int
0
15
int
rand
600
1
int
100
rand
100
int
rand
20
10
for
int
for
int
if
int
int
if
1
600
2
299
if
28
37
for
int
1
600
for
int
2
299
if
37
-1
28
if
rand
100
2
int
rand
5
1
for
int
0
if
299
37
24
for
int
0
30
int
rand
600
1
int
0
for
int
2
299
if
28
+1
37
1
break
if
0
299
int
rand
5
3
for
int
for
int
if
int
int
if
1
600
2
299
if
37
rand
3
0
38
for
int
1
600
for
int
2
299
if
28
if
rand
100
3
15
if
150
rand
100
5
29
for
int
1
600
for
int
10
10
if
2
299
28
if
rand
100
8
39
int
200
for
int
0
int
rand
600
1
int
50
rand
200
if
1
600
2
299
if
28
35
if
rand
3
0
int
rand
3
1
for
int
for
int
if
abs
abs
int
int
if
1
600
2
299
if
28
35
int
100
for
int
0
int
rand
600
1
int
0
int
rand
3
if
0
for
int
100
250
if
37
+1
28
break
else
if
1
for
int
2
299
if
28
+1
37
break
else
rand
10
5
if
0
299
28
36
if
rand
2
0
int
rand
2
1
for
int
for
int
if
abs
abs
int
int
if
1
600
2
299
if
28
36
for
int
0
10
int
rand
600
1
int
0
for
int
2
299
if
28
+1
37
break
if
0
299
int
rand
10
5
int
rand
8
4
for
int
0
for
int
2
2
int
int
if
1
600
2
299
if
0
-1
2
2
if
rand
3
0
30
bool checkNetherPortalOverworld (int x, int y)
if
1
597
1
296
return
false
for
int
0
5
if
32
return
false
if
3
32
return
false
for
int
0
4
if
32
return
false
if
4
32
return
false
for
int
1
2
for
int
1
3
if
0
return
false
return
true
void activateNetherPortalOverworld (int x, int y)
for
int
1
2
for
int
1
3
33
int ran (int x)
int
50
for
int
1
rand
return
void spawn_tree (int x)
int
ran
3
+4
int
1
ran
4
int
if
-2
-1
0
for
1
4
for
-2
-1
for
18
void generateWater ()
int
int
for
int
2
600
if
-1
+1
int
min
-1
+1
if
3
push_back
for
auto
int
int
1
int
while
1
int
while
600
min
5
for
int
for
int
3
if
300
0
21
void maps ()
int
1
ran
15
20
for
2
600
int
ran
1
3
if
0
1
1
else
if
1
1
1
else
1
if
10
10
if
50
50
for
1
600
for
1
0
2
for
1
10
if
300
3
for
11
299
if
300
1
300
7
generateWater
for
int
0
40
int
ran
100
600
1
int
ran
200
100
15
int
ran
300
10
5
for
int
for
int
if
int
int
if
1
600
1
300
if
1
0
for
7
593
if
ran
11
8
spawn_tree
void showHotbar ()
15
printf
"\n"
for
int
0
10
if
240
else
15
printf
"["
if
0
0
print
15
else
printf
" "
15
printf
"] "
14
printf
" Selected: "
if
0
0
print
14
printf
" %s"
c_str
else
printf
"Empty"
void showCreativeInventory ()
system
"cls"
GetTickCount
int
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
35
36
38
39
int
36
while
true
if
GetTickCount
Sleep
100
continue
system
"cls"
14
printf
"=== CREATIVE INVENTORY ===\n"
15
printf
"WASD: Move Space: Select ESC: Back\n\n"
for
int
0
if
240
else
15
printf
"%02d. "
+1
print
printf
" %s"
c_str
if
printf
" <--"
printf
"\n"
if
key
'W'
0
Sleep
150
if
key
'S'
-1
Sleep
150
if
key
if
0
10
9999
return
if
key
return
Sleep
50
void showInventoryMenu ()
system
"cls"
GetTickCount
while
true
if
GetTickCount
Sleep
100
continue
system
"cls"
14
printf
"=== INVENTORY ===\n"
15
printf
"WASD: Move Space: Select/Exchange ESC: Exit\n\n"
for
int
0
10
if
240
else
15
printf
"Slot %d: "
if
0
0
print
240
15
printf
" %s "
c_str
else
printf
"Empty"
if
printf
" [HOTBAR]"
if
printf
" [SELECTED]"
printf
"\n"
printf
"\n"
if
10
240
printf
"> Creative Menu <\n"
15
else
printf
" Creative Menu\n"
if
key
'W'
0
Sleep
150
if
key
'S'
10
Sleep
150
if
key
if
10
showCreativeInventory
0
else
if
true
else
if
swap
swap
false
-1
if
key
false
-1
return
Sleep
50
void addToInventory (int blockId)
if
0
7
33
34
37
return
for
int
0
10
if
9999
return
for
int
0
10
if
0
1
return
void placeBlock ()
if
0
0
if
if
0
21
22
else
if
0
21
22
37
bool worldExists (string filename)
"saves/"
".dat"
struct
stat
return
stat
c_str
0
void saveGame ()
"saves"
"saves/"
".dat"
if
worldExists
"quicksave"
12
printf
"World name already exists!\n"
Sleep
1000
return
ofstream file (path.c_str(), ios::binary)
if
is_open
12
printf
"Failed to create save file!\n"
Sleep
1000
return
write
char
sizeof
int
write
char
sizeof
int
write
char
sizeof
int
write
char
sizeof
bool
write
char
sizeof
bool
for
int
0
300
write
char
0
601
sizeof
int
for
int
0
300
write
char
0
601
sizeof
int
write
char
10
sizeof
int
write
char
10
sizeof
int
close
10
printf
"Game saved to %s\n"
c_str
Sleep
1000
void loadGame (string filename)
"saves/"
".dat"
if
worldExists
12
printf
"Save file not found: %s\n"
c_str
Sleep
1000
return
ifstream file (path.c_str(), ios::binary)
if
is_open
12
printf
"Failed to open save file!\n"
Sleep
1000
return
read
char
sizeof
int
read
char
sizeof
int
read
char
sizeof
int
read
char
sizeof
bool
read
char
sizeof
bool
for
int
0
300
read
char
0
601
sizeof
int
for
int
0
300
read
char
0
601
sizeof
int
read
char
10
sizeof
int
read
char
10
sizeof
int
close
10
printf
"Game loaded from %s\n"
c_str
Sleep
1000
void getSavedWorlds ()
clear
struct
stat
if
stat
"saves"
0
"saves"
return
FindFirstFile
"saves\\*.dat"
if
do
substr
0
length
4
push_back
while
FindNextFile
0
FindClose
void screen ()
int
int
601
int
max
1
int
min
300
int
max
1
int
min
600
for
for
if
11
printf
"[]"
else
if
0
print
37
else
print
printf
"\n"
14
printf
"POS X:%d Y:%d "
10
printf
"FPS:%d "
1000
11
printf
"Render:%d "
if
12
printf
"NETHER "
else
11
printf
"OVERWORLD "
14
if
empty
printf
"World: %s"
c_str
showHotbar
8
printf
"\nE:Inventory P:Settings F5:Save F6:Load ESC:Menu"
void setting ()
int
0
int
system
"cls"
GetTickCount
while
true
if
GetTickCount
Sleep
100
continue
system
"cls"
15
printf
"### Settings ###\n\n"
for
int
0
5
if
240
else
15
switch
case
0
printf
"> Frame Rate: "
if
200
printf
"[5fps] 10fps 50fps"
else
if
100
printf
"5fps [10fps] 50fps"
else
printf
"5fps 10fps [50fps]"
break
case
1
printf
"> Render Distance: "
if
5
printf
"[5] 10 15"
else
if
10
printf
"5 [10] 15"
else
printf
"5 10 [15]"
break
case
2
printf
"> Save Game"
break
case
3
printf
"> Load Game"
break
case
4
printf
"> Back to Game"
break
printf
"\n"
8
printf
"\nWASD: Navigate Space: Select D: Change value\n"
if
key
'W'
0
Sleep
150
if
key
'S'
4
Sleep
150
if
key
key
'A'
switch
case
0
if
200
100
else
if
100
18
else
200
break
case
1
if
5
10
else
if
10
15
else
5
break
case
2
saveGame
break
case
3
getSavedWorlds
return
case
4
return
Sleep
150
if
key
'D'
switch
case
0
if
200
100
else
if
100
18
else
200
break
case
1
if
5
10
else
if
10
15
else
5
break
Sleep
150
if
key
return
Sleep
50
void showMainMenu ()
0
system
"cls"
GetTickCount
while
if
GetTickCount
Sleep
100
continue
system
"cls"
14
printf
" Paper Minecraft v3.0 \n"
15
printf
" Enhanced Edition \n\n"
"New World"
"Load World"
"About"
"Quit"
for
int
0
4
if
224
printf
" > %s < \n"
c_str
15
else
15
printf
" %s \n"
c_str
7
printf
"\nWASD: Navigate Space: Select\n"
if
key
'W'
0
Sleep
200
if
key
'S'
3
Sleep
200
if
key
switch
case
0
memset
0
sizeof
0
GetTickCount
return
case
1
getSavedWorlds
GetTickCount
return
case
2
system
"cls"
14
printf
"\n\n About Paper Minecraft v3.0\n\n"
15
printf
" Enhanced Features:\n"
printf
" - Nether Dimension\n"
printf
" - Improved Water Generation\n"
printf
" - Enhanced Inventory System\n"
printf
" - World Management\n\n"
printf
" Controls:\n"
printf
" WASD - Move/Navigate menus\n"
printf
" Space - Select/Place block\n"
printf
" E - Open inventory\n"
printf
" X - Destroy block\n"
printf
" P - Settings\n"
printf
" F5 - Quick Save\n"
printf
" F6 - Quick Load\n"
printf
" ESC - Pause menu\n\n"
9
printf
" Press any key to continue..."
while
break
case
3
exit
0
Sleep
200
Sleep
100
void showNewWorldMenu ()
memset
0
sizeof
memset
0
sizeof
int
0
system
"cls"
GetTickCount
while
if
GetTickCount
Sleep
100
continue
system
"cls"
14
printf
"=== Create New World ===\n\n"
15
printf
"World Name: %s"
if
0
printf
"_"
printf
"\n"
15
printf
"Seed (press Enter for random): %s"
if
1
printf
"_"
printf
"\n\n"
8
printf
"Press Enter to confirm input\n"
printf
"Press ESC to go back\n"
if
char
if
'\r'
'\n'
if
0
if
strlen
0
12
printf
"\nWorld name cannot be empty!\n"
Sleep
1000
continue
if
worldExists
12
printf
"\nWorld name already exists!\n"
Sleep
1000
continue
1
else
if
1
if
strlen
0
atoi
else
time
NULL
GetTickCount
1000000
sprintf
"%d"
printf
"\nGenerating terrain...\n"
abs
10001
srand
memset
0
sizeof
memset
0
sizeof
memset
0
sizeof
init
maps
generateNether
300
300
0
300
1
150
0
2
0
999999
1
3
1
999999
2
1
2
999999
3
32
3
999999
4
31
4
1
GetTickCount
return
else
if
'\b'
if
0
strlen
0
strlen
-1
'\0'
else
if
1
strlen
0
strlen
-1
'\0'
else
if
27
GetTickCount
return
else
if
isprint
if
0
strlen
49
int
strlen
+1
'\0'
else
if
1
strlen
19
if
isdigit
'-'
int
strlen
+1
'\0'
Sleep
50
void showLoadWorldMenu ()
0
system
"cls"
GetTickCount
while
if
GetTickCount
Sleep
100
continue
system
"cls"
14
printf
"=== Load World ===\n\n"
if
empty
15
printf
"No saved worlds found!\n\n"
else
for
int
0
size
if
240
printf
"> %s <\n"
c_str
15
else
printf
" %s\n"
c_str
printf
"\n"
if
size
240
printf
"> Back <\n"
15
else
printf
" Back\n"
8
printf
"\nWASD: Navigate Space: Select ESC: Back\n"
int
size
1
if
key
'W'
0
Sleep
200
if
key
'S'
1
Sleep
200
if
key
if
size
loadGame
GetTickCount
return
else
GetTickCount
return
if
key
GetTickCount
return
Sleep
100
int main ()
system
"title Paper Minecraft v3.0 - Enhanced Edition"
system
"mode con cols=130 lines=45"
srand
time
NULL
init
while
true
switch
case
showMainMenu
break
case
showNewWorldMenu
break
case
showLoadWorldMenu
break
case
case
screen
if
GetTickCount
Sleep
system
"cls"
break
if
key
'W'
if
key
'S'
if
key
'A'
if
key
'D'
if
600
600
if
1
1
if
300
300
if
1
1
for
int
0
10
if
key
'0'
if
key
'X'
int
if
if
0
7
33
34
0
addToInventory
else
if
0
7
33
34
37
37
addToInventory
if
key
if
31
useFlintAndSteel
else
placeBlock
checkAndEnterPortal
if
key
'E'
showInventoryMenu
if
key
'P'
setting
if
key
if
empty
saveGame
if
key
if
worldExists
"quicksave"
loadGame
"quicksave"
if
key
int
0
GetTickCount
while
true
if
GetTickCount
500
Sleep
100
continue
system
"cls"
14
printf
"=== Game Paused ===\n\n"
"Resume"
"Save Game"
"Load Game"
"Settings"
"Quit to Menu"
for
int
0
5
if
240
printf
"> %s <\n"
c_str
15
else
printf
" %s\n"
c_str
8
printf
"\nWASD: Navigate Space: Select\n"
if
key
'W'
0
Sleep
200
if
key
'S'
4
Sleep
200
if
key
switch
case
0
break
case
1
saveGame
continue
case
2
getSavedWorlds
GetTickCount
break
case
3
setting
break
case
4
GetTickCount
break
break
if
key
break
Sleep
100
Sleep
system
"cls"
break
return
0