Pārlūkot izejas kodu

[WIP] Started programming HUD. Maybe broken.

Florian DORMONT 12 gadi atpakaļ
vecāks
revīzija
99f2cf6096
5 mainītis faili ar 42 papildinājumiem un 9 dzēšanām
  1. 2 2
      ECode.h
  2. 2 2
      FXSH_Build.bat
  3. 32 0
      draw_states.c
  4. 1 0
      draw_states.h
  5. 5 5
      hexagon.g1w

+ 2 - 2
ECode.h

@@ -45,7 +45,7 @@
 // #define EASY_CHAR2STR
 // #define EASY_UCHAR2STR
 #define EASY_INT2STR
-// #define EASY_UINT2STR
+#define EASY_UINT2STR
 // #define EASY_FLOAT2STR
 
 /**TO NUMBER**/
@@ -111,7 +111,7 @@ void printn(unsigned char x, unsigned char y, int n, unsigned char mode);
 
 /**TO STRING OPERATIONS**/
 unsigned char* intToStr(unsigned char* c, int n);
-unsigned char* uintToStr(char* c, unsigned int n);
+unsigned char* uintToStr(unsigned char* c, unsigned int n);
 unsigned char* charToStr(char* c, char n);
 unsigned char* ucharToStr(char* c, unsigned char n);
 unsigned char* floatToStr(char* c, float f, int pecision);

+ 2 - 2
FXSH_Build.bat

@@ -1,7 +1,7 @@
 @echo off
 rem Do not edit! This batch file is created by CASIO fx-9860G SDK.
 
-
+if exist debug\*.obj  del debug\*.obj
 if exist HEXAGON.G1A  del HEXAGON.G1A
 
 cd debug
@@ -10,7 +10,7 @@ if exist FXADDINror.bin  del FXADDINror.bin
 cd ..
 if not exist debug\FXADDINror.bin  goto error
 
-"C:\Program Files\CASIO\fx-9860G SDK\Tools\MakeAddinHeader363.exe" "C:\Users\Florian\GIT\Super-Hexagon-Casio"
+"C:\Program Files\CASIO\fx-9860G SDK\Tools\MakeAddinHeader363.exe" "Z:\Super-Hexagon-Casio"
 if not exist HEXAGON.G1A  goto error
 echo Build has completed.
 goto end

+ 32 - 0
draw_states.c

@@ -1,4 +1,6 @@
 #include "draw_states.h"
+#include "fxlib.h"
+
 void draw_game(Game_Data *data)
 {
 	//draw the player and the lines
@@ -9,6 +11,8 @@ void draw_game(Game_Data *data)
 	//showing the walls
     if(data->list != NULL)
         drawWalls(data->list, &(data->cam));
+	//showing the HUD
+	drawGameHUD(data);
 }
 void draw_title(Game_Data *data)
 {
@@ -23,6 +27,34 @@ void draw_game_over(Game_Data *data)
 
 }
 
+int numDigits(unsigned int number)
+{
+    int digits = 0;
+    if (number <= 0) digits = 1; // remove this line if '-' counts as a digit
+    while (number) {
+        number /= 10;
+        digits++;
+    }
+    return digits;
+}
+
+
+//draws HUD
+//Shows the time elapsed and the current level
+void drawGameHUD(Game_Data *data) {
+	unsigned char timeBuffer[11] =""; 					//9 digits + . + \0
+	unsigned long int delta = RTC_GetTIcks() - data->start_time;
+	unsigned int centis = ((delta%128)/128.) *100; 		//calculate 1/100e second deciaml part
+	unsigned int seconds = delta /128;					//calculatr seconds
+	
+	unsigned char offset = 0;							//offset touse to merge strings in the same array
+	uintToStr(timeBuffer + offset, seconds);
+	offset += numDigits(seconds);
+	timeBuffer[offset++] ='.';
+	uintToStr(timeBuffer + offset, centis);
+	PrintMini(0, 8, timeBuffer, MINI_OVER);
+}
+
 //draws the player
 //at first, was supposed to draw an hexagon in the center, plus a triangle to show the player,
 //but the hexagon was not visible, and it was a pixel mess, so we're showing a circle instead.

+ 1 - 0
draw_states.h

@@ -11,4 +11,5 @@ void draw_game_over(Game_Data *data);
 
 void drawPlayer(Camera *cam, int player_angle);
 void drawDiagonal(int nb, Camera cam);
+void drawGameHUD(Game_Data *data);
 #endif

+ 5 - 5
hexagon.g1w

@@ -2,13 +2,13 @@
 Name=hexagon
 Version=1.00.0000
 Model=:fx-9860G.dlm
-SourcePath=SRC
-MemoryPath=INIT
-MemCardPath=SDCard
+SourcePath=\SRC
+MemoryPath=\INIT
+MemCardPath=\SDCard
 
 [Program1]
-Program=hexagon.G1A
-Debug=Debug\FXADDINror.dbg
+Program=\hexagon.G1A
+Debug=\Debug\FXADDINror.dbg
 LoadAddress=80000000:90100000
 
 [Files]