效果图:
以上效果使用 SDL2.0 所写
/**********************
使用 SDL 编写推箱子
***********************/
#include <stdlib.h>
#include <stdio.h>
#include <SDL.h>
#define WINDOW_WIDTH 416
#define WINDOW_HIGH 320
#define BOXS_WIDTH 13
#define BOXS_HIGH 10
#define PASS 6
SDL_Rect rect;
int index;
int direct; // 人物方向标识
void initGame();
int get_box();
int proessEvent(SDL_Window *window);
void drawMap(SDL_Texture ** texture, SDL_Renderer * renderer);
int map[PASS][BOXS_HIGH][BOXS_WIDTH] =
{
{
{0,0,0,1,1,1,0,0,0,0,0,0,0},
{0,0,0,1,3,1,0,0,0,0,0,0,0},
{0,0,0,1,0,1,1,1,1,0,0,0,0},
{0,1,1,1,4,0,4,3,1,0,0,0,0},
{0,1,3,0,4,5,1,1,1,0,0,0,0},
{0,1,1,1,1,4,1,0,0,0,0,0,0},
{0,0,0,0,1,3,1,0,0,0,0,0,0},
{0,0,0,0,1,1,1,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0}
},
{
{0,0,0,1,1,1,1,1,1,0,0,0,0},
{0,0,0,1,0,3,3,3,1,0,0,0,0},
{1,1,1,1,3,3,3,3,1,0,0,0,0},
{1,0,0,1,1,1,4,0,1,1,1,0,0},
{1,0,4,0,4,0,0,4,4,0,1,0,0},