原文地址:
一直都是自机在左上角这边很不好玩啊,我们把最基本的框架显示出来看看吧。
首先在GV.h 里把存储面板用的画像表示出来吧。
—————————————————————————————————————————————————————————————————————————————
GLOBAL int img_board[40];
—————————————————————————————————————————————————————————————————————————————
—————————————————————————————————————————————————————————————————————————————
--define.h改动--
#include "struct.h"
#define FIELD_MAX_X 384
#define FIELD_MAX_Y 448
#define FIELD_X 32
#define FIELD_Y 16
—————————————————————————————————————————————————————————————————————————————
—————————————————————————————————————————————————————————————————————————————
#include "../include/GV.h"
void calc_ch(){
ch.cnt++;
ch.img=(ch.cnt%24)/6;
}
—————————————————————————————————————————————————————————————————————————————
—————————————————————————————————————————————————————————————————————————————
GLOBAL void calc_ch();
—————————————————————————————————————————————————————————————————————————————
—————————————————————————————————————————————————————————————————————————————
#include "../include/GV.h"
void load(){
img_board[10] = LoadGraph("../dat/img/board/10.png");
img_board[11] = LoadGraph("../dat/img/board/11.png");
img_board[12] = LoadGraph("../dat/img/board/12.png");
img_board[20] = LoadGraph("../dat/img/board/20.png");
LoadDivGraph( "../dat/img/char/0.png" , 12 , 4 , 3 , 73 , 73 , img_ch[0] ) ;
}
—————————————————————————————————————————————————————————————————————————————
—————————————————————————————————————————————————————————————————————————————
#include "../include/GV.h"
//最开始坐标的初始化
void first_ini(){
ch.x=FIELD_MAX_X/2;
ch.y=FIELD_MAX_Y*3/4;
}
—————————————————————————————————————————————————————————————————————————————
—————————————————————————————————————————————————————————————————————————————
//--graph.cpp 的改动--
#include "../include/GV.h"
void graph_ch(){
DrawRotaGraphF(ch.x+FIELD_X,ch.y+FIELD_Y,1.0f,0.0f,img_ch[0][ch.img],TRUE);
}
void graph_board(){
DrawGraph( 0, 0,img_board[10],FALSE);
DrawGraph( 0, 16,img_board[11],FALSE);
DrawGraph( 0,464,img_board[12],FALSE);
DrawGraph(416, 0,img_board[20],FALSE);
}
void graph_main(){
graph_ch();
graph_board();
}
—————————————————————————————————————————————————————————————————————————————
—————————————————————————————————————————————————————————————————————————————
//--main.cpp改动--
#define GLOBAL_INSTANCE
#include "../include/GV.h"
//主循环里必须做的三大处理
int ProcessLoop()
{
if(ProcessMessage()!=0)
return -1 ; //Process处理出错的话,返回-1
if(ClearDrawScreen()!=0)
return -1; //画面清理出错的话,返回-1
GetHitKeyStateAll_2();//当前键盘输入的处理
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
ChangeWindowMode(TRUE); //窗口模式
if(DxLib_Init() == -1 || SetDrawScreen( DX_SCREEN_BACK )!=0) return -1; //初始化和设置双缓冲模式
while(ProcessLoop()==0) //主循环
{
switch(func_state)
{
case 0:
load(); //载入数据
first_ini(); //第一次初始化
func_state=100;
break;
case 100:
calc_ch();
graph_main();//主绘画函数
break;
default:
printfDx("未知的func_state\n");
break;
}
if(CheckStateKey(KEY_INPUT_ESCAPE)==1)
break; //按下ESC的话,break
ScreenFlip(); //交换双缓冲画面
}
DxLib_End();//DxLib中止
return 0;
}
————————————————————————————————————————————————————————————————————————————
本人CSDN博客目录: