⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 init.c

📁 TETRIS GAME, AUTO-PLAYER AND ARTIFICIAL INTELLIGENCY By Bluteau Thomas
💻 C
字号:
/************************/
/* Game Project for ACP */
/************************/

/***********************/
/*       TETRIS        */
/*    Thomas Bluteau   */
/***********************/


/*********************************************
  INIT.C contains functions initializing the
  game.
*********************************************/

#include "SDL.h"
#include "function.h"


/*********
Initialise the common and game variables
*********/
void init_Variables(t_infos * infos_globales, mov_t * mov)
{
			// The Color
	infos_globales->yellow = SDL_MapRGB(infos_globales->screen->format, 0xff, 0xff, 0x00);
	infos_globales->green = SDL_MapRGB(infos_globales->screen->format, 0x25, 0xAA, 0x25);
	infos_globales->red = SDL_MapRGB(infos_globales->screen->format, 0xff, 0x00, 0x00);
	infos_globales->blue = SDL_MapRGB(infos_globales->screen->format, 0x00, 0xFF, 0xFF);
	infos_globales->white = SDL_MapRGB(infos_globales->screen->format, 0xff, 0xff, 0xff);
	infos_globales->black = SDL_MapRGB(infos_globales->screen->format, 0x00, 0x00, 0x00);
	infos_globales->dark_blue = SDL_MapRGB(infos_globales->screen->format, 0x00, 0x00, 0xFF);
	infos_globales->orange = SDL_MapRGB(infos_globales->screen->format, 0xFF, 0x7F, 0x00);
	infos_globales->marron = SDL_MapRGB(infos_globales->screen->format, 0xE0, 0x80, 0x30);
			
		// The games variables
	infos_globales->speed_level = 300;		//This represent the speed level
	infos_globales->endGame = 0;			// Flag to detect the end of game
	infos_globales->fallCompleted = 0;		// Flag to detect the end fall for objec
	infos_globales->score = 0;
	infos_globales->line = 0;

		// The movement variables
	mov->vX = 0;							//No movement on the X axis
	mov->vY = 1;							//Gravity movement on the Y axis	
	mov->R = 0;								// No rotation
}



/************
Fill the ground of black square and draw a color for bound
************/
void initGround(t_infos *infos)
{
	int i,j;
	for(i=0;i<GRID_WIDTH;i++){
		for(j=0;j<GRID_HEIGHT;j++)
			infos->ground[i*GRID_HEIGHT+j] = infos->black;
	}
			//Paint the bounds
	for(i=0;i<GRID_WIDTH;i++){
		infos->ground[i*GRID_HEIGHT + GRID_HEIGHT-1] = infos->dark_blue;
	}
	for(i=0;i<GRID_HEIGHT;i++)
	{
		infos->ground[i] = infos->dark_blue;
		infos->ground[i + (GRID_HEIGHT*(GRID_WIDTH-1))] = infos->dark_blue;
	}	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -