now the character has some momentum but the text is fucked again

This commit is contained in:
Rohmer Maxime
2024-06-13 17:28:59 +02:00
parent ce18682e77
commit 5f6bfb3439
9 changed files with 84 additions and 68 deletions
+1
View File
@@ -39,5 +39,6 @@ void Refresh_Area(Rectangle area);
void Draw_stars();
void Resize_Window(Rectangle area);
void DrawPlayer(Player player, Rectangle areaToDraw);
void DrawText(Point starting_point,char text[],Size charSize);
#endif /* SPI_H_ */
+23 -8
View File
@@ -146,12 +146,14 @@ int main(void) {
Resize_Window(SCREEN);
Draw_stars();
Point vec = {0,0};
int increment = 5;
Point momentum = {0,0};
while (true)
{
int JoystickState = JoystickGetState();
Point vec = {0,0};
if(JoystickState & (1 << 4)){
vec.X -= increment;
@@ -168,23 +170,36 @@ int main(void) {
if(need_to_scroll){
scroll(scrolling);
vec.Y -= 1;
player.Hitbox.Position.Y -= 1;
need_to_scroll = false;
int digits = number_of_digits(scrolling);
char newStr[digits+1];
convert_to_string(scrolling,digits,&newStr);
Size charSize = {7,11};
Point new_origin = {text_origin.X,(text_origin.Y + scrolling)%320};
Rectangle areaToRefresh = {{new_origin.X,new_origin.Y},{charSize.Width* 4,charSize.Height+5}};
Refresh_Area(areaToRefresh);
DrawText(new_origin,newStr,charSize);
Rectangle areaToRefresh = {{new_origin.X,new_origin.Y + charSize.Height},{charSize.Width* 4,charSize.Height}};
Refresh_Area(areaToRefresh);
}
if(vec.X != 0 || vec.Y != 0){
RefreshPlayer(vec);
}
momentum.X += vec.X;
momentum.Y += vec.Y;
if(momentum.X > 20)
momentum.X = 20;
if(momentum.X < -25)
momentum.X = -25;
if(momentum.Y > 20)
momentum.Y = 20;
if(momentum.Y < -20)
momentum.Y = -20;
RefreshPlayer(momentum);
}