correction de la dificulté

This commit is contained in:
leo 2021-07-11 22:32:59 +02:00
parent 0a2fd06876
commit 9b5fb92e86
2 changed files with 108 additions and 55 deletions

67
Biblio/UML/class.puml Normal file
View file

@ -0,0 +1,67 @@
@startuml
class Joueur {
+ int32_t x
+ int32_t y
+ int8_t dx
+ int8_t dy
+ int8_t health
+ Missile missile
---
modelise le joueur
}
class Missile{
+ int16_t x
+ int16_t y
+ int8_t dx
+ int8_t dy
+ Camps_missile equipe
+ uint8_t damage
+ uint8_t valide
---
modelise les missiles.
}
class Monster{
+ int32_t x
+ int32_t y
+ int16_t health
+ Missile missile
---
modelise les monstres.
}
class Collision{
uint8_t idx1
uint8_t idx2
uint8_t damage
---
décrit les colision entre missile et monstre.
}
enum Camps_missile{
MISSILE_AMI
MISSILE_ENNEMI
---
décrit le camps du missile.
}
enum End_type{
END_TABLEAU_VIDE
END_MORT_JOUEUR
---
décrit le type de fin de la partie.
}
enum Sens_ennemie{
DROITE
GAUCHE
---
décrit le sens de déplacement actuel des ennemis.
}
Joueur *-- Missile : décrit le missile de base du joueur.
Monster *-- Missile : décrit le missile de base des monstres.
Missile *-- Camps_missile : décrit le missile de base des monstres.
@enduml

View file

@ -102,11 +102,11 @@ static void MX_DMA2D_Init(void);
static void MX_CRC_Init(void); static void MX_CRC_Init(void);
static void MX_RNG_Init(void); static void MX_RNG_Init(void);
static void MX_ADC1_Init(void); static void MX_ADC1_Init(void);
void f_GameMaster(void const * argument); void f_GameMaster(void const *argument);
void f_Joueur_1(void const * argument); void f_Joueur_1(void const *argument);
void f_block_enemie(void const * argument); void f_block_enemie(void const *argument);
void f_projectile(void const * argument); void f_projectile(void const *argument);
void f_HUD(void const * argument); void f_HUD(void const *argument);
/* USER CODE BEGIN PFP */ /* USER CODE BEGIN PFP */
uint8_t proba_bernoulli(uint32_t numerateur, uint32_t denominateur); uint8_t proba_bernoulli(uint32_t numerateur, uint32_t denominateur);
@ -127,6 +127,12 @@ enum End_type
END_MORT_JOUEUR END_MORT_JOUEUR
}; };
enum Sens_ennemie
{
DROITE,
GAUCHE
};
const uint16_t joueur_width = 20; const uint16_t joueur_width = 20;
const uint16_t joueur_height = 20; const uint16_t joueur_height = 20;
@ -398,8 +404,7 @@ void SystemClock_Config(void)
} }
/** Initializes the CPU, AHB and APB buses clocks /** Initializes the CPU, AHB and APB buses clocks
*/ */
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4;
@ -409,7 +414,7 @@ void SystemClock_Config(void)
{ {
Error_Handler(); Error_Handler();
} }
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC|RCC_PERIPHCLK_CLK48; PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC | RCC_PERIPHCLK_CLK48;
PeriphClkInitStruct.PLLSAI.PLLSAIN = 384; PeriphClkInitStruct.PLLSAI.PLLSAIN = 384;
PeriphClkInitStruct.PLLSAI.PLLSAIR = 5; PeriphClkInitStruct.PLLSAI.PLLSAIR = 5;
PeriphClkInitStruct.PLLSAI.PLLSAIQ = 2; PeriphClkInitStruct.PLLSAI.PLLSAIQ = 2;
@ -470,7 +475,6 @@ static void MX_ADC1_Init(void)
/* USER CODE BEGIN ADC1_Init 2 */ /* USER CODE BEGIN ADC1_Init 2 */
/* USER CODE END ADC1_Init 2 */ /* USER CODE END ADC1_Init 2 */
} }
/** /**
@ -520,7 +524,6 @@ static void MX_ADC3_Init(void)
/* USER CODE BEGIN ADC3_Init 2 */ /* USER CODE BEGIN ADC3_Init 2 */
/* USER CODE END ADC3_Init 2 */ /* USER CODE END ADC3_Init 2 */
} }
/** /**
@ -551,7 +554,6 @@ static void MX_CRC_Init(void)
/* USER CODE BEGIN CRC_Init 2 */ /* USER CODE BEGIN CRC_Init 2 */
/* USER CODE END CRC_Init 2 */ /* USER CODE END CRC_Init 2 */
} }
/** /**
@ -589,7 +591,6 @@ static void MX_DAC_Init(void)
/* USER CODE BEGIN DAC_Init 2 */ /* USER CODE BEGIN DAC_Init 2 */
/* USER CODE END DAC_Init 2 */ /* USER CODE END DAC_Init 2 */
} }
/** /**
@ -626,7 +627,6 @@ static void MX_DMA2D_Init(void)
/* USER CODE BEGIN DMA2D_Init 2 */ /* USER CODE BEGIN DMA2D_Init 2 */
/* USER CODE END DMA2D_Init 2 */ /* USER CODE END DMA2D_Init 2 */
} }
/** /**
@ -688,7 +688,6 @@ static void MX_LTDC_Init(void)
/* USER CODE BEGIN LTDC_Init 2 */ /* USER CODE BEGIN LTDC_Init 2 */
/* USER CODE END LTDC_Init 2 */ /* USER CODE END LTDC_Init 2 */
} }
/** /**
@ -714,7 +713,6 @@ static void MX_RNG_Init(void)
/* USER CODE BEGIN RNG_Init 2 */ /* USER CODE BEGIN RNG_Init 2 */
/* USER CODE END RNG_Init 2 */ /* USER CODE END RNG_Init 2 */
} }
/** /**
@ -761,7 +759,6 @@ static void MX_TIM1_Init(void)
/* USER CODE BEGIN TIM1_Init 2 */ /* USER CODE BEGIN TIM1_Init 2 */
/* USER CODE END TIM1_Init 2 */ /* USER CODE END TIM1_Init 2 */
} }
/** /**
@ -806,7 +803,6 @@ static void MX_TIM2_Init(void)
/* USER CODE BEGIN TIM2_Init 2 */ /* USER CODE BEGIN TIM2_Init 2 */
/* USER CODE END TIM2_Init 2 */ /* USER CODE END TIM2_Init 2 */
} }
/** /**
@ -872,7 +868,6 @@ static void MX_TIM3_Init(void)
/* USER CODE END TIM3_Init 2 */ /* USER CODE END TIM3_Init 2 */
HAL_TIM_MspPostInit(&htim3); HAL_TIM_MspPostInit(&htim3);
} }
/** /**
@ -917,7 +912,6 @@ static void MX_TIM5_Init(void)
/* USER CODE BEGIN TIM5_Init 2 */ /* USER CODE BEGIN TIM5_Init 2 */
/* USER CODE END TIM5_Init 2 */ /* USER CODE END TIM5_Init 2 */
} }
/** /**
@ -996,7 +990,6 @@ static void MX_TIM8_Init(void)
/* USER CODE END TIM8_Init 2 */ /* USER CODE END TIM8_Init 2 */
HAL_TIM_MspPostInit(&htim8); HAL_TIM_MspPostInit(&htim8);
} }
/* FMC initialization function */ /* FMC initialization function */
@ -1038,7 +1031,7 @@ static void MX_FMC_Init(void)
if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK) if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK)
{ {
Error_Handler( ); Error_Handler();
} }
/* USER CODE BEGIN FMC_Init 2 */ /* USER CODE BEGIN FMC_Init 2 */
@ -1069,7 +1062,7 @@ static void MX_GPIO_Init(void)
__HAL_RCC_GPIOH_CLK_ENABLE(); __HAL_RCC_GPIOH_CLK_ENABLE();
/*Configure GPIO pin Output Level */ /*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOE, LED14_Pin|LED15_Pin, GPIO_PIN_RESET); HAL_GPIO_WritePin(GPIOE, LED14_Pin | LED15_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */ /*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(OTG_FS_PowerSwitchOn_GPIO_Port, OTG_FS_PowerSwitchOn_Pin, GPIO_PIN_SET); HAL_GPIO_WritePin(OTG_FS_PowerSwitchOn_GPIO_Port, OTG_FS_PowerSwitchOn_Pin, GPIO_PIN_SET);
@ -1087,8 +1080,7 @@ static void MX_GPIO_Init(void)
HAL_GPIO_WritePin(LCD_DISP_GPIO_Port, LCD_DISP_Pin, GPIO_PIN_SET); HAL_GPIO_WritePin(LCD_DISP_GPIO_Port, LCD_DISP_Pin, GPIO_PIN_SET);
/*Configure GPIO pin Output Level */ /*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOH, LED13_Pin|LED17_Pin|LED11_Pin|LED12_Pin HAL_GPIO_WritePin(GPIOH, LED13_Pin | LED17_Pin | LED11_Pin | LED12_Pin | LED2_Pin | LED18_Pin, GPIO_PIN_RESET);
|LED2_Pin|LED18_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */ /*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(EXT_RST_GPIO_Port, EXT_RST_Pin, GPIO_PIN_RESET); HAL_GPIO_WritePin(EXT_RST_GPIO_Port, EXT_RST_Pin, GPIO_PIN_RESET);
@ -1100,7 +1092,7 @@ static void MX_GPIO_Init(void)
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
/*Configure GPIO pins : ARDUINO_SCL_D15_Pin ARDUINO_SDA_D14_Pin */ /*Configure GPIO pins : ARDUINO_SCL_D15_Pin ARDUINO_SDA_D14_Pin */
GPIO_InitStruct.Pin = ARDUINO_SCL_D15_Pin|ARDUINO_SDA_D14_Pin; GPIO_InitStruct.Pin = ARDUINO_SCL_D15_Pin | ARDUINO_SDA_D14_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
@ -1109,8 +1101,7 @@ static void MX_GPIO_Init(void)
/*Configure GPIO pins : ULPI_D7_Pin ULPI_D6_Pin ULPI_D5_Pin ULPI_D2_Pin /*Configure GPIO pins : ULPI_D7_Pin ULPI_D6_Pin ULPI_D5_Pin ULPI_D2_Pin
ULPI_D1_Pin ULPI_D4_Pin */ ULPI_D1_Pin ULPI_D4_Pin */
GPIO_InitStruct.Pin = ULPI_D7_Pin|ULPI_D6_Pin|ULPI_D5_Pin|ULPI_D2_Pin GPIO_InitStruct.Pin = ULPI_D7_Pin | ULPI_D6_Pin | ULPI_D5_Pin | ULPI_D2_Pin | ULPI_D1_Pin | ULPI_D4_Pin;
|ULPI_D1_Pin|ULPI_D4_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
@ -1118,13 +1109,13 @@ static void MX_GPIO_Init(void)
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/*Configure GPIO pins : BP2_Pin BP1_Pin */ /*Configure GPIO pins : BP2_Pin BP1_Pin */
GPIO_InitStruct.Pin = BP2_Pin|BP1_Pin; GPIO_InitStruct.Pin = BP2_Pin | BP1_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/*Configure GPIO pins : LED14_Pin LED15_Pin */ /*Configure GPIO pins : LED14_Pin LED15_Pin */
GPIO_InitStruct.Pin = LED14_Pin|LED15_Pin; GPIO_InitStruct.Pin = LED14_Pin | LED15_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
@ -1151,14 +1142,14 @@ static void MX_GPIO_Init(void)
HAL_GPIO_Init(Audio_INT_GPIO_Port, &GPIO_InitStruct); HAL_GPIO_Init(Audio_INT_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pins : OTG_FS_PowerSwitchOn_Pin LED16_Pin */ /*Configure GPIO pins : OTG_FS_PowerSwitchOn_Pin LED16_Pin */
GPIO_InitStruct.Pin = OTG_FS_PowerSwitchOn_Pin|LED16_Pin; GPIO_InitStruct.Pin = OTG_FS_PowerSwitchOn_Pin | LED16_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
/*Configure GPIO pins : LED3_Pin LCD_DISP_Pin */ /*Configure GPIO pins : LED3_Pin LCD_DISP_Pin */
GPIO_InitStruct.Pin = LED3_Pin|LCD_DISP_Pin; GPIO_InitStruct.Pin = LED3_Pin | LCD_DISP_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
@ -1184,7 +1175,7 @@ static void MX_GPIO_Init(void)
HAL_GPIO_Init(OTG_FS_OverCurrent_GPIO_Port, &GPIO_InitStruct); HAL_GPIO_Init(OTG_FS_OverCurrent_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pins : TP3_Pin NC2_Pin */ /*Configure GPIO pins : TP3_Pin NC2_Pin */
GPIO_InitStruct.Pin = TP3_Pin|NC2_Pin; GPIO_InitStruct.Pin = TP3_Pin | NC2_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
@ -1199,8 +1190,7 @@ static void MX_GPIO_Init(void)
/*Configure GPIO pins : LED13_Pin LED17_Pin LED11_Pin LED12_Pin /*Configure GPIO pins : LED13_Pin LED17_Pin LED11_Pin LED12_Pin
LED2_Pin LED18_Pin */ LED2_Pin LED18_Pin */
GPIO_InitStruct.Pin = LED13_Pin|LED17_Pin|LED11_Pin|LED12_Pin GPIO_InitStruct.Pin = LED13_Pin | LED17_Pin | LED11_Pin | LED12_Pin | LED2_Pin | LED18_Pin;
|LED2_Pin|LED18_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
@ -1229,7 +1219,7 @@ static void MX_GPIO_Init(void)
HAL_GPIO_Init(LCD_INT_GPIO_Port, &GPIO_InitStruct); HAL_GPIO_Init(LCD_INT_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pins : PC7 PC6 */ /*Configure GPIO pins : PC7 PC6 */
GPIO_InitStruct.Pin = GPIO_PIN_7|GPIO_PIN_6; GPIO_InitStruct.Pin = GPIO_PIN_7 | GPIO_PIN_6;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
@ -1245,7 +1235,7 @@ static void MX_GPIO_Init(void)
HAL_GPIO_Init(ULPI_NXT_GPIO_Port, &GPIO_InitStruct); HAL_GPIO_Init(ULPI_NXT_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pins : BP_JOYSTICK_Pin RMII_RXER_Pin */ /*Configure GPIO pins : BP_JOYSTICK_Pin RMII_RXER_Pin */
GPIO_InitStruct.Pin = BP_JOYSTICK_Pin|RMII_RXER_Pin; GPIO_InitStruct.Pin = BP_JOYSTICK_Pin | RMII_RXER_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
@ -1259,7 +1249,7 @@ static void MX_GPIO_Init(void)
HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
/*Configure GPIO pins : ULPI_STP_Pin ULPI_DIR_Pin */ /*Configure GPIO pins : ULPI_STP_Pin ULPI_DIR_Pin */
GPIO_InitStruct.Pin = ULPI_STP_Pin|ULPI_DIR_Pin; GPIO_InitStruct.Pin = ULPI_STP_Pin | ULPI_DIR_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
@ -1274,7 +1264,7 @@ static void MX_GPIO_Init(void)
HAL_GPIO_Init(EXT_RST_GPIO_Port, &GPIO_InitStruct); HAL_GPIO_Init(EXT_RST_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pins : LCD_SCL_Pin LCD_SDA_Pin */ /*Configure GPIO pins : LCD_SCL_Pin LCD_SDA_Pin */
GPIO_InitStruct.Pin = LCD_SCL_Pin|LCD_SDA_Pin; GPIO_InitStruct.Pin = LCD_SCL_Pin | LCD_SDA_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD; GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
@ -1282,7 +1272,7 @@ static void MX_GPIO_Init(void)
HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
/*Configure GPIO pins : ULPI_CLK_Pin ULPI_D0_Pin */ /*Configure GPIO pins : ULPI_CLK_Pin ULPI_D0_Pin */
GPIO_InitStruct.Pin = ULPI_CLK_Pin|ULPI_D0_Pin; GPIO_InitStruct.Pin = ULPI_CLK_Pin | ULPI_D0_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
@ -1290,13 +1280,12 @@ static void MX_GPIO_Init(void)
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/*Configure GPIO pins : PB14 PB15 */ /*Configure GPIO pins : PB14 PB15 */
GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15; GPIO_InitStruct.Pin = GPIO_PIN_14 | GPIO_PIN_15;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF5_SPI2; GPIO_InitStruct.Alternate = GPIO_AF5_SPI2;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
} }
/* USER CODE BEGIN 4 */ /* USER CODE BEGIN 4 */
@ -1412,7 +1401,7 @@ uint8_t colision_missile(uint16_t m_pos_x, uint16_t m_pos_y, uint16_t o_pos_x, u
* @retval None * @retval None
*/ */
/* USER CODE END Header_f_GameMaster */ /* USER CODE END Header_f_GameMaster */
void f_GameMaster(void const * argument) void f_GameMaster(void const *argument)
{ {
/* init code for LWIP */ /* init code for LWIP */
MX_LWIP_Init(); MX_LWIP_Init();
@ -1455,7 +1444,7 @@ void f_GameMaster(void const * argument)
* @retval None * @retval None
*/ */
/* USER CODE END Header_f_Joueur_1 */ /* USER CODE END Header_f_Joueur_1 */
void f_Joueur_1(void const * argument) void f_Joueur_1(void const *argument)
{ {
/* USER CODE BEGIN f_Joueur_1 */ /* USER CODE BEGIN f_Joueur_1 */
TickType_t xLastWakeTime; TickType_t xLastWakeTime;
@ -1552,14 +1541,10 @@ void f_Joueur_1(void const * argument)
* @retval None * @retval None
*/ */
/* USER CODE END Header_f_block_enemie */ /* USER CODE END Header_f_block_enemie */
void f_block_enemie(void const * argument) void f_block_enemie(void const *argument)
{ {
/* USER CODE BEGIN f_block_enemie */ /* USER CODE BEGIN f_block_enemie */
enum Sens_ennemie
{
DROITE,
GAUCHE
};
TickType_t xLastWakeTime; TickType_t xLastWakeTime;
xLastWakeTime = xTaskGetTickCount(); xLastWakeTime = xTaskGetTickCount();
const TickType_t xPeriodeTache = 200 / portTICK_PERIOD_MS; // Toute les demi secondes const TickType_t xPeriodeTache = 200 / portTICK_PERIOD_MS; // Toute les demi secondes
@ -1642,7 +1627,7 @@ void f_block_enemie(void const * argument)
{ {
if (Table_ennemis[idx1][idx2].health > 0) if (Table_ennemis[idx1][idx2].health > 0)
{ {
if (proba_bernoulli(1, 32)) if (proba_bernoulli(wave, 32))
{ {
missile.x = Table_ennemis[idx1][idx2].x + monstre_width / 2; missile.x = Table_ennemis[idx1][idx2].x + monstre_width / 2;
missile.y = Table_ennemis[idx1][idx2].y + monstre_height; missile.y = Table_ennemis[idx1][idx2].y + monstre_height;
@ -1663,7 +1648,7 @@ void f_block_enemie(void const * argument)
* @retval None * @retval None
*/ */
/* USER CODE END Header_f_projectile */ /* USER CODE END Header_f_projectile */
void f_projectile(void const * argument) void f_projectile(void const *argument)
{ {
/* USER CODE BEGIN f_projectile */ /* USER CODE BEGIN f_projectile */
TickType_t xLastWakeTime; TickType_t xLastWakeTime;
@ -1750,7 +1735,7 @@ void f_projectile(void const * argument)
* @retval None * @retval None
*/ */
/* USER CODE END Header_f_HUD */ /* USER CODE END Header_f_HUD */
void f_HUD(void const * argument) void f_HUD(void const *argument)
{ {
/* USER CODE BEGIN f_HUD */ /* USER CODE BEGIN f_HUD */
TickType_t xLastWakeTime; TickType_t xLastWakeTime;
@ -1768,7 +1753,7 @@ void f_HUD(void const * argument)
/* USER CODE END f_HUD */ /* USER CODE END f_HUD */
} }
/** /**
* @brief Period elapsed callback in non blocking mode * @brief Period elapsed callback in non blocking mode
* @note This function is called when TIM6 interrupt took place, inside * @note This function is called when TIM6 interrupt took place, inside
* HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment * HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
@ -1781,7 +1766,8 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
/* USER CODE BEGIN Callback 0 */ /* USER CODE BEGIN Callback 0 */
/* USER CODE END Callback 0 */ /* USER CODE END Callback 0 */
if (htim->Instance == TIM6) { if (htim->Instance == TIM6)
{
HAL_IncTick(); HAL_IncTick();
} }
/* USER CODE BEGIN Callback 1 */ /* USER CODE BEGIN Callback 1 */
@ -1804,7 +1790,7 @@ void Error_Handler(void)
/* USER CODE END Error_Handler_Debug */ /* USER CODE END Error_Handler_Debug */
} }
#ifdef USE_FULL_ASSERT #ifdef USE_FULL_ASSERT
/** /**
* @brief Reports the name of the source file and the source line number * @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred. * where the assert_param error has occurred.