Kaynağa Gözat

Added a few fixes in the state switching system

Adrien Boucaud 12 yıl önce
ebeveyn
işleme
b2ae0eb604
3 değiştirilmiş dosya ile 8 ekleme ve 5 silme
  1. 1 1
      hexagon.c
  2. 5 2
      init_states.c
  3. 2 2
      states.c

+ 1 - 1
hexagon.c

@@ -17,7 +17,7 @@ int AddIn_main(int isAppli, unsigned short OptionNum)
 	//rand initialisation
     srand(RTC_GetTicks());
 
-    switch_to_state(GAME, &data);
+    switch_to_state(MENU, &data);
 
     while(KeyUp(K_EXIT)){ //main loop
         //fps

+ 5 - 2
init_states.c

@@ -55,13 +55,16 @@ void load_difficulty_names(char **str_list)
 	char c_5[] = "Hardestest";
 	char c_6[] = "Hardestestest";
 
-	for(int i = 0; i < 6; i++)
+	int i = 0;
+	int j = 0;
+
+	for(i = 0; i < 6; i++)
 	{
 		str_list[i] = NULL;
 		str_list[i] = malloc(sizeof(char) * 24);
 		if(str_list[i] == NULL)
 			return;
-		for(int j = 0; j < 24; str_list[i][j] = 0, j++);
+		for(j = 0; j < 24; str_list[i][j] = 0, j++);
 	}
 	memcpy(str_list[0], c_1, sizeof(char) * strlen(c_1));
 	memcpy(str_list[1], c_2, sizeof(char) * strlen(c_2));

+ 2 - 2
states.c

@@ -1,6 +1,6 @@
 #include "states.h"
 
-State current_state = GAME;
+State current_state = MENU;
 void switch_to_state(State new_state, Game_Data *data)
 {
 	switch (new_state)
@@ -54,4 +54,4 @@ void draw(Game_Data *data)
 			draw_game_over(data);
 		break;
 	}
-}
+}