资源简介
SDL俄罗斯方块,自己做的,6410开发板完美运行,内含SDLTetris-mouse文件夹和SDLTetris-ts文件夹,SDLTetris-mouse是鼠标控制的,SDLTetris-ts是触摸控制的,另附实验报告册,包括需求分析、系统设计等。

代码片段和文件信息
#include “SDL.h“
#include “SDL_image.h“
#include “SDL_mixer.h“
#include “SDL_ttf.h“
#include
#include
SDL_Surface *screen=NULL*bg=NULL*pic=NULL*message=NULL*up=NULL*left=NULL*right=NULL
*se=NULL*art=NULL*arting=NULL*op=NULL*ex=NULL*x=NULL*m=NULL*reart=NULL*re=NULL; //screen屏幕指针,bg背景图片指针,pic砖块,message字体信息
//Mix_Music *music = NULL;
//Mix_Chunk *down=NULL*turn=NULL*dele=NULL*over = NULL;
TTF_Font *font = NULL;
SDL_Color textcolor1 = {4524226}textcolor2={2553232}textcolor3={23318236};
const int width = 640;
const int height = 480;
const int picture = 30;
const int BPP = 16;
int moving = 0; //monving表示方块处于运动状态。
SDL_Rect clip; //整个程序随时用的矩形
int map[18][10]={0}; //整个数组
int scorelevel;
int delay; //初始化难度
int mousex=0;
int mousey=0;
typedef struct square
{
int x[4];
int y[4];
int num;
int status;
}position; //方块的信息,num是方块的编号,status表示处于两种状态之一,即水平与竖直状态。
position where;
int col1col2row1row2; //表示方块所处与的行与列
int des[3]; //用来表示每个坐标与标准坐标(x[3]y[3])之间的水平或竖直距离
int nextnow; //下一个方块的num与现在的num
void apply_bg(int xint yint wint h);
void apply_surface(int xint ySDL_Surface *fromSDL_Surface *toSDL_Rect *clip);
void clean();
void clean_pic();
void del(int row);
int go_down(int sound);
int go_left_right(int i);
void go_up();
void go_up_one();
void go_up_two();
int init();
void init_pic(int xint yint num);
void initGame();
void judge();
int load_files();
SDL_Surface *load_image(char *str);
void pause(int x);
void save();
void show_pic();
void print(int xint ychar *strint iint size); //在(xy)坐标打印信息;
void show_score();
int fail();
int go_somewhere(int xint y);
int go_to(int xint yint (*p)(intint));
void button(int x1int y1int x2int y2SDL_Surface *picture);
int main(int argcchar *argv[])
{
int t1 = 0;
SDL_Event event;
int quit=0;
int flag=0;
if(!init())
return 1;
if(!load_files())
return 1;
initGame();
srand((unsigned)time(NULL));
now=rand()%7+1;
while(!quit)
{
if(!moving) //如果不在运动状态,则需要预测下一个方块及产生上一次预测的方块
{
next=rand()%7+1;
where.num=next;
apply_bg(12*picture1*picture4*picture4*picture);
init_pic(91where.num);
show_pic();
where.num=now;
init_pic(00where.num);
now=next;
moving = 1;
show_pic();
}
SDL_Delay(delay);
while(SDL_PollEvent(&event))
{
switch(event.type)
{
case SDL_MOUSEBUTTONDOWN:
{
mousex=event.button.x;
mousey=event.button.y;
if(mousex>=560&&mousex<=590&&mousey>=110&&mousey<=140) //变形
{
go_up();
t1 = 1;
}
if(mousex>=520&&mousex<=550&&mousey>=150&&mousey<=180) //方块左移
go_to(-10go_somewhere);
if(mousex>=560&&mousex<=590&&mousey>=150&&mousey<=180) //加速下落
go_to(01go_somewhere);
if(mousex>=600&&mousex<=630&&mousey>=150&&mousey<=180) //方块右移
go_to(10go_somewhere);
if(mousex>=560&&mousex<=590&&mousey>=190&&mousey<=220) //暂停游戏
{
button(5601905902
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2013-01-04 14:34 SDL俄罗斯方块\
目录 0 2012-12-06 17:26 SDL俄罗斯方块\SDLTetris-mouse\
目录 0 2012-12-06 17:26 SDL俄罗斯方块\SDLTetris-mouse\fonts\
文件 45260 2010-07-13 13:29 SDL俄罗斯方块\SDLTetris-mouse\fonts\arlrdbd.ttf
文件 28360 2000-01-09 18:32 SDL俄罗斯方块\SDLTetris-mouse\fonts\Elements.ttf
文件 4009504 1999-03-22 00:32 SDL俄罗斯方块\SDLTetris-mouse\fonts\kaiti.ttf
文件 20024 2012-05-07 09:01 SDL俄罗斯方块\SDLTetris-mouse\fonts\Michaelmas.ttf
目录 0 2012-12-06 17:26 SDL俄罗斯方块\SDLTetris-mouse\images\
文件 2814 2012-05-11 11:12 SDL俄罗斯方块\SDLTetris-mouse\images\art.bmp
文件 2814 2012-05-11 11:25 SDL俄罗斯方块\SDLTetris-mouse\images\arting.bmp
文件 921654 2012-05-11 11:11 SDL俄罗斯方块\SDLTetris-mouse\images\background.bmp
文件 2814 2012-05-11 11:20 SDL俄罗斯方块\SDLTetris-mouse\images\ex.bmp
文件 2814 2012-05-11 11:12 SDL俄罗斯方块\SDLTetris-mouse\images\left.bmp
文件 2814 2012-05-11 11:19 SDL俄罗斯方块\SDLTetris-mouse\images\m.bmp
文件 2814 2012-05-11 11:12 SDL俄罗斯方块\SDLTetris-mouse\images\op.bmp
文件 2814 2012-05-13 15:31 SDL俄罗斯方块\SDLTetris-mouse\images\re.bmp
文件 2814 2012-05-11 11:23 SDL俄罗斯方块\SDLTetris-mouse\images\reart.bmp
文件 2814 2012-05-11 11:13 SDL俄罗斯方块\SDLTetris-mouse\images\right.bmp
文件 2814 2012-05-11 11:13 SDL俄罗斯方块\SDLTetris-mouse\images\se.bmp
文件 2814 2012-05-11 11:13 SDL俄罗斯方块\SDLTetris-mouse\images\up.bmp
文件 2814 2012-05-11 11:29 SDL俄罗斯方块\SDLTetris-mouse\images\wall.bmp
文件 2814 2012-05-11 12:44 SDL俄罗斯方块\SDLTetris-mouse\images\x.bmp
文件 19006 2012-05-13 21:57 SDL俄罗斯方块\SDLTetris-mouse\SDLTetris.c
目录 0 2012-12-06 17:26 SDL俄罗斯方块\SDLTetris-mouse\sounds\
文件 9322 2010-07-13 13:29 SDL俄罗斯方块\SDLTetris-mouse\sounds\gameover.wav
文件 5176 2010-07-13 13:29 SDL俄罗斯方块\SDLTetris-mouse\sounds\high.wav
文件 4554 2010-07-13 13:29 SDL俄罗斯方块\SDLTetris-mouse\sounds\low.wav
文件 3170 2010-07-13 13:29 SDL俄罗斯方块\SDLTetris-mouse\sounds\medium.wav
目录 0 2012-12-06 17:26 SDL俄罗斯方块\SDLTetris-ts\
目录 0 2012-12-06 17:26 SDL俄罗斯方块\SDLTetris-ts\fonts\
文件 45260 2010-07-13 13:29 SDL俄罗斯方块\SDLTetris-ts\fonts\arlrdbd.ttf
............此处省略18个文件信息
相关资源
- bp神经网络源代码,可直接运行
- 随机森林R语言代码
- 计算机图形学 边填充算法实现代码
- 直流无刷电机方波驱动 stm32 例程代码
- 仿知乎界面小程序源代码
- 贪吃蛇源代码.fla
- 周立功开发板ProASIC3实验-syn_FIFO代码
- IMX385驱动代码.zip
- dotnet 写字板 实验 源代码 不好请要不
- 图像二维小波变换的实现源代码
- 八三编码器设计 VHDL代码 简单,包附
- linux应用层的华容道游戏源代码
- 交通咨询模拟系统完整代码
- http请求状态代码
- 数值分析所有实验代码
- 网上拍卖系统完整源代码
- 音乐代码转换软件 单片机编程时用
- CSMA/CD等动画演示加源代码
- silicon lab公司的收音IC SI47XX全套开发工
- 用51单片机实现G代码翻译
- 合同管理系统的源代码(附数据库)
- 用VC 编写的仿QQ聊天室程序源代码
- web班级网站设计代码
- 38k单片机红外发送代码、keil
- STM32F103 串口程序(完整版)
- 网络唤醒代码
- VPC3_DPV1源代码,Profibus
- PB做的托盘程序(最小化后在左下角显
- RSA算法源码
- ubuntu9.10 可加载内核模块和字符设备驱
评论
共有 条评论