fix on the movement model and the text is still fucked

This commit is contained in:
Rohmer Maxime
2024-06-13 17:54:29 +02:00
parent 5f6bfb3439
commit c32b714a81
9 changed files with 76 additions and 76 deletions
+1
View File
@@ -38,6 +38,7 @@ void ILI9341_Initial(void);
void Refresh_Area(Rectangle area);
void Draw_stars();
void Resize_Window(Rectangle area);
void Refresh_Area(Rectangle area);
void DrawPlayer(Player player, Rectangle areaToDraw);
void DrawText(Point starting_point,char text[],Size charSize);
+13 -14
View File
@@ -110,7 +110,7 @@ Player CreatePlayer(){
void RefreshPlayer(Point vector){
if(player.Hitbox.Position.Y + vector.Y < 0){
player.Hitbox.Position.Y = SCREEN_SIZE.Height - (0-vector.Y);
player.Hitbox.Position.Y = SCREEN_SIZE.Height + (player.Hitbox.Position.Y - (0-vector.Y));
}else{
if(player.Hitbox.Position.Y + vector.Y >= SCREEN_SIZE.Height){
player.Hitbox.Position.Y = vector.Y - (SCREEN_SIZE.Height - player.Hitbox.Position.Y);
@@ -147,8 +147,9 @@ int main(void) {
Draw_stars();
int increment = 5;
int increment = 3;
Point momentum = {0,0};
Size charSize = {7,11};
while (true)
{
@@ -169,6 +170,7 @@ int main(void) {
}
if(need_to_scroll){
//Refresh_Area((Rectangle){text_origin,(Size){charSize.Width * 3,charSize.Height}});
scroll(scrolling);
player.Hitbox.Position.Y -= 1;
need_to_scroll = false;
@@ -176,28 +178,25 @@ int main(void) {
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};
DrawText(new_origin,newStr,charSize);
Rectangle areaToRefresh = {{new_origin.X,new_origin.Y + charSize.Height},{charSize.Width* 4,charSize.Height}};
Refresh_Area(areaToRefresh);
Refresh_Area((Rectangle){(Point){new_origin.X,new_origin.Y + charSize.Height -1},(Size){charSize.Width * 3,charSize.Height - 2}});
}
momentum.X += vec.X;
momentum.Y += vec.Y;
if(momentum.X > 20)
momentum.X = 20;
if(momentum.X < -25)
momentum.X = -25;
if(momentum.X > 35)
momentum.X = 35;
if(momentum.X < -40)
momentum.X = -40;
if(momentum.Y > 20)
momentum.Y = 20;
if(momentum.Y < -20)
momentum.Y = -20;
if(momentum.Y > 35)
momentum.Y = 35;
if(momentum.Y < -35)
momentum.Y = -35;
RefreshPlayer(momentum);