📄 editor.cpp
字号:
/////////////////////////////////////////////////////////////////////////////////////////////
// EDITOR.CPP
/////////////////////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include "engine.h"
#include "graphics.h"
#include "input.h"
#include "sound.h"
#include "editor.h"
extern BYTE Keys[256];
extern long MouseX, MouseY;
extern int ProgramState;
int Level[20][20][20];
/////////////////////////////////////////////////////////////////////////////////////////////
// LoadLevel
/////////////////////////////////////////////////////////////////////////////////////////////
void LoadLevel()
{
FILE *fp;
fp = fopen("LEVELS.DAT", "rb");
if(fp == NULL) return;
for(int i=0; i<20; i++)
for(int x=0; x<20; x++)
for(int y=0; y<20; y++)
fread(&Level[i][x][y], sizeof(int), 1, fp);
}
/////////////////////////////////////////////////////////////////////////////////////////////
// SaveLevel
/////////////////////////////////////////////////////////////////////////////////////////////
void SaveLevel()
{
FILE *fp;
fp = fopen("LEVELS.DAT", "wb");
if(fp == NULL) return;
for(int i=0; i<20; i++)
for(int x=0; x<20; x++)
for(int y=0; y<20; y++)
fwrite(&Level[i][x][y], sizeof(int), 1, fp);
}
/////////////////////////////////////////////////////////////////////////////////////////////
// UpdateEditor
/////////////////////////////////////////////////////////////////////////////////////////////
void UpdateEditor(void)
{
UpdateInput();
if(Keys[DIK_Q] & 0x80) ProgramState = PS_ACTIVE;
if(Keys[DIK_L] & 0x80) LoadLevel();
if(Keys[DIK_S] & 0x80) SaveLevel();
}
/////////////////////////////////////////////////////////////////////////////////////////////
// FiniEditor
/////////////////////////////////////////////////////////////////////////////////////////////
void FiniEditor()
{
for(int i=0; i<256; i++) Keys[i] = 0;
}
/////////////////////////////////////////////////////////////////////////////////////////////
// InitEditor
/////////////////////////////////////////////////////////////////////////////////////////////
void InitEditor()
{
for(int i=0; i<256; i++) Keys[i] = 0;
while(ProgramState == PS_EDITOR)
{
UpdateEditor();
}
FiniEditor();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -