The FPS are now unfucked
This commit is contained in:
@@ -9675,5 +9675,6 @@ static const struct background_image_t{
|
||||
"#\300\002#\300\002#\300\002#\300\002#\300\002#\300\002#\300\002#\300\002#\300\002#\300\002#\300"
|
||||
"\002#\300\002#\300\002#\300\002#\300",
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -266,11 +266,11 @@ void Get_Color_From_Background(Point whereToLook,Color *color){
|
||||
color->Blue = SMPTE.pixel_data[index+2];
|
||||
}
|
||||
|
||||
void Get_Color_From_Sprite(Sprite_32x32 sprite, Point whereToLook, Color *color){
|
||||
int index = (whereToLook.Y*32+whereToLook.X)*3;
|
||||
color->Red = sprite.pixel_data[index];
|
||||
color->Green = sprite.pixel_data[index+1];
|
||||
color->Blue = sprite.pixel_data[index+2];
|
||||
void Get_Color_From_Sprite(Point whereToLook, Color *color){
|
||||
int index = ((whereToLook.Y << 5)+whereToLook.X)*3;
|
||||
color->Red = ShipSprite1.pixel_data[index];
|
||||
color->Green = ShipSprite1.pixel_data[index+1];
|
||||
color->Blue = ShipSprite1.pixel_data[index+2];
|
||||
}
|
||||
void auto_screen_roloff(Rectangle area,Point currentPos){
|
||||
if(currentPos.Y + area.Position.Y == SCREEN_HEIGHT){
|
||||
@@ -294,8 +294,9 @@ void Refresh_Area(Rectangle area){
|
||||
}
|
||||
}
|
||||
}
|
||||
int showDebug = 0;
|
||||
void Refresh_Player_Area(Rectangle area,Rectangle Hitbox){
|
||||
Sprite_32x32 sprite = ShipSprite1;
|
||||
//Sprite_32x32 sprite = ShipSprite1;
|
||||
Resize_Window(area);
|
||||
Write_Cmd(0x2C);
|
||||
Color color;
|
||||
@@ -307,14 +308,13 @@ void Refresh_Player_Area(Rectangle area,Rectangle Hitbox){
|
||||
&& x + area.Position.X >= Hitbox.Position.X
|
||||
&& x + area.Position.X < Hitbox.Position.X + Hitbox.Size.Width){
|
||||
|
||||
Get_Color_From_Sprite(sprite,(Point){x-(Hitbox.Position.X - area.Position.X),y-(Hitbox.Position.Y-area.Position.Y)},&color);
|
||||
|
||||
Get_Color_From_Sprite((Point){x-(Hitbox.Position.X - area.Position.X),y-(Hitbox.Position.Y-area.Position.Y)},&color);
|
||||
if(color.Red == 0 && color.Green == 0 && color.Blue == 0)
|
||||
Get_Color_From_Background((Point){area.Position.X+x,(area.Position.Y+y)%SCREEN_HEIGHT},&color);
|
||||
}else{
|
||||
Get_Color_From_Background((Point){area.Position.X+x,(area.Position.Y+y)%SCREEN_HEIGHT},&color);
|
||||
//if(y == 0 || y == area.Size.Height -1 || x == 0 || x == area.Size.Width -1)
|
||||
//color = (Color){255,0,0};
|
||||
if(showDebug && (y == 0 || y == area.Size.Height -1 || x == 0 || x == area.Size.Width -1))
|
||||
color = (Color){255,0,0};
|
||||
}
|
||||
SendPixel(color.Red,color.Green,color.Blue);
|
||||
}
|
||||
@@ -329,7 +329,7 @@ void DrawPlayer(Player player, Rectangle areaToDraw){
|
||||
auto_screen_roloff(player.Hitbox,(Point){0,y});
|
||||
for(int x = 0; x < (player.Hitbox.Size.Width+1);x++){
|
||||
if(y >= areaToDraw.Position.Y && y <= areaToDraw.Size.Height && x >= areaToDraw.Position.X && x <= areaToDraw.Size.Width){
|
||||
Get_Color_From_Sprite(sprite,(Point){x,y},&color);
|
||||
Get_Color_From_Sprite((Point){x,y},&color);
|
||||
if(color.Red != 0 && color.Green != 0 && color.Blue != 0){
|
||||
SendPixel(color.Red,color.Green,color.Blue);
|
||||
}else{
|
||||
|
||||
+2
-1
@@ -6,7 +6,7 @@
|
||||
const typedef struct Sprite_32x32_t{
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int bytes_per_pixel; /* 2:RGB16, 3:RGB, 4:RGBA */
|
||||
unsigned int bytes_per_pixel; /* 2:RGB16, 3:RGB, 4:RGBA */
|
||||
unsigned char pixel_data[32 * 32 * 3 + 1];
|
||||
}Sprite_32x32;
|
||||
|
||||
@@ -110,4 +110,5 @@ static const Sprite_32x32 ShipSprite1 = {
|
||||
"\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
|
||||
"\000\000\000\000\000\000",
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+9
-23
@@ -118,15 +118,8 @@ int min(int x,int y){
|
||||
}
|
||||
|
||||
void RefreshPlayer(Point vector){
|
||||
|
||||
/*
|
||||
if(vector.X != 0 || vector.Y != 0)
|
||||
Refresh_Area(player.Hitbox);
|
||||
*/
|
||||
|
||||
if(player.Hitbox.Position.Y + vector.Y < 0){
|
||||
player.Hitbox.Position.Y = SCREEN_SIZE.Height + (player.Hitbox.Position.Y - (0-vector.Y));
|
||||
//player.Hitbox.Position.Y = player.Hitbox.Position.Y % SCREEN_SIZE.Height;
|
||||
}else{
|
||||
if(player.Hitbox.Position.Y + vector.Y >= SCREEN_SIZE.Height){
|
||||
player.Hitbox.Position.Y = vector.Y - (SCREEN_SIZE.Height - player.Hitbox.Position.Y);
|
||||
@@ -152,16 +145,9 @@ void RefreshPlayer(Point vector){
|
||||
bigPos.Y = bigPos.Y % SCREEN_SIZE.Height;
|
||||
|
||||
Refresh_Player_Area((Rectangle){bigPos,bigSize},player.Hitbox);
|
||||
|
||||
/*
|
||||
Rectangle rect = player.Hitbox;
|
||||
rect.Position = (Point){0,0};
|
||||
DrawPlayer(player,rect);
|
||||
*/
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
|
||||
init();
|
||||
InitButtons();
|
||||
InitTimer();
|
||||
@@ -175,7 +161,7 @@ int main(void) {
|
||||
Draw_stars();
|
||||
|
||||
|
||||
int increment = 3;
|
||||
int increment = 1;
|
||||
Point momentum = {0,0};
|
||||
Size charSize = {7,11};
|
||||
|
||||
@@ -217,15 +203,15 @@ int main(void) {
|
||||
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 > 15)
|
||||
momentum.X = 15;
|
||||
if(momentum.X < -20)
|
||||
momentum.X = -20;
|
||||
|
||||
if(momentum.Y > 20)
|
||||
momentum.Y = 20;
|
||||
if(momentum.Y < -20)
|
||||
momentum.Y = -20;
|
||||
if(momentum.Y > 15)
|
||||
momentum.Y = 15;
|
||||
if(momentum.Y < -15)
|
||||
momentum.Y = -15;
|
||||
|
||||
RefreshPlayer(momentum);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user